Skip to content

Give better error for macro_rules name - #89257

Merged
bors merged 1 commit into
rust-lang:masterfrom
aDotInTheVoid:macro-error-2
Oct 22, 2021
Merged

Give better error for macro_rules name#89257
bors merged 1 commit into
rust-lang:masterfrom
aDotInTheVoid:macro-error-2

Conversation

@aDotInTheVoid

Copy link
Copy Markdown
Member

follow up to #89221

r? @estebank

@rustbot modify labels: +A-diagnostics +A-parser

@rustbotrustbot added A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The lexing & parsing of Rust source code to an AST labels Sep 25, 2021
@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 25, 2021
Comment on lines 1539 to 1541

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: Seems like this code might be clearer if the return type were a struct with two boolean fields? E.g.:

structIsMacroRulesItem{is_macro_rules:bool,has_bang_after_macro_rules:bool,}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Or return Option<IsMacroRulesItem> with struct IsMacroRulesItem { has_bang: bool }

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Went with

enumIsMacroRulesItem{Yes{has_bang:bool},No,}

we could bikeshed this forever, but I think this is pritty clear

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't this equivalent to self.token.span?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Yep, didn't realise you could do that

@estebankestebank left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

After addressing the nitpicks, r=me

@aDotInTheVoid

Copy link
Copy Markdown
MemberAuthor

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@apirainoapiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 14, 2021
@jackh726

Copy link
Copy Markdown
Member

@bors r=estebank

@bors

bors commented Oct 21, 2021

Copy link
Copy Markdown
Collaborator

📌 Commit 729ff2d has been approved by estebank

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 21, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Oct 22, 2021
…bank
Give better error for `macro_rules name`
follow up to rust-lang#89221
r? `@estebank`
`@rustbot` modify labels: +A-diagnostics +A-parser
@JohnTitorJohnTitor mentioned this pull request Oct 22, 2021
@JohnTitorJohnTitor mentioned this pull request Oct 22, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 22, 2021
Rollup of 14 pull requests
Successful merges:
- rust-lang#87537 (Clarify undefined behaviour in binary heap, btree and hashset docs)
- rust-lang#88624 (Stabilize feature `saturating_div` for rust 1.58.0)
- rust-lang#89257 (Give better error for `macro_rules name`)
- rust-lang#89665 (Ensure that pushing empty path works as before on verbatim paths)
- rust-lang#89895 (Don't mark for loop iter expression as desugared)
- rust-lang#89922 (Update E0637 description to mention `&` w/o an explicit lifetime name)
- rust-lang#89944 (Change `Duration::[try_]from_secs_{f32, f64}` underflow error)
- rust-lang#89991 (rustc_ast: Turn `MutVisitor::token_visiting_enabled` into a constant)
- rust-lang#90028 (Reject closures in patterns)
- rust-lang#90069 (Fix const qualification when executed after promotion)
- rust-lang#90078 (Add a regression test for issue-83479)
- rust-lang#90114 (Add some tests for const_generics_defaults)
- rust-lang#90115 (Add test for issue rust-lang#78561)
- rust-lang#90129 (triagebot: Treat `I-*nominated` like `I-nominated`)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 8738d5d into rust-lang:masterOct 22, 2021
@rustbotrustbot added this to the 1.58.0 milestone Oct 22, 2021
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTS-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@aDotInTheVoid@jackh726@bors@estebank@camsteffen@camelid@apiraino@rust-highfive@rustbot