-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Improve TokenTree variants #18229
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
Improve TokenTree variants #18229
Conversation
448b25d
to
7580e84
Compare
Could you rename Don't you think the new cc #17830. |
Ah, this is true... Would boxing the delimiters help? That would take us to 12 words if my calculations are correct... |
Very nice. Isn't it 6 words? |
Unfortunately with this you lose the nice patten matching... but I guess that is not the biggest issue. |
Ok, updated with your suggestion. |
I've also just made a change to |
This came up when working [on the gl-rs generator extension](https://github.com/bjz/gl-rs/blob/990383de801bd2e233159d5be07c9b5622827620/src/gl_generator/lib.rs#L135-L146). The new definition of `TTDelim` adds an associated `Span` that covers the whole token tree and enforces the invariant that a delimited sequence of token trees must have an opening and closing delimiter. A `get_span` method has also been added to `TokenTree` type to make it easier to implement better error messages for syntax extensions.
This should be clearer, and fits in better with the `TTNonterminal` variant. Renames: - `TTTok` -> `TTToken` - `TTDelim` -> `TTDelimited` - `TTSeq` -> `TTSequence`
Rebased |
fix: Join rustfmt overrideCommand with project root When providing a custom rustfmt command, join it with the project root instead of the workspace root. This fixes rust-analyzer getting the wrong invocation path in projects containing subprojects. This makes the behaviour consistent with how a custom path provided in rust-analyzer.procMacro.server behaves already. Resolves issue rust-lang#18222
I have renamed the
TokenTree
variants to be longer and clearer, and to use standard capitalisation. They should also fit in better with the existingTTNonterminal
variant.The new definition of
TtDelimited
adds an associatedSpan
that covers the whole token tree, and moves the opening and closing delimiters out of the vector of delimited token trees. This came up when working on the gl-rs generator plugin.The
bool
inTtSequence
has been replaced with aKleeneOp
enum. This should make the intent of the code clearer (I had trouble understanding it).A
get_span
method has also been added toTokenTree
type to make it easier to implement better error messages for syntax extensions.[breaking-change]
Renamed:
TTTok
->TtToken
TTDelim
->TtDelimited
TTSeq
->TtSequence
TTNonterminal
->TtNonterminal
New definition of
TtDelimited
:New definition of
TtSequence
: