-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Port #[used]
to new attribute parsing infrastructure
#142818
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
|
Some changes occurred in compiler/rustc_attr_parsing Some changes occurred in compiler/rustc_codegen_ssa Some changes occurred in compiler/rustc_codegen_ssa/src/codegen_attrs.rs Some changes occurred in compiler/rustc_attr_data_structures Some changes occurred in compiler/rustc_passes/src/check_attr.rs |
| | ||
LL | #[used] | ||
| ^^^^^^^ | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! |
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 warning is new, but I think this is reasonable in this context.
Is adding this warning acceptable?
} | ||
|
||
if let Some(prev) = &group.result { | ||
cx.emit_lint( |
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 infra that makes this nicer merges with #142493 so let 's sequence this after that and rebase onto
44fa5f0
to
073e2c6
Compare
@@ -131,6 +131,17 @@ impl Deprecation { | |||
} | |||
} | |||
|
|||
/// There are three valid forms of the attribute: | |||
/// `#[used]`, which is semantically equivalent to `#[used(compiler)]` except that the latter is currently unstable. |
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.
#[used]
is only guaranteed to be an alias for #[used(compiler)]
, but in practice it is an alias for #[used(linker)]
nowadays.
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.
Hmmm indeed this is kinda weird, I did not notice that, thanks for letting me know!
#[used]
conflicts with #[used(linker)]
but not with #[used(compiler)]
, even though it is treated as an alias for #[used(linker)]
in codegen
Is this the desired behaviour or shall I change this? @bjorn3
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've pushed a change that makes #[used]
conflict with #[used(compiler)]
, and no longer conflict with #[used(linker)]
. I have no expertise in exactly what is good here but this seems like the best option.
(Also added a test for this since apparently there were none)
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 think either #[used]
, #[used(compiler)]
and #[used(linker)]
should all conflict with each other, or it should be a ratchet where #[used(linker)]
wins over #[used(compiler)]
.
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'll make them all conflict then, I think that's the safe option here. Will implement this later this weekend
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.
After some discussion here I'll implement the ratcheting
https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/attribute.20conflicts/with/525158490
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
073e2c6
to
468dd68
Compare
@rustbot author |
Reminder, once the PR becomes ready for a review, use |
☔ The latest upstream changes (presumably #142826) made this pull request unmergeable. Please resolve the merge conflicts. |
Ports
used
to the new attribute parsing infrastructure for #131229 (comment)r? @jdonszelmann