-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Port #[macro_export] to the new attribute parsing infrastructure #143857
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_attr_data_structures Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred in compiler/rustc_passes/src/check_attr.rs |
@@ -26,12 +22,15 @@ macro_rules! d { | |||
} | |||
|
|||
#[macro_export()] | |||
//~^ ERROR malformed `macro_export` attribute input |
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 is a breaking change! Malformed macro_export attributes have had a lint since 2023 (deny(invalid_macro_export_arguments)
). This PR makes this an error.
Furthermore, #[macro_export()]
has been accepted since 2023, and this PR makes that an error too.
As discussed in #142838 (comment), we can make breaking changes as long as we do a crater run. So this PR needs a crater run.
This comment has been minimized.
This comment has been minimized.
12474a6
to
bb6c5dd
Compare
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #140717) made this pull request unmergeable. Please resolve the merge conflicts. |
@Periodic1911 if you rebase I'll run a crater |
@rust-lang/lang this makes a long-standing warning an error with a crater run. Just wanted to notify you |
bb6c5dd
to
92071cc
Compare
92071cc
to
ac1f122
Compare
@bors try |
Port #[macro_export] to the new attribute parsing infrastructure Ports macro_export to the new attribute parsing infrastructure for #131229 (comment) r? `@oli-obk` cc `@JonathanBrouwer` `@jdonszelmann`
☀️ Try build successful - checks-actions |
@craterbot check |
@Periodic1911 FCP finished. if you rebase we can go for merge! :) |
ac1f122
to
f9b9221
Compare
@@ -4187,8 +4187,13 @@ declare_lint! { | |||
/// You can't have multiple arguments in a `#[macro_export(..)]`, or mention arguments other than `local_inner_macros`. | |||
/// | |||
pub INVALID_MACRO_EXPORT_ARGUMENTS, | |||
Warn, | |||
Deny, |
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 lint is now deny by default and FCW
@jdonszelmann rebased! And I made some changes to the parser error handling in accordance with the lang team's decision. Did I comply exactly with what they had in mind? |
@@ -0,0 +1,40 @@ | |||
Future incompatibility report: Future breakage diagnostic: |
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.
Although the invalid_macro_export_argument.rs
test passes (check-pass
) with #![allow(invalid_macro_export_arguments)]
, it also prints FCWs to stderr
This comment has been minimized.
This comment has been minimized.
f9b9221
to
943b384
Compare
|
||
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> { | ||
let suggestions = | ||
<Self as SingleAttributeParser<S>>::TEMPLATE.suggestions(false, "macro_export"); |
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.
might be nice to only compute this when emitting the lint since that's quite uncommon. You could reduce deduplication by putting this code in a closure or macro.
@@ -213,7 +213,8 @@ extern crate wloop; | |||
//~^ ERROR can't find crate for `wloop` [E0463] | |||
|
|||
#[macro_export = 18] | |||
//~^ ERROR malformed `macro_export` attribute input | |||
//~^ ERROR valid forms for the attribute are | |||
//~| WARN this was previously accepted by the 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 think this isn't very nice. It took me a while to see that this really was a problem, tried some things to make sure. But this was already an error, not a warning. Only the #[macro_export(meow)]
was a warning that will become an error. For this form, the compiler already gave an error and now we're getting an error, plus also a warning that it'll be an error in the future. I don't think that's right
☔ The latest upstream changes (presumably #144740) made this pull request unmergeable. Please resolve the merge conflicts. |
943b384
to
d62190a
Compare
|
||
fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> { | ||
let suggestions = | ||
|| <Self as SingleAttributeParser<S>>::TEMPLATE.suggestions(false, "macro_export"); |
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.
It's a closure now :)
//~^ ERROR malformed `macro_export` attribute input | ||
//~^ ERROR valid forms for the attribute are |
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.
You were right, this was always an error. I checked on stable, and the invalid_macro_export_arguments
lint does not handle this
d62190a
to
7a67892
Compare
Some changes occurred in compiler/rustc_hir/src/attrs |
I expect the tests introduced by this PR to fail |
r=me after that, @bors delegate+ |
✌️ @Periodic1911, you can now approve this pull request! If @jdonszelmann told you to " |
This comment has been minimized.
This comment has been minimized.
7a67892
to
90fad60
Compare
Ports macro_export to the new attribute parsing infrastructure for #131229 (comment)
r? @oli-obk
cc @JonathanBrouwer @jdonszelmann