Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macros: improve the TokenStream quoter #40532

Merged
merged 1 commit into from
Mar 20, 2017

Conversation

jseyfried
Copy link
Contributor

@jseyfried jseyfried commented Mar 14, 2017

This PR

  • renames the TokenStream quoter from qquote! to quote!,
  • uses $ instead of unquote (e.g. let toks: TokenStream = ...; quote!([$toks])),
  • allows unquoting Tokens as well as TokenTrees and TokenStreams (fixes token quote should be able to unquote a single token #39746), and
  • to preserve syntactic space, requires that $ be followed by
    • a single identifier to unquote, or
    • another $ to produce a literal $.

r? @nrc

@jseyfried jseyfried changed the title Improve the TokenStream quoter. macros: improve the TokenStream quoter Mar 14, 2017
Copy link
Member

@nrc nrc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any clash between this quote! macro and the AST quote! macro? I don't recall if that is magically in the global namespace or anything.

r=me if not and with the $$ doc

@@ -29,6 +29,11 @@ pub fn plugin_registrar(reg: &mut Registry) {

// This macro is not very interesting, but it does contain delimited tokens with
// no content - `()` and `{}` - which has caused problems in the past.
// Also, it tests that we can escape `$` via `$$`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you document this in the doc comments for the quote module please?

Copy link
Contributor Author

@jseyfried jseyfried Mar 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@jseyfried
Copy link
Contributor Author

@nrc None of the AST quoters are named quote.

@jseyfried
Copy link
Contributor Author

@bors r=nrc

@bors
Copy link
Contributor

bors commented Mar 15, 2017

📌 Commit ce616a7 has been approved by nrc

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 17, 2017
…r, r=nrc

macros: improve the `TokenStream` quoter

This PR
 - renames the `TokenStream` quoter from `qquote!` to `quote!`,
 - uses `$` instead of `unquote` (e.g. `let toks: TokenStream = ...; quote!([$toks])`),
 - allows unquoting `Token`s as well as `TokenTree`s and `TokenStream`s (fixes rust-lang#39746), and
 - to preserve syntactic space, requires that `$` be followed by
   - a single identifier to unquote, or
   - another `$` to produce a literal `$`.

r? @nrc
arielb1 pushed a commit to arielb1/rust that referenced this pull request Mar 18, 2017
…r, r=nrc

macros: improve the `TokenStream` quoter

This PR
 - renames the `TokenStream` quoter from `qquote!` to `quote!`,
 - uses `$` instead of `unquote` (e.g. `let toks: TokenStream = ...; quote!([$toks])`),
 - allows unquoting `Token`s as well as `TokenTree`s and `TokenStream`s (fixes rust-lang#39746), and
 - to preserve syntactic space, requires that `$` be followed by
   - a single identifier to unquote, or
   - another `$` to produce a literal `$`.

r? @nrc
bors added a commit that referenced this pull request Mar 18, 2017
arielb1 pushed a commit to arielb1/rust that referenced this pull request Mar 19, 2017
…r, r=nrc

macros: improve the `TokenStream` quoter

This PR
 - renames the `TokenStream` quoter from `qquote!` to `quote!`,
 - uses `$` instead of `unquote` (e.g. `let toks: TokenStream = ...; quote!([$toks])`),
 - allows unquoting `Token`s as well as `TokenTree`s and `TokenStream`s (fixes rust-lang#39746), and
 - to preserve syntactic space, requires that `$` be followed by
   - a single identifier to unquote, or
   - another `$` to produce a literal `$`.

r? @nrc
frewsxcv added a commit to frewsxcv/rust that referenced this pull request Mar 20, 2017
…r, r=nrc

macros: improve the `TokenStream` quoter

This PR
 - renames the `TokenStream` quoter from `qquote!` to `quote!`,
 - uses `$` instead of `unquote` (e.g. `let toks: TokenStream = ...; quote!([$toks])`),
 - allows unquoting `Token`s as well as `TokenTree`s and `TokenStream`s (fixes rust-lang#39746), and
 - to preserve syntactic space, requires that `$` be followed by
   - a single identifier to unquote, or
   - another `$` to produce a literal `$`.

r? @nrc
bors added a commit that referenced this pull request Mar 20, 2017
Rollup of 9 pull requests

- Successful merges: #40241, #40281, #40398, #40521, #40532, #40554, #40566, #40581, #40587
- Failed merges:
@bors bors merged commit ce616a7 into rust-lang:master Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

token quote should be able to unquote a single token
3 participants