From dbb9d9170155ed072b56cec5c01019dcda553389 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Wed, 22 Oct 2025 15:42:40 +0200 Subject: [PATCH] Fix attribute style for `#[macro_export]` Signed-off-by: Jonathan Brouwer --- .../src/attributes/macro_attrs.rs | 8 +++----- .../invalid_macro_export_argument.allow.stderr | 8 ++++---- .../invalid_macro_export_argument.deny.stderr | 16 ++++++++-------- tests/ui/attributes/malformed-attrs.stderr | 2 +- 4 files changed, 16 insertions(+), 18 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs index 849141c34f7d9..99068eb05946a 100644 --- a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs @@ -1,4 +1,3 @@ -use rustc_ast::AttrStyle; use rustc_errors::DiagArgValue; use rustc_hir::attrs::MacroUseArgs; @@ -149,10 +148,9 @@ impl SingleAttributeParser for MacroExportParser { ]); fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option { - let suggestions = || { - >::TEMPLATE - .suggestions(AttrStyle::Inner, "macro_export") - }; + let attr_style = cx.attr_style; + let suggestions = + || >::TEMPLATE.suggestions(attr_style, "macro_export"); let local_inner_macros = match args { ArgParser::NoArgs => false, ArgParser::List(list) => { diff --git a/tests/ui/attributes/invalid_macro_export_argument.allow.stderr b/tests/ui/attributes/invalid_macro_export_argument.allow.stderr index 162b315b072a4..2db60a6897282 100644 --- a/tests/ui/attributes/invalid_macro_export_argument.allow.stderr +++ b/tests/ui/attributes/invalid_macro_export_argument.allow.stderr @@ -1,5 +1,5 @@ Future incompatibility report: Future breakage diagnostic: -warning: valid forms for the attribute are `#![macro_export(local_inner_macros)]` and `#![macro_export]` +warning: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` --> $DIR/invalid_macro_export_argument.rs:7:1 | LL | #[macro_export(hello, world)] @@ -9,7 +9,7 @@ LL | #[macro_export(hello, world)] = note: for more information, see issue #57571 Future breakage diagnostic: -warning: valid forms for the attribute are `#![macro_export(local_inner_macros)]` and `#![macro_export]` +warning: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` --> $DIR/invalid_macro_export_argument.rs:14:1 | LL | #[macro_export(not_local_inner_macros)] @@ -19,7 +19,7 @@ LL | #[macro_export(not_local_inner_macros)] = note: for more information, see issue #57571 Future breakage diagnostic: -warning: valid forms for the attribute are `#![macro_export(local_inner_macros)]` and `#![macro_export]` +warning: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` --> $DIR/invalid_macro_export_argument.rs:31:1 | LL | #[macro_export()] @@ -29,7 +29,7 @@ LL | #[macro_export()] = note: for more information, see issue #57571 Future breakage diagnostic: -warning: valid forms for the attribute are `#![macro_export(local_inner_macros)]` and `#![macro_export]` +warning: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` --> $DIR/invalid_macro_export_argument.rs:38:1 | LL | #[macro_export("blah")] diff --git a/tests/ui/attributes/invalid_macro_export_argument.deny.stderr b/tests/ui/attributes/invalid_macro_export_argument.deny.stderr index ad225ae187b11..fd50b824d0a26 100644 --- a/tests/ui/attributes/invalid_macro_export_argument.deny.stderr +++ b/tests/ui/attributes/invalid_macro_export_argument.deny.stderr @@ -1,4 +1,4 @@ -error: valid forms for the attribute are `#![macro_export(local_inner_macros)]` and `#![macro_export]` +error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` --> $DIR/invalid_macro_export_argument.rs:7:1 | LL | #[macro_export(hello, world)] @@ -12,7 +12,7 @@ note: the lint level is defined here LL | #![cfg_attr(deny, deny(invalid_macro_export_arguments))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: valid forms for the attribute are `#![macro_export(local_inner_macros)]` and `#![macro_export]` +error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` --> $DIR/invalid_macro_export_argument.rs:14:1 | LL | #[macro_export(not_local_inner_macros)] @@ -21,7 +21,7 @@ LL | #[macro_export(not_local_inner_macros)] = 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 -error: valid forms for the attribute are `#![macro_export(local_inner_macros)]` and `#![macro_export]` +error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` --> $DIR/invalid_macro_export_argument.rs:31:1 | LL | #[macro_export()] @@ -30,7 +30,7 @@ LL | #[macro_export()] = 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 -error: valid forms for the attribute are `#![macro_export(local_inner_macros)]` and `#![macro_export]` +error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` --> $DIR/invalid_macro_export_argument.rs:38:1 | LL | #[macro_export("blah")] @@ -42,7 +42,7 @@ LL | #[macro_export("blah")] error: aborting due to 4 previous errors Future incompatibility report: Future breakage diagnostic: -error: valid forms for the attribute are `#![macro_export(local_inner_macros)]` and `#![macro_export]` +error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` --> $DIR/invalid_macro_export_argument.rs:7:1 | LL | #[macro_export(hello, world)] @@ -57,7 +57,7 @@ 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]` +error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` --> $DIR/invalid_macro_export_argument.rs:14:1 | LL | #[macro_export(not_local_inner_macros)] @@ -72,7 +72,7 @@ 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]` +error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` --> $DIR/invalid_macro_export_argument.rs:31:1 | LL | #[macro_export()] @@ -87,7 +87,7 @@ 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]` +error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` --> $DIR/invalid_macro_export_argument.rs:38:1 | LL | #[macro_export("blah")] diff --git a/tests/ui/attributes/malformed-attrs.stderr b/tests/ui/attributes/malformed-attrs.stderr index c29bd0245bf04..5627cb452a815 100644 --- a/tests/ui/attributes/malformed-attrs.stderr +++ b/tests/ui/attributes/malformed-attrs.stderr @@ -701,7 +701,7 @@ error: valid forms for the attribute are `#[macro_use(name1, name2, ...)]` and ` LL | #[macro_use = 1] | ^^^^^^^^^^^^^^^^ -error: valid forms for the attribute are `#![macro_export(local_inner_macros)]` and `#![macro_export]` +error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` --> $DIR/malformed-attrs.rs:221:1 | LL | #[macro_export = 18]