Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,19 @@ impl<S: Stage> SingleAttributeParser<S> for MacroExportParser {
cx.adcx().warn_ill_formed_attribute_input(INVALID_MACRO_EXPORT_ARGUMENTS);
return None;
};
match l.meta_item().and_then(|i| i.path().word_sym()) {
Some(sym::local_inner_macros) => true,
_ => {
cx.adcx().warn_ill_formed_attribute_input(INVALID_MACRO_EXPORT_ARGUMENTS);
return None;
}
let Some(l) = l.meta_item() else {
cx.adcx().warn_ill_formed_attribute_input(INVALID_MACRO_EXPORT_ARGUMENTS);
return None;
};
if !l.path().word_is(sym::local_inner_macros) {
cx.adcx().warn_ill_formed_attribute_input(INVALID_MACRO_EXPORT_ARGUMENTS);
return None;
}
if let Err(_) = l.args().no_args() {
cx.adcx().warn_ill_formed_attribute_input(INVALID_MACRO_EXPORT_ARGUMENTS);
return None;
}
true
}
ArgParser::NameValue(nv) => {
cx.adcx().expected_list_or_no_args(nv.args_span());
Expand Down
20 changes: 20 additions & 0 deletions tests/ui/attributes/invalid_macro_export_argument.allow.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,23 @@ LL | #[macro_export("blah")]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>

Future breakage diagnostic:
warning: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]`
--> $DIR/invalid_macro_export_argument.rs:45:1
|
LL | #[macro_export(local_inner_macros = false)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>

Future breakage diagnostic:
warning: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]`
--> $DIR/invalid_macro_export_argument.rs:52:1
|
LL | #[macro_export(local_inner_macros(false))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>

50 changes: 49 additions & 1 deletion tests/ui/attributes/invalid_macro_export_argument.deny.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,25 @@ LL | #[macro_export("blah")]
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>

error: aborting due to 4 previous errors
error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]`
--> $DIR/invalid_macro_export_argument.rs:45:1
|
LL | #[macro_export(local_inner_macros = false)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>

error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]`
--> $DIR/invalid_macro_export_argument.rs:52:1
|
LL | #[macro_export(local_inner_macros(false))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>

error: aborting due to 6 previous errors

Future incompatibility report: Future breakage diagnostic:
error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]`
Expand Down Expand Up @@ -101,3 +119,33 @@ note: the lint level is defined here
LL | #![cfg_attr(deny, deny(invalid_macro_export_arguments))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Future breakage diagnostic:
error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]`
--> $DIR/invalid_macro_export_argument.rs:45:1
|
LL | #[macro_export(local_inner_macros = false)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
note: the lint level is defined here
--> $DIR/invalid_macro_export_argument.rs:4:24
|
LL | #![cfg_attr(deny, deny(invalid_macro_export_arguments))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Future breakage diagnostic:
error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]`
--> $DIR/invalid_macro_export_argument.rs:52:1
|
LL | #[macro_export(local_inner_macros(false))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
note: the lint level is defined here
--> $DIR/invalid_macro_export_argument.rs:4:24
|
LL | #![cfg_attr(deny, deny(invalid_macro_export_arguments))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

14 changes: 14 additions & 0 deletions tests/ui/attributes/invalid_macro_export_argument.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,18 @@ macro_rules! f {
() => ()
}

#[macro_export(local_inner_macros = false)]
//[deny]~^ ERROR valid forms for the attribute are
//[deny]~| WARN this was previously accepted
macro_rules! g {
() => ()
}

#[macro_export(local_inner_macros(false))]
//[deny]~^ ERROR valid forms for the attribute are
//[deny]~| WARN this was previously accepted
macro_rules! h {
() => ()
}

fn main() {}
Loading