-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Handle macro invocation in attribute during parse #146579
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
base: master
Are you sure you want to change the base?
Conversation
Some changes occurred in compiler/rustc_attr_parsing |
r? @davidtwco rustbot has assigned @davidtwco. Use |
let before = self.parser.token.span.shrink_to_lo(); | ||
while let token::Ident(..) = self.parser.token.kind { | ||
self.parser.bump(); | ||
if self.parser.look_ahead(1, |t| matches!(t.kind, token::TokenKind::Bang)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we meet:
#[deprecated(note = a!=b)]
struct X;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Silly me, I organized things thinking of only parsing a macro and not a statement. I think that parse_stmt_without_recovery
will fail because of a lack of ;
, but I can look at the stmt.kind
instead. It should give the error with no note or structured suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll wait with further review for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally looking good though :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
r? jdonszelmann |
r? author |
This comment was marked as resolved.
This comment was marked as resolved.
``` error: expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found macro `concat` --> $DIR/macro-in-attribute.rs:4:21 | LL | #[deprecated(note = concat!("a", "b"))] | ^^^^^^^^^^^^^^^^^ macros are not allowed here ```
f48a21e
to
811d2e7
Compare
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
StmtKind::Expr(_) => "expression", | ||
StmtKind::Semi(_) => "statement", | ||
StmtKind::Empty => "semicolon", | ||
StmtKind::MacCall(_) => "macro", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"macro call"
intead of "macro"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, macro calls feel more appropriate
@rustbot author |
Reminder, once the PR becomes ready for a review, use |
☔ The latest upstream changes (presumably #147345) made this pull request unmergeable. Please resolve the merge conflicts. |
Fix #146325.