From 6c7f841e9761628d45f3008a7963f427bcd0974d Mon Sep 17 00:00:00 2001 From: mejrs <59372212+mejrs@users.noreply.github.com> Date: Tue, 3 Nov 2026 19:08:41 +0100 Subject: [PATCH] Revert FCW on lint attributes on macro calls --- .../rustc_attr_parsing/src/diagnostics.rs | 2 +- .../rustc_attr_parsing/src/target_checking.rs | 6 +- tests/ui/attributes/attr-on-mac-call.stderr | 62 +++++++++---------- ...-gate-check-nested-macro-invocation.stderr | 2 +- tests/ui/lint/inert-attr-macro.rs | 1 - tests/ui/lint/inert-attr-macro.stderr | 7 +-- .../expect_lint_from_macro.rs | 1 - .../expect_lint_from_macro.stderr | 5 +- .../semicolon-in-expressions-from-macros.rs | 1 - ...emicolon-in-expressions-from-macros.stderr | 3 +- .../unused/unused_attributes-must_use.stderr | 2 +- tests/ui/pin-ergonomics/pin_v2-attr.stderr | 2 +- tests/ui/rust-2024/gen_in_macro_input.rs | 11 ++++ tests/ui/rust-2024/gen_in_macro_input.stderr | 28 +++++++++ 14 files changed, 85 insertions(+), 48 deletions(-) create mode 100644 tests/ui/rust-2024/gen_in_macro_input.rs create mode 100644 tests/ui/rust-2024/gen_in_macro_input.stderr diff --git a/compiler/rustc_attr_parsing/src/diagnostics.rs b/compiler/rustc_attr_parsing/src/diagnostics.rs index 127b0e4f14de8..953abc631b95a 100644 --- a/compiler/rustc_attr_parsing/src/diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/diagnostics.rs @@ -1451,7 +1451,7 @@ pub(crate) struct InvalidTarget { )] pub previously_accepted: bool, #[note( - "placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute" + "attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion" )] pub on_macro_call: bool, } diff --git a/compiler/rustc_attr_parsing/src/target_checking.rs b/compiler/rustc_attr_parsing/src/target_checking.rs index 58ba6d4cc717b..89d80b8c82ba7 100644 --- a/compiler/rustc_attr_parsing/src/target_checking.rs +++ b/compiler/rustc_attr_parsing/src/target_checking.rs @@ -129,6 +129,8 @@ impl<'sess> AttributeParser<'sess> { let allowed_targets = allowed_targets.allowed_targets(); let (applied, only) = allowed_targets_applied(allowed_targets, cx.target, cx.features); let is_diagnostic_attr = cx.attr_path.segments[0] == sym::diagnostic; + let is_lint_check_attr = [sym::allow, sym::expect, sym::deny, sym::warn, sym::forbid] + .contains(&cx.attr_path.segments[0]); let span = if attribute_args.is_empty() { // Example: for the attribute `#[inline]`, name+attribute_args gives "inline", @@ -159,7 +161,9 @@ impl<'sess> AttributeParser<'sess> { applied: DiagArgValue::StrListSepByAnd(applied.into_iter().map(Cow::Owned).collect()), attribute_args: attribute_args.to_string(), help: Self::target_checking_help(attribute_args, cx), - previously_accepted: matches!(result, AllowedResult::Warn) && !is_diagnostic_attr, + previously_accepted: matches!(result, AllowedResult::Warn) + && !is_diagnostic_attr + && !is_lint_check_attr, on_macro_call: matches!(cx.target, Target::MacroCall), }; diff --git a/tests/ui/attributes/attr-on-mac-call.stderr b/tests/ui/attributes/attr-on-mac-call.stderr index 3f10e5720e9ee..0d6fe64db735f 100644 --- a/tests/ui/attributes/attr-on-mac-call.stderr +++ b/tests/ui/attributes/attr-on-mac-call.stderr @@ -7,7 +7,7 @@ LL | LL | unreachable!(); | = help: the `sanitize` attribute can be applied to crates, functions, impl blocks, modules, and statics - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion error[E0658]: SIMD types are experimental and possibly buggy --> $DIR/attr-on-mac-call.rs:106:12 @@ -28,7 +28,7 @@ LL | #[repr(simd)] LL | unreachable!(); | = help: the `repr(simd)` attribute can only be applied to structs - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![register_tool]` --> $DIR/attr-on-mac-call.rs:110:5 @@ -85,7 +85,7 @@ LL | unreachable!(); | = help: the `export_name` attribute can be applied to functions and statics = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion note: the lint level is defined here --> $DIR/attr-on-mac-call.rs:3:9 | @@ -102,7 +102,7 @@ LL | unreachable!(); | = help: the `naked` attribute can only be applied to functions = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `track_caller` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:14:7 @@ -114,7 +114,7 @@ LL | unreachable!(); | = help: the `track_caller` attribute can only be applied to functions = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `used` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:17:7 @@ -126,7 +126,7 @@ LL | unreachable!(); | = help: the `used` attribute can only be applied to statics = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `target_feature` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:20:7 @@ -138,7 +138,7 @@ LL | unreachable!(); | = help: the `target_feature` attribute can only be applied to functions = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `deprecated` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:23:7 @@ -150,7 +150,7 @@ LL | unreachable!(); | = help: the `deprecated` attribute can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, and use statements = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `inline` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:26:7 @@ -162,7 +162,7 @@ LL | unreachable!(); | = help: the `inline` attribute can only be applied to functions = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `link_name` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:29:7 @@ -174,7 +174,7 @@ LL | unreachable!(); | = help: the `link_name` attribute can be applied to foreign functions and foreign statics = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `link_section` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:32:7 @@ -186,7 +186,7 @@ LL | unreachable!(); | = help: the `link_section` attribute can be applied to functions and statics = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `link_ordinal` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:35:7 @@ -198,7 +198,7 @@ LL | unreachable!(); | = help: the `link_ordinal` attribute can be applied to foreign functions and foreign statics = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `non_exhaustive` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:38:7 @@ -210,7 +210,7 @@ LL | unreachable!(); | = help: the `non_exhaustive` attribute can be applied to data types and enum variants = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `proc_macro` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:41:7 @@ -222,7 +222,7 @@ LL | unreachable!(); | = help: the `proc_macro` attribute can only be applied to functions = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `cold` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:44:7 @@ -234,7 +234,7 @@ LL | unreachable!(); | = help: the `cold` attribute can only be applied to functions = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `no_mangle` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:47:7 @@ -246,7 +246,7 @@ LL | unreachable!(); | = help: the `no_mangle` attribute can be applied to functions and statics = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `deprecated` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:50:7 @@ -258,7 +258,7 @@ LL | unreachable!(); | = help: the `deprecated` attribute can be applied to associated consts, associated types, constants, crates, data types, enum variants, foreign statics, functions, inherent impl blocks, macro defs, modules, statics, struct fields, traits, type aliases, and use statements = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `automatically_derived` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:53:7 @@ -270,7 +270,7 @@ LL | unreachable!(); | = help: the `automatically_derived` attribute can only be applied to trait impl blocks = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `macro_use` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:56:7 @@ -282,7 +282,7 @@ LL | unreachable!(); | = help: the `macro_use` attribute can be applied to extern crates and modules = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `must_use` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:59:7 @@ -294,7 +294,7 @@ LL | unreachable!(); | = help: the `must_use` attribute can be applied to data types, functions, and traits = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `no_implicit_prelude` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:62:7 @@ -306,7 +306,7 @@ LL | unreachable!(); | = help: the `no_implicit_prelude` attribute can be applied to crates and modules = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `path` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:65:7 @@ -318,7 +318,7 @@ LL | unreachable!(); | = help: the `path` attribute can only be applied to modules = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `ignore` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:68:7 @@ -330,7 +330,7 @@ LL | unreachable!(); | = help: the `ignore` attribute can only be applied to functions = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `should_panic` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:71:7 @@ -342,7 +342,7 @@ LL | unreachable!(); | = help: the `should_panic` attribute can only be applied to functions = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `link_name` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:74:7 @@ -354,7 +354,7 @@ LL | unreachable!(); | = help: the `link_name` attribute can be applied to foreign functions and foreign statics = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `repr()` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:81:7 @@ -366,7 +366,7 @@ LL | unreachable!(); | = help: the `repr()` attribute can only be applied to data types = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: unused attribute --> $DIR/attr-on-mac-call.rs:81:5 @@ -386,7 +386,7 @@ LL | unreachable!(); | = help: the `repr(u8)` attribute can only be applied to enums = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `repr(align(...))` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:90:7 @@ -398,7 +398,7 @@ LL | unreachable!(); | = help: the `repr(align(...))` attribute can only be applied to data types = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `repr(packed)` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:94:7 @@ -410,7 +410,7 @@ LL | unreachable!(); | = help: the `repr(packed)` attribute can only be applied to data types = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `repr(C)` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:98:7 @@ -422,7 +422,7 @@ LL | unreachable!(); | = help: the `repr(C)` attribute can only be applied to data types = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `repr(Rust)` attribute cannot be used on macro calls --> $DIR/attr-on-mac-call.rs:102:7 @@ -434,7 +434,7 @@ LL | unreachable!(); | = help: the `repr(Rust)` attribute can only be applied to data types = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion error: aborting due to 8 previous errors; 30 warnings emitted diff --git a/tests/ui/feature-gates/feature-gate-check-nested-macro-invocation.stderr b/tests/ui/feature-gates/feature-gate-check-nested-macro-invocation.stderr index 84effb42564cb..3c4999a2e6072 100644 --- a/tests/ui/feature-gates/feature-gate-check-nested-macro-invocation.stderr +++ b/tests/ui/feature-gates/feature-gate-check-nested-macro-invocation.stderr @@ -26,7 +26,7 @@ LL | foo!(); | ------ in this macro invocation | = help: the `allow_internal_unstable` attribute can be applied to functions and macro defs - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion error: aborting due to 2 previous errors diff --git a/tests/ui/lint/inert-attr-macro.rs b/tests/ui/lint/inert-attr-macro.rs index deb8995f36008..b7ea5ba889085 100644 --- a/tests/ui/lint/inert-attr-macro.rs +++ b/tests/ui/lint/inert-attr-macro.rs @@ -16,7 +16,6 @@ fn main() { //~^ WARN the `allow` attribute cannot be used on macro calls //~| WARN previously accepted //~| WARN the `inline` attribute cannot be used on macro calls - //~| WARN previously accepted // This does work, since the attribute is on a parent // of the macro invocation. diff --git a/tests/ui/lint/inert-attr-macro.stderr b/tests/ui/lint/inert-attr-macro.stderr index a13d17bd4b0c2..1b7b5bdeef7fd 100644 --- a/tests/ui/lint/inert-attr-macro.stderr +++ b/tests/ui/lint/inert-attr-macro.stderr @@ -6,7 +6,7 @@ LL | #[inline] foo!(); | = help: the `inline` attribute can only be applied to functions = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion note: the lint level is defined here --> $DIR/inert-attr-macro.rs:3:9 | @@ -21,8 +21,7 @@ LL | #[allow(warnings)] #[inline] foo!(); | ^^^^^ | = help: the `allow` attribute can be applied to associated consts, associated types, break expressions, const parameters, constants, crates, data types, enum variants, extern crates, for loops, foreign modules, foreign statics, function params, functions, global asms, impl blocks, lifetime parameters, loops, macro defs, match arms, modules, pattern fields, statics, struct fields, trait aliases, traits, type aliases, type parameters, use statements, and while loops - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: the `inline` attribute cannot be used on macro calls --> $DIR/inert-attr-macro.rs:15:26 @@ -32,7 +31,7 @@ LL | #[allow(warnings)] #[inline] foo!(); | = help: the `inline` attribute can only be applied to functions = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion warning: 3 warnings emitted diff --git a/tests/ui/lint/rfc-2383-lint-reason/expect_lint_from_macro.rs b/tests/ui/lint/rfc-2383-lint-reason/expect_lint_from_macro.rs index 52aa8c0980f7b..4daa6fe85d481 100644 --- a/tests/ui/lint/rfc-2383-lint-reason/expect_lint_from_macro.rs +++ b/tests/ui/lint/rfc-2383-lint-reason/expect_lint_from_macro.rs @@ -25,7 +25,6 @@ pub fn check_expect_on_macro() { // This should be fulfilled by the macro #[expect(unused_variables)] //~^ WARN the `expect` attribute cannot be used on macro call - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! trigger_unused_variables_macro!(); // FIXME: Lint attributes currently don't work directly on macros, and diff --git a/tests/ui/lint/rfc-2383-lint-reason/expect_lint_from_macro.stderr b/tests/ui/lint/rfc-2383-lint-reason/expect_lint_from_macro.stderr index b527312aca42b..71f14b88ca75a 100644 --- a/tests/ui/lint/rfc-2383-lint-reason/expect_lint_from_macro.stderr +++ b/tests/ui/lint/rfc-2383-lint-reason/expect_lint_from_macro.stderr @@ -3,12 +3,11 @@ warning: the `expect` attribute cannot be used on macro calls | LL | #[expect(unused_variables)] | ^^^^^^ -... +LL | LL | trigger_unused_variables_macro!(); | = help: the `expect` attribute can be applied to associated consts, associated types, break expressions, const parameters, constants, crates, data types, enum variants, extern crates, for loops, foreign modules, foreign statics, function params, functions, global asms, impl blocks, lifetime parameters, loops, macro defs, match arms, modules, pattern fields, statics, struct fields, trait aliases, traits, type aliases, type parameters, use statements, and while loops - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion = note: requested on the command line with `-W unused-attributes` warning: unused variable: `x` diff --git a/tests/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.rs b/tests/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.rs index d3c4a205c4b1f..48433f421ba60 100644 --- a/tests/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.rs +++ b/tests/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.rs @@ -49,5 +49,4 @@ fn main() { // when we expand the macro let _ = #[allow(semicolon_in_expressions_from_macros)] foo!(allow_does_not_work); //~^ WARN the `allow` attribute cannot be used on macro calls - //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } diff --git a/tests/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.stderr b/tests/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.stderr index fd2af817ea775..82e62e56b96cb 100644 --- a/tests/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.stderr +++ b/tests/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.stderr @@ -40,8 +40,7 @@ LL | let _ = #[allow(semicolon_in_expressions_from_macros)] foo!(allow_does_ | ^^^^^ | = help: the `allow` attribute can be applied to associated consts, associated types, break expressions, const parameters, constants, crates, data types, enum variants, expressions, extern crates, for loops, foreign modules, foreign statics, function params, functions, global asms, impl blocks, lifetime parameters, loops, macro defs, match arms, modules, pattern fields, statements, statics, struct fields, trait aliases, traits, type aliases, type parameters, use statements, and while loops - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion = note: requested on the command line with `-W unused-attributes` warning: trailing semicolon in macro used in expression position diff --git a/tests/ui/lint/unused/unused_attributes-must_use.stderr b/tests/ui/lint/unused/unused_attributes-must_use.stderr index d0fecf48774c0..39c0609acc656 100644 --- a/tests/ui/lint/unused/unused_attributes-must_use.stderr +++ b/tests/ui/lint/unused/unused_attributes-must_use.stderr @@ -8,7 +8,7 @@ LL | global_asm!(""); | = help: the `must_use` attribute can be applied to data types, functions, and traits = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion note: the lint level is defined here --> $DIR/unused_attributes-must_use.rs:4:9 | diff --git a/tests/ui/pin-ergonomics/pin_v2-attr.stderr b/tests/ui/pin-ergonomics/pin_v2-attr.stderr index 3550ad8212c15..c1c3a59cfe602 100644 --- a/tests/ui/pin-ergonomics/pin_v2-attr.stderr +++ b/tests/ui/pin-ergonomics/pin_v2-attr.stderr @@ -6,7 +6,7 @@ LL | #[pin_v2] LL | macro_def!(); | = help: the `pin_v2` attribute can only be applied to data types - = note: placing this attribute on a macro invocation does nothing even if the macro expands to what would be a valid target for the attribute + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion error: the `pin_v2` attribute cannot be used on crates --> $DIR/pin_v2-attr.rs:10:4 diff --git a/tests/ui/rust-2024/gen_in_macro_input.rs b/tests/ui/rust-2024/gen_in_macro_input.rs new file mode 100644 index 0000000000000..2792f0e343159 --- /dev/null +++ b/tests/ui/rust-2024/gen_in_macro_input.rs @@ -0,0 +1,11 @@ +macro_rules! wat { + ($($tt:tt)*) => {} +} + +fn main(){ + #[deny(keyword_idents_2024)] + //~^ WARN the `deny` attribute cannot be used on macro calls + wat!(gen); + //~^ ERROR `gen` is a keyword in the 2024 edition + //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! +} diff --git a/tests/ui/rust-2024/gen_in_macro_input.stderr b/tests/ui/rust-2024/gen_in_macro_input.stderr new file mode 100644 index 0000000000000..f757861a09828 --- /dev/null +++ b/tests/ui/rust-2024/gen_in_macro_input.stderr @@ -0,0 +1,28 @@ +error: `gen` is a keyword in the 2024 edition + --> $DIR/gen_in_macro_input.rs:8:10 + | +LL | wat!(gen); + | ^^^ help: you can use a raw identifier to stay compatible: `r#gen` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! + = note: for more information, see +note: the lint level is defined here + --> $DIR/gen_in_macro_input.rs:6:12 + | +LL | #[deny(keyword_idents_2024)] + | ^^^^^^^^^^^^^^^^^^^ + +warning: the `deny` attribute cannot be used on macro calls + --> $DIR/gen_in_macro_input.rs:6:7 + | +LL | #[deny(keyword_idents_2024)] + | ^^^^ +LL | +LL | wat!(gen); + | + = help: the `deny` attribute can be applied to associated consts, associated types, break expressions, const parameters, constants, crates, data types, enum variants, extern crates, for loops, foreign modules, foreign statics, function params, functions, global asms, impl blocks, lifetime parameters, loops, macro defs, match arms, modules, pattern fields, statics, struct fields, trait aliases, traits, type aliases, type parameters, use statements, and while loops + = note: attributes on a macro invocation apply to the invocation itself and are not forwarded to its expansion + = note: requested on the command line with `-W unused-attributes` + +error: aborting due to 1 previous error; 1 warning emitted +