-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Emit check-cfg lints during attribute parsing rather than evaluation
#149215
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: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
|
Does it mean we would get warnings for non-active cfg attributes? #[cfg(target_os = "lol")] // warn and not active
#[cfg(unknown)] // currently doesn't warn, since above is not active, but will it with this PR?
fn foo() {}Regarding the non-accessible |
abb82ad to
4ee0f66
Compare
This comment has been minimized.
This comment has been minimized.
4ee0f66 to
f5e9e93
Compare
This comment has been minimized.
This comment has been minimized.
|
Attributes that are configured out (like in your example) are currently not parsed, and therefore this would not cause this warning, preserving the old behavior. I didn't think of this edgecase so I'll make sure to add a test for this. Indeed currently attribute lints are special and not emitted as a builtin lint. I'm gonna play around with this a bit and see if anything is stopping me from changing that |
…r=Urgau Run `eval_config_entry` on all branches so we always emit lints Fixes rust-lang#149090 Ideally I'd have liked to fix this issue using rust-lang#149215, and this is still the long term plan, but this is slightly more annoying to implement than I'd have liked to, and this is also a nice and easy solution to the problem. r? `@tgross35`
Rollup merge of #149380 - JonathanBrouwer:cfg_select_lints, r=Urgau Run `eval_config_entry` on all branches so we always emit lints Fixes #149090 Ideally I'd have liked to fix this issue using #149215, and this is still the long term plan, but this is slightly more annoying to implement than I'd have liked to, and this is also a nice and easy solution to the problem. r? `@tgross35`
Run `eval_config_entry` on all branches so we always emit lints Fixes rust-lang/rust#149090 Ideally I'd have liked to fix this issue using rust-lang/rust#149215, and this is still the long term plan, but this is slightly more annoying to implement than I'd have liked to, and this is also a nice and easy solution to the problem. r? `@tgross35`
|
☔ The latest upstream changes (presumably #149410) made this pull request unmergeable. Please resolve the merge conflicts. |
Run `eval_config_entry` on all branches so we always emit lints Fixes rust-lang/rust#149090 Ideally I'd have liked to fix this issue using rust-lang/rust#149215, and this is still the long term plan, but this is slightly more annoying to implement than I'd have liked to, and this is also a nice and easy solution to the problem. r? `@tgross35`
…elmann Move even more early buffered lints to dyn lint diagnostics Follow-up to #145881 and #145747. I originally wanted to migrate most if not the entire rest of the early buffered lints. However, when trying to migrate the buffered lints used by check-cfg I encountered a roadblock. Namely, it depends on `TyCtxt` (well, `Option<TyCtxt>`) which makes it quite hard to migrate (see also #147634 (comment), #147634 (comment) & #149215). So for now, I won't migrate it (maybe #149215 will find a solution), nor will I migrate the rest since it's quite tedious to migrate these. I'll leave them for future me.
f5e9e93 to
1b85568
Compare
|
☔ The latest upstream changes (presumably #149646) made this pull request unmergeable. Please resolve the merge conflicts. |
1b85568 to
557fcb0
Compare
557fcb0 to
5010285
Compare
|
Rebased on #149662 After that PR, this change becomes trivial, we don't need to move the lints and we have access to |
check-cfg lints to rustc_attr_parsingcheck-cfg during attribute parsing rather than evaluation
check-cfg during attribute parsing rather than evaluationcheck-cfg lints during attribute parsing rather than evaluation
5010285 to
b93aaa7
Compare
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.
Looks good to me. Thanks for making it impossible to miss the check-cfg diagnostics.
…nszelmann Move attribute lints to `rustc_lint` This PR changes two things: - This decouples the `AttributeLintKind` from the `Lint` it is emitted in. `cx.emit_lint` now takes both as an argument, rather than inferring the `Lint` from the `AttributeLintKind`. This is nice because: - It allows us to remove `AttributeLintKind::InvalidMacroExportArguments` - It allows us to move the choice between `USELESS_DEPRECATED` and `UNUSED_ATTRIBUTES` out of the lint emitting code - It allows the next change: - This moves `AttributeLintKind` to `rustc_lint_defs`, and the decorating code to `rustc_lint`. This is nice because: - It allows attribute lint decorating code to access the TypeCtxt, which unblocks rust-lang#149215 - It might allow most early buffered attribute lints to become dyn lint diagnostics in the future, as in rust-lang#147634 - It deduplicates `IllFormedAttributeInput` This PR does not change observable output of the compiler, as can be seen by no uitests being affected. r? `@jdonszelmann`
Rollup merge of #149662 - JonathanBrouwer:lint-rework, r=jdonszelmann Move attribute lints to `rustc_lint` This PR changes two things: - This decouples the `AttributeLintKind` from the `Lint` it is emitted in. `cx.emit_lint` now takes both as an argument, rather than inferring the `Lint` from the `AttributeLintKind`. This is nice because: - It allows us to remove `AttributeLintKind::InvalidMacroExportArguments` - It allows us to move the choice between `USELESS_DEPRECATED` and `UNUSED_ATTRIBUTES` out of the lint emitting code - It allows the next change: - This moves `AttributeLintKind` to `rustc_lint_defs`, and the decorating code to `rustc_lint`. This is nice because: - It allows attribute lint decorating code to access the TypeCtxt, which unblocks #149215 - It might allow most early buffered attribute lints to become dyn lint diagnostics in the future, as in #147634 - It deduplicates `IllFormedAttributeInput` This PR does not change observable output of the compiler, as can be seen by no uitests being affected. r? `@jdonszelmann`
b93aaa7 to
e7df904
Compare
|
Some changes occurred in compiler/rustc_attr_parsing Some changes occurred in compiler/rustc_hir/src/attrs |
|
The PR is ready to be merged now :) |
The goal of this PR is to make the
eval_config_entrynot have any side effects, by moving the check-cfg lints to the attribute parsing. This also helps ensure we do emit the lint in situations where the attribute happens to be parsed, but never evaluated.cc @jdonszelmann @Urgau for a vibe check if you feel like it