-
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
Infrastructure for lints during attribute parsing, specifically duplicate usages of attributes #138164
base: master
Are you sure you want to change the base?
Infrastructure for lints during attribute parsing, specifically duplicate usages of attributes #138164
Conversation
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
This comment has been minimized.
This comment has been minimized.
(am aware of merge commits, was just an easy way to get those changes in before they're on master so we can run CI on this PR. will obviously remove once those changes are on master and this PR can be merged) |
This comment has been minimized.
This comment has been minimized.
b5f1130
to
9559a37
Compare
This comment has been minimized.
This comment has been minimized.
To do this we stuff them in the diagnostic context to be emitted after hir is constructed
9559a37
to
d529827
Compare
This comment has been minimized.
This comment has been minimized.
d529827
to
bfeed70
Compare
This comment has been minimized.
This comment has been minimized.
bfeed70
to
fc63551
Compare
/// *specifically* for lints emitted during ast lowering. | ||
/// At this point we can't get the lint level yet (doing so will cause really weird bugs). | ||
/// So, by stuffing lints in here they can be emitted when hir is built. | ||
hir_delayed_lints: Vec<HirDelayedLint>, |
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.
I don't think this is sound (wrt incremental) for lints. I think the right place would be to put them into https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/hir/struct.OwnerInfo.html and emit them from the late lint for each owner.
compiler/rustc_errors/src/lib.rs
Outdated
&'static Lint, | ||
HirId, | ||
Span, | ||
Box<dyn DynSend + for<'a, 'b> FnOnce(&'b mut Diag<'a, ()>) + 'static> |
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.
similarly this won't work, as you can't hash it for incremental
r? @oli-obk
Currently depends on #138060 and #138160 to merge. Those should be pretty trivial on their own. No need to review those commits in this PR.
This PR adds a new field to the diagnostics context to buffer lints which are generated during attribute parsing. They can't be emitted during attribute parsing because at that point there's no HIR yet, and early lints are already emitted.
This also adds the generic
S: Stage
to attribute parsers. Currently we don't emit any lints during early attribute parsing, but if we ever want to that logic will be different. That's because there we don't have hir ids yet, while at the same time still having access to node ids and early lints. Even though that logic isn't completely there in this PR (no worries, we don't use it), that's why the parameter is there.With this PR, we also add 2 associated consts to
SingleAttributeParser
. Those determine what logic should be applied when finding a duplicate attribute.