-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Rewrite inline
attribute parser to use new infrastructure and improve diagnostics for all parsed attributes
#138165
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: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@@ -584,7 +546,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs { | |||
return OptimizeAttr::Default; | |||
}; | |||
|
|||
inline_span = Some(attr.span()); |
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.
This fixes #137950
e6dad01
to
2a707bf
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #138302) made this pull request unmergeable. Please resolve the merge conflicts. |
b7dda57
to
88a713a
Compare
This comment has been minimized.
This comment has been minimized.
@rustbot review |
This comment has been minimized.
This comment has been minimized.
ah shit, broke clippy 😭 |
Infrastructure for lints during attribute parsing, specifically duplicate usages of attributes r? `@oli-obk` This PR adds a new field to OwnerInfo to buffer lints which are generated during attribute parsing and ast lowering in general. They can't be emitted at this stage 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. This PR was getting pretty large, so the first code using this logic is in #138165. This code is all new things that weren't possible before so it also doesn't break any behaviour. However, some of it will be dead code right now. I recommend reviewing both before merging, though in some sense that doubles the size of the review again, and the other PR might be more controversial. Let me know how you want to do this `@oli-obk`
Some changes occurred in compiler/rustc_codegen_ssa Some changes occurred in src/tools/clippy cc @rust-lang/clippy These commits modify Please ensure that if you've changed the output:
cc @aDotInTheVoid, @obi1kenobi Some changes occurred in diagnostic error codes These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
☔ The latest upstream changes (presumably #142432) made this pull request unmergeable. Please resolve the merge conflicts. |
//@ is "$.index[?(@.name=='just_inline')].attrs" '["#[inline]"]' | ||
//@ is "$.index[?(@.name=='just_inline')].attrs" '["#[attr = Inline(Hint)]"]' |
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.
So to understand https://github.com/rust-lang/rust/pull/138165/files?diff=unified&w=1#r2143839007 right, we could represent this attrs
list in json not as a list of strings, but as a list of either strings (unstable format, only print or view it) or json maps that contain all the information in a structured way and doesn't require consumers to re-parse it.
If we change the map representation, we bump the format. If we change the string representation, we do not.
Either way, we either break csc or we bump the version so csc can gate its parser on it. The only question we're asking right now is whether we bump the version twice (once now, and once for when we move to json maps).
is that about right @aDotInTheVoid @obi1kenobi ?
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.
From a c-s-c perspective I don't have a strong opinion, we don't check #[inline]
and the change shouldn't break us.
From a rustdoc JSON format perspective, I think it's kinder to other rustdoc JSON users if we bump.
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.
@oli-obk if we bump, we should also decide if we bump from now on on every reworked attribute parser.
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.
@obi1kenobi and I talked synchronously for a bit, and for now we both think it's best to do version bumps for a bit until we can implement a more structured approach. Pushed a commit that does the bump.
This comment has been minimized.
This comment has been minimized.
rustdoc-json-types is a public (although nightly-only) API. If possible, consider changing |
I think that addresses all the review comments by others @oli-obk :) |
r? @oli-obk
This PR:
Builds on top of #138164
Closes #137950