-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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 -Z crate-attr
diagnostics
#138336
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: Vadim Petrochenkov <[email protected]>
5e4599d
to
2d05a27
Compare
7fc52b8
to
74e6e2d
Compare
This comment has been minimized.
This comment has been minimized.
- Move `crate-attr` parsing from `rustc_builtin_macros` to `rustc_parse`. This is not a built-in macro. - Show the `#![ ... ]` in the span (to make it clear that it should not be included in the CLI argument) - Show more detailed errors when the crate has valid token trees but invalid syntax. Previously, `crate-attr=feature(foo),feature(bar)` would just say "invalid crate attribute" and point at the comma. Now, it explicitly says that the comma was unexpected, which is useful when using `--error-format=short`. It also fixes the column to show the correct span. - Recover from parse errors. Previously we would abort immediately on syntax errors; now we go on to try and type-check the rest of the crate. The new diagnostic code also happens to be slightly shorter.
74e6e2d
to
4b25b06
Compare
All kind of code injected by rustc consistently lives in |
The job Click to see the possible cause of the failure (guessed by this bot)
|
@@ -0,0 +1,3 @@ | |||
//@ compile-flags: '-Zcrate-attr=feature(yeet_expr)]fn main(){}#[inline' |
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 about -Zcrate-attr=feature(yeet_expr)]#![allow(warnings)
? aka when you have two attributes back to back rather than an item after an attribute.
crate-attr
parsing fromrustc_builtin_macros
torustc_parse
. This is not a built-in macro.#![ ... ]
in the span (to make it clear that it should notbe included in the CLI argument)
invalid syntax.
Previously,
crate-attr=feature(foo),feature(bar)
would just say"invalid crate attribute" and point at the comma. Now, it explicitly
says that the comma was unexpected, which is useful when using
--error-format=short
. It also fixes the column to show the correctspan.
syntax errors; now we go on to try and type-check the rest of the
crate.
The new diagnostic code also happens to be slightly shorter.
This builds on #138288; the last commit more clearly shows exactly how this changes diagnostics. You don't have to review the tests themselves (unless you want to i guess ^^ but in that case please leave the review on the other PR).
r? diagnostics