-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Move attribute lints to rustc_lint
#149662
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
Conversation
|
Some changes occurred in compiler/rustc_attr_parsing These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
|
☔ The latest upstream changes (presumably #149646) made this pull request unmergeable. Please resolve the merge conflicts. |
f10523e to
942e4b2
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| span, | ||
| ast::CRATE_NODE_ID, | ||
| BuiltinLintDiag::IllFormedAttributeInput { | ||
| BuiltinLintDiag::AttributeLint(AttributeLintKind::IllFormedAttributeInput { |
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.
is the reason we can't use the diagnostics infra like in https://github.com/rust-lang/rust/pull/147634/files#diff-2b4127dee93eb2b198d202fad306da78f9b475e75affb3e146dab4a579a041a2R236 still that we need to hash the lints for lowering?
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.
In the specific place this comment is on (this one is a bit special since it's not called from an attribute parser), we could theoretically convert to using dyn lint diagnostics now, but that would make the code uglier since we then need to inline the decorating code.
In general for all other attribute lints, the problem is that in late attribute parsing Attribute Lints are placed on a HirId, while the buffer_lint function expects a NodeId. I am planning on seeing if we can make buffer_lint also take a HirId, but not sure how hard that will be and that's definitely not for this PR.
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.
wait but buffer_lint doesn't do anything during late parsing those buffered lints are already emitted at this point
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.
did I miss something about how you implemented 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.
right we never use buffer_lint with a hirid. during later parsing those lints are sent to the hir owner info of the owner node that's being lowered, to be hashed with that node, and emitted once hir is built
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.
Everything stays the same during late parsing, it's still put in the OwnerInfo of the hir.
The only difference for Late is here, which is different because the decorating code moved https://github.com/rust-lang/rust/pull/149662/files#diff-0f333b55aca600b036a38495f514656022cea3e3e0d41a3d4b3ce484c7279d34R161
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.
right, but I guess what I was asking first is that it's probably still hard to convert these lints to be opaque diagnostics since we have to hash them into owner nodes. We'll always have to keep an enum around like 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.
Oh right, yeah that will be annoying :c
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.
Some questions, but looks good overall. Indeed, especially the part where those lints can access the tcx. this seems very important to support in some way going forward
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
942e4b2 to
5648040
Compare
This comment has been minimized.
This comment has been minimized.
|
Oops I accidentally undid my rebase :p (Yes I should start using jj) |
5648040 to
8f59eb0
Compare
|
This PR was rebased onto a different main 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. |
|
@rustbot ready @jdonszelmann Here is one link with the two range diffs above combined, so you don't have to review me undoing and redoing my rebase :P Thanks to the new method |
|
@bors r+ rollup |
Rollup of 4 pull requests Successful merges: - #149563 (f*::min/max: fix comparing with libm and IEEE operations) - #149592 (`is_const_default_method` is completely handled by the `constness` query) - #149662 (Move attribute lints to `rustc_lint`) - #149684 (rustc-dev-guide subtree update) r? `@ghost` `@rustbot` modify labels: rollup
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`
This PR changes two things:
AttributeLintKindfrom theLintit is emitted in.cx.emit_lintnow takes both as an argument, rather than inferring theLintfrom theAttributeLintKind. This is nice because:AttributeLintKind::InvalidMacroExportArgumentsUSELESS_DEPRECATEDandUNUSED_ATTRIBUTESout of the lint emitting codeAttributeLintKindtorustc_lint_defs, and the decorating code torustc_lint. This is nice because:check-cfglints during attribute parsing rather than evaluation #149215IllFormedAttributeInputThis PR does not change observable output of the compiler, as can be seen by no uitests being affected.
r? @jdonszelmann