Recover on attribute in use tree#155254
Draft
scrabsha wants to merge 2 commits intorust-lang:mainfrom
Draft
Conversation
This comment has been minimized.
This comment has been minimized.
291ff75 to
290c04c
Compare
fmease
reviewed
Apr 13, 2026
| /// Consumes the tokens that constitute the attribute and returns them. | ||
| /// | ||
| /// /!\ Always emit an error if this function returns `Some(_)`. | ||
| fn recover_attr_in_use_tree(&mut self) -> Option<Span> { |
Member
There was a problem hiding this comment.
Is there any particular reason for why you don't just call the attribute subparsers directly and reject the attributes immediately after? There shouldn't be any issue with that like ambiguities or what have you.
Right now you're essentially reimplementing parts of the attribute parser.
E.g., for types & generic arguments where attributes are also not allowed, we just use the attribute subparsers.
Contributor
Author
There was a problem hiding this comment.
oh, good idea. thanks! i'll do that tomorrow
(note for tomorrow me: the logic is the same as Parser::parse_generic_arg)
290c04c to
83f6ae9
Compare
Contributor
Author
|
@fmease would you be ok with me assigning this PR to you? (once I have re-reviewed it again) |
Member
|
Sure! :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Renders as:

This requires passing two more arguments to
Parser::parse_use_treeand I'm not super happy about it. I did consider adding more context toParserinstead, but that did not sound like a good idea. Happy to rework my code to make it less ugly :)I am also not very happy that the deletion shows up as a green
~in the suggestion. I tried very hard to make it render properly but failed. I am not sure it's actually possible but would love to be proven wrong hehe