-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add a label to point to the lacking macro name definition #127557
Conversation
rustbot has assigned @compiler-errors. Use |
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.
LGTM, but one change needed. Afterwards I can approve.
@@ -1439,7 +1439,11 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { | |||
); | |||
|
|||
if macro_kind == MacroKind::Bang && ident.name == sym::macro_rules { | |||
err.subdiagnostic(MaybeMissingMacroRulesName { span: ident.span }); | |||
let primary_span = ident.span; | |||
let label_span = primary_span.with_hi(primary_span.hi() + BytePos(1)).shrink_to_hi(); |
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.
Manual manipulation of spans can cause issues in situations where we recover in the lexer. I don't think this diagnostic would look a lot worse if we just used primary_span.shrink_to_hi()
.
Alternatively, find a more "pure" way to express this span (or a similar one) without using bytepos.
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.
if we just used primary_span.shrink_to_hi()
This is also looks good to me. And it is more consistent between macro_rules! {}
and macro_rules!{}
, which will always point to the !
Alternatively, find a more "pure" way to express this span (or a similar one) without using bytepos.
I currently have few time to try this.
@rustbot author |
@rustbot review |
@bors r+ rollup |
Rollup of 7 pull requests Successful merges: - rust-lang#126575 (Make it crystal clear what lint `type_alias_bounds` actually signifies) - rust-lang#127017 (Extend rules of dead code analysis for impls for adts to impls for types refer to adts) - rust-lang#127523 (Migrate `dump-ice-to-disk` and `panic-abort-eh_frame` `run-make` tests to rmake) - rust-lang#127557 (Add a label to point to the lacking macro name definition) - rust-lang#127989 (Migrate `interdependent-c-libraries`, `compiler-rt-works-on-mingw` and `incr-foreign-head-span` `run-make` tests to rmake) - rust-lang#128099 (migrate tests/run-make/extern-flag-disambiguates to rmake) - rust-lang#128170 (Make Clone::clone a lang item) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#127557 - linyihai:issue-126694, r=compiler-errors Add a label to point to the lacking macro name definition Fixes rust-lang#126694, but adopts the suggestion from rust-lang#118295 ``` --> src/main.rs:1:14 | 1 | macro_rules! { | ^ put a macro name here ```
Fixes #126694, but adopts the suggestion from #118295