From 43d58493577de18064ad246789a58468d4261ba6 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Fri, 10 Apr 2026 16:23:20 +0200 Subject: [PATCH 01/14] Remove `Clone` from parser types --- compiler/rustc_attr_parsing/src/parser.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/parser.rs b/compiler/rustc_attr_parsing/src/parser.rs index ce2367006128d..f293a12f910d3 100644 --- a/compiler/rustc_attr_parsing/src/parser.rs +++ b/compiler/rustc_attr_parsing/src/parser.rs @@ -5,7 +5,7 @@ use std::borrow::Borrow; use std::fmt::{Debug, Display}; - +use std::sync::atomic::AtomicBool; use rustc_ast::token::{self, Delimiter, MetaVarKind}; use rustc_ast::tokenstream::TokenStream; use rustc_ast::{ @@ -87,7 +87,7 @@ impl> Display for PathParser

{ } } -#[derive(Clone, Debug)] +#[derive(Debug)] #[must_use] pub enum ArgParser { NoArgs, @@ -215,7 +215,7 @@ impl ArgParser { /// This enum represents that. /// /// Choose which one you want using the provided methods. -#[derive(Debug, Clone)] +#[derive(Debug)] pub enum MetaItemOrLitParser { MetaItemParser(MetaItemParser), Lit(MetaItemLit), @@ -269,7 +269,6 @@ impl MetaItemOrLitParser { /// `= value` part /// /// The syntax of MetaItems can be found at -#[derive(Clone)] pub struct MetaItemParser { path: OwnedPathParser, args: ArgParser, @@ -656,7 +655,7 @@ impl<'a, 'sess> MetaItemListParserContext<'a, 'sess> { } } -#[derive(Debug, Clone)] +#[derive(Debug)] pub struct MetaItemListParser { sub_parsers: ThinVec, pub span: Span, From e8933a850d89e6e134dcc7a22272cdc6684f252c Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Fri, 10 Apr 2026 16:27:18 +0200 Subject: [PATCH 02/14] Add debug assertion to check usage of arguments of `MetaItemParser` --- .../src/attributes/diagnostic/on_const.rs | 1 + .../src/attributes/diagnostic/on_move.rs | 1 + .../src/attributes/diagnostic/on_unknown.rs | 1 + .../rustc_attr_parsing/src/attributes/doc.rs | 2 + .../src/attributes/dummy.rs | 3 +- compiler/rustc_attr_parsing/src/context.rs | 9 +++ compiler/rustc_attr_parsing/src/interface.rs | 39 +++++++++++- compiler/rustc_attr_parsing/src/parser.rs | 61 ++++++++++++++++++- 8 files changed, 113 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_const.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_const.rs index e6c66b597ce08..b445f23f2202b 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_const.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_const.rs @@ -18,6 +18,7 @@ impl AttributeParser for OnConstParser { |this, cx, args| { if !cx.features().diagnostic_on_const() { // `UnknownDiagnosticAttribute` is emitted in rustc_resolve/macros.rs + args.ignore_args(); return; } diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_move.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_move.rs index d4ef92fc9a548..a104f68292fcb 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_move.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_move.rs @@ -21,6 +21,7 @@ impl OnMoveParser { fn parse<'sess>(&mut self, cx: &mut AcceptContext<'_, 'sess>, args: &ArgParser, mode: Mode) { if !cx.features().diagnostic_on_move() { // `UnknownDiagnosticAttribute` is emitted in rustc_resolve/macros.rs + args.ignore_args(); return; } diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unknown.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unknown.rs index 0a9aaaaa1893e..e70a54302fd2f 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unknown.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unknown.rs @@ -19,6 +19,7 @@ impl OnUnknownParser { && !features.diagnostic_on_unknown() { // `UnknownDiagnosticAttribute` is emitted in rustc_resolve/macros.rs + args.ignore_args(); return; } let span = cx.attr_span; diff --git a/compiler/rustc_attr_parsing/src/attributes/doc.rs b/compiler/rustc_attr_parsing/src/attributes/doc.rs index 74fee3df0c524..d32a7a1de9491 100644 --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs @@ -205,6 +205,8 @@ impl DocParser { // FIXME: convert list into a Vec of `AttributeKind` because current code is awful. for attr in list.mixed() { + // Arguments of `attr` are checked via the span, so can be safely ignored + attr.ignore_args(); self.attribute.test_attrs.push(attr.span()); } } diff --git a/compiler/rustc_attr_parsing/src/attributes/dummy.rs b/compiler/rustc_attr_parsing/src/attributes/dummy.rs index 622f7e1ceba49..ebf72722c9012 100644 --- a/compiler/rustc_attr_parsing/src/attributes/dummy.rs +++ b/compiler/rustc_attr_parsing/src/attributes/dummy.rs @@ -14,7 +14,8 @@ impl SingleAttributeParser for RustcDummyParser { const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS); const TEMPLATE: AttributeTemplate = template!(Word); // Anything, really - fn convert(_: &mut AcceptContext<'_, '_>, _: &ArgParser) -> Option { + fn convert(_: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option { + args.ignore_args(); Some(AttributeKind::RustcDummy) } } diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 85fff6684ecd1..11ef1d6daa7ba 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -4,6 +4,8 @@ use std::collections::btree_map::Entry; use std::mem; use std::ops::{Deref, DerefMut}; use std::sync::LazyLock; +#[cfg(debug_assertions)] +use std::sync::atomic::{AtomicBool, Ordering}; use rustc_ast::{AttrStyle, MetaItemLit}; use rustc_data_structures::sync::{DynSend, DynSync}; @@ -403,6 +405,8 @@ impl<'f, 'sess: 'f> SharedContext<'f, 'sess> { kind: EmitAttribute, span: impl Into, ) { + #[cfg(debug_assertions)] + self.has_lint_been_emitted.store(true, Ordering::Relaxed); if !matches!( self.should_emit, ShouldEmit::ErrorsAndLints { .. } | ShouldEmit::EarlyFatal { also_emit_lints: true } @@ -556,6 +560,11 @@ pub struct SharedContext<'p, 'sess> { pub(crate) target: rustc_hir::Target, pub(crate) emit_lint: &'p mut dyn FnMut(LintId, MultiSpan, EmitAttribute), + + /// This atomic bool keeps track of whether any lint has been emitted. + /// This is used for the arguments-used check. + #[cfg(debug_assertions)] + pub(crate) has_lint_been_emitted: AtomicBool, } /// Context given to every attribute parser during finalization. diff --git a/compiler/rustc_attr_parsing/src/interface.rs b/compiler/rustc_attr_parsing/src/interface.rs index f4506d8d5fedc..5eb1fd617d84b 100644 --- a/compiler/rustc_attr_parsing/src/interface.rs +++ b/compiler/rustc_attr_parsing/src/interface.rs @@ -1,4 +1,6 @@ use std::convert::identity; +#[cfg(debug_assertions)] +use std::sync::atomic::{AtomicBool, Ordering}; use rustc_ast as ast; use rustc_ast::token::DocFragmentKind; @@ -221,6 +223,8 @@ impl<'sess> AttributeParser<'sess> { target_span, target, emit_lint: &mut emit_lint, + #[cfg(debug_assertions)] + has_lint_been_emitted: AtomicBool::new(false), }, attr_span, inner_span, @@ -391,6 +395,8 @@ impl<'sess> AttributeParser<'sess> { target_span, target, emit_lint: &mut emit_lint, + #[cfg(debug_assertions)] + has_lint_been_emitted: AtomicBool::new(false), }, attr_span, inner_span: lower_span(n.item.span()), @@ -403,6 +409,10 @@ impl<'sess> AttributeParser<'sess> { (accept.accept_fn)(&mut cx, &args); finalizers.push(accept.finalizer); + #[cfg(debug_assertions)] + if !cx.shared.has_lint_been_emitted.load(Ordering::Relaxed) { + cx.shared.cx.check_args_used(&attr, &args) + } if !matches!(cx.should_emit, ShouldEmit::Nothing) { Self::check_target(&accept.allowed_targets, target, &mut cx); } @@ -450,7 +460,14 @@ impl<'sess> AttributeParser<'sess> { early_parsed_state.finalize_early_parsed_attributes(&mut attributes); for f in &finalizers { if let Some(attr) = f(&mut FinalizeContext { - shared: SharedContext { cx: self, target_span, target, emit_lint: &mut emit_lint }, + shared: SharedContext { + cx: self, + target_span, + target, + emit_lint: &mut emit_lint, + #[cfg(debug_assertions)] + has_lint_been_emitted: AtomicBool::new(false), + }, all_attrs: &attr_paths, }) { attributes.push(Attribute::Parsed(attr)); @@ -464,6 +481,26 @@ impl<'sess> AttributeParser<'sess> { attributes } + #[cfg(debug_assertions)] + /// Checks whether all `ArgParser`s were observed by an attribute parser at least once + /// This check exists because otherwise it is too easy to accidentally ignore the arguments of an attribute + fn check_args_used(&self, attr: &ast::Attribute, args: &ArgParser) { + if let ArgParser::List(items) = args { + for item in items.mixed() { + if let crate::parser::MetaItemOrLitParser::MetaItemParser(item) = item { + if !item.are_args_checked() { + self.dcx().span_delayed_bug( + item.span(), + "attribute args were not properly checked", + ); + return; + } + self.check_args_used(attr, item.args()); + } + } + } + } + /// Returns whether there is a parser for an attribute with this name pub fn is_parsed_attribute(path: &[Symbol]) -> bool { /// The list of attributes that are parsed attributes, diff --git a/compiler/rustc_attr_parsing/src/parser.rs b/compiler/rustc_attr_parsing/src/parser.rs index f293a12f910d3..3da0d98cddfa7 100644 --- a/compiler/rustc_attr_parsing/src/parser.rs +++ b/compiler/rustc_attr_parsing/src/parser.rs @@ -5,7 +5,9 @@ use std::borrow::Borrow; use std::fmt::{Debug, Display}; -use std::sync::atomic::AtomicBool; +#[cfg(debug_assertions)] +use std::sync::atomic::{AtomicBool, Ordering}; + use rustc_ast::token::{self, Delimiter, MetaVarKind}; use rustc_ast::tokenstream::TokenStream; use rustc_ast::{ @@ -209,6 +211,19 @@ impl ArgParser { Self::NameValue(args) => Err(args.args_span()), } } + + /// Explicitly ignore the arguments, disarming the arguments-used check + pub fn ignore_args(&self) { + #[cfg(debug_assertions)] + match self { + ArgParser::List(list) => { + for item in list.mixed() { + item.ignore_args(); + } + } + _ => {} + } + } } /// Inside lists, values could be either literals, or more deeply nested meta items. @@ -253,6 +268,26 @@ impl MetaItemOrLitParser { MetaItemOrLitParser::Lit(_) => None, } } + + /// Returns some if this `MetaItemOrLitParser` is a `MetaItem` with no arguments + pub fn meta_item_no_args(&self) -> Option<&MetaItemParser> { + let meta_item = self.meta_item()?; + match meta_item.args().no_args() { + Ok(_) => Some(meta_item), + Err(_) => None, + } + } + + /// Explicitly ignore the arguments, disarming the arguments-used check + pub fn ignore_args(&self) { + #[cfg(debug_assertions)] + match self { + MetaItemOrLitParser::MetaItemParser(meta_item) => { + meta_item.ignore_args(); + } + MetaItemOrLitParser::Lit(_) => {} + } + } } // FIXME(scrabsha): once #155696 is merged, update this and mention the higher-level APIs. @@ -272,6 +307,11 @@ impl MetaItemOrLitParser { pub struct MetaItemParser { path: OwnedPathParser, args: ArgParser, + + /// Whether the `args` of this meta item have been looked at. + /// This is tracked because if the arguments of a `MetaItemParser` are ignored, this is probably a mistake + #[cfg(debug_assertions)] + args_checked: AtomicBool, } impl Debug for MetaItemParser { @@ -308,6 +348,8 @@ impl MetaItemParser { /// Gets just the args parser, without caring about the path. pub fn args(&self) -> &ArgParser { + #[cfg(debug_assertions)] + self.args_checked.store(true, Ordering::Relaxed); &self.args } @@ -320,6 +362,16 @@ impl MetaItemParser { pub fn word_is(&self, sym: Symbol) -> Option<&ArgParser> { self.path().word_is(sym).then(|| self.args()) } + + /// Explicitly ignore the arguments, disarming the arguments-used check + pub fn ignore_args(&self) { + self.args().ignore_args(); + } + + #[cfg(debug_assertions)] + pub fn are_args_checked(&self) -> bool { + self.args_checked.load(Ordering::Relaxed) + } } #[derive(Clone)] @@ -530,7 +582,12 @@ impl<'a, 'sess> MetaItemListParserContext<'a, 'sess> { ArgParser::NoArgs }; - Ok(MetaItemParser { path: PathParser(path), args }) + Ok(MetaItemParser { + path: PathParser(path), + args, + #[cfg(debug_assertions)] + args_checked: AtomicBool::new(false), + }) } fn parse_meta_item_inner(&mut self) -> PResult<'sess, MetaItemOrLitParser> { From 06d8f470248c03ce9d410a39dc6af74162b9063c Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Sun, 12 Apr 2026 12:33:49 +0200 Subject: [PATCH 03/14] Properly check arguments of `#[inline]` --- .../src/attributes/inline.rs | 2 +- tests/ui/attributes/args-checked.rs | 7 +++ tests/ui/attributes/args-checked.stderr | 45 +++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tests/ui/attributes/args-checked.rs create mode 100644 tests/ui/attributes/args-checked.stderr diff --git a/compiler/rustc_attr_parsing/src/attributes/inline.rs b/compiler/rustc_attr_parsing/src/attributes/inline.rs index a02f0a89cc042..1df3008ff3e50 100644 --- a/compiler/rustc_attr_parsing/src/attributes/inline.rs +++ b/compiler/rustc_attr_parsing/src/attributes/inline.rs @@ -39,7 +39,7 @@ impl SingleAttributeParser for InlineParser { ArgParser::List(list) => { let l = cx.expect_single(list)?; - match l.meta_item().and_then(|i| i.path().word_sym()) { + match l.meta_item_no_args().and_then(|i| i.path().word_sym()) { Some(sym::always) => { Some(AttributeKind::Inline(InlineAttr::Always, cx.attr_span)) } diff --git a/tests/ui/attributes/args-checked.rs b/tests/ui/attributes/args-checked.rs new file mode 100644 index 0000000000000..8a512a7f2a849 --- /dev/null +++ b/tests/ui/attributes/args-checked.rs @@ -0,0 +1,7 @@ +#[inline(always = 5)] +//~^ ERROR malformed +#[inline(always(x, y, z))] +//~^ ERROR malformed +fn main() { + +} \ No newline at end of file diff --git a/tests/ui/attributes/args-checked.stderr b/tests/ui/attributes/args-checked.stderr new file mode 100644 index 0000000000000..362a03ac68f5d --- /dev/null +++ b/tests/ui/attributes/args-checked.stderr @@ -0,0 +1,45 @@ +error[E0539]: malformed `inline` attribute input + --> $DIR/args-checked.rs:1:1 + | +LL | #[inline(always = 5)] + | ^^^^^^^^^----------^^ + | | + | valid arguments are `always` or `never` + | + = note: for more information, visit +help: try changing it to one of the following valid forms of the attribute + | +LL - #[inline(always = 5)] +LL + #[inline(always)] + | +LL - #[inline(always = 5)] +LL + #[inline(never)] + | +LL - #[inline(always = 5)] +LL + #[inline] + | + +error[E0539]: malformed `inline` attribute input + --> $DIR/args-checked.rs:3:1 + | +LL | #[inline(always(x, y, z))] + | ^^^^^^^^^---------------^^ + | | + | valid arguments are `always` or `never` + | + = note: for more information, visit +help: try changing it to one of the following valid forms of the attribute + | +LL - #[inline(always(x, y, z))] +LL + #[inline(always)] + | +LL - #[inline(always(x, y, z))] +LL + #[inline(never)] + | +LL - #[inline(always(x, y, z))] +LL + #[inline] + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0539`. From e9c835e954abba5bda3fc757a81f7f807dd97d70 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Sun, 12 Apr 2026 12:35:05 +0200 Subject: [PATCH 04/14] Properly check arguments of `#[instruction_set]` --- .../src/attributes/instruction_set.rs | 2 +- tests/ui/attributes/args-checked.rs | 4 +++ tests/ui/attributes/args-checked.stderr | 32 ++++++++++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs b/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs index 6f239a8f5761d..a42a77d95c5c0 100644 --- a/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs +++ b/compiler/rustc_attr_parsing/src/attributes/instruction_set.rs @@ -21,7 +21,7 @@ impl SingleAttributeParser for InstructionSetParser { const POSSIBLE_ARM_SYMBOLS: &[Symbol] = &[sym::a32, sym::t32]; let maybe_meta_item = cx.expect_single_element_list(args, cx.attr_span)?; - let Some(meta_item) = maybe_meta_item.meta_item() else { + let Some(meta_item) = maybe_meta_item.meta_item_no_args() else { cx.adcx().expected_specific_argument(maybe_meta_item.span(), POSSIBLE_SYMBOLS); return None; }; diff --git a/tests/ui/attributes/args-checked.rs b/tests/ui/attributes/args-checked.rs index 8a512a7f2a849..0f4d933e7be4e 100644 --- a/tests/ui/attributes/args-checked.rs +++ b/tests/ui/attributes/args-checked.rs @@ -2,6 +2,10 @@ //~^ ERROR malformed #[inline(always(x, y, z))] //~^ ERROR malformed +#[instruction_set(arm::a32 = 5)] +//~^ ERROR malformed +#[instruction_set(arm::a32(x, y, z))] +//~^ ERROR malformed fn main() { } \ No newline at end of file diff --git a/tests/ui/attributes/args-checked.stderr b/tests/ui/attributes/args-checked.stderr index 362a03ac68f5d..cdc08bc4b45f0 100644 --- a/tests/ui/attributes/args-checked.stderr +++ b/tests/ui/attributes/args-checked.stderr @@ -40,6 +40,36 @@ LL - #[inline(always(x, y, z))] LL + #[inline] | -error: aborting due to 2 previous errors +error[E0539]: malformed `instruction_set` attribute input + --> $DIR/args-checked.rs:5:1 + | +LL | #[instruction_set(arm::a32 = 5)] + | ^^^^^^^^^^^^^^^^^^------------^^ + | | + | valid arguments are `arm::a32` or `arm::t32` + | + = note: for more information, visit +help: must be of the form + | +LL - #[instruction_set(arm::a32 = 5)] +LL + #[instruction_set(set)] + | + +error[E0539]: malformed `instruction_set` attribute input + --> $DIR/args-checked.rs:7:1 + | +LL | #[instruction_set(arm::a32(x, y, z))] + | ^^^^^^^^^^^^^^^^^^-----------------^^ + | | + | valid arguments are `arm::a32` or `arm::t32` + | + = note: for more information, visit +help: must be of the form + | +LL - #[instruction_set(arm::a32(x, y, z))] +LL + #[instruction_set(set)] + | + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0539`. From 7432ccdbbb1fe1ed4f9ebaf9be5abdb903e41bc3 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Sun, 12 Apr 2026 12:36:39 +0200 Subject: [PATCH 05/14] Properly check arguments of `#[macro_export]` --- .../src/attributes/macro_attrs.rs | 2 +- tests/ui/attributes/args-checked.rs | 10 +++++ tests/ui/attributes/args-checked.stderr | 43 ++++++++++++++++++- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs index 36ee18d5bbe8d..29289c55fdda4 100644 --- a/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/macro_attrs.rs @@ -146,7 +146,7 @@ impl SingleAttributeParser 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()) { + match l.meta_item_no_args().and_then(|i| i.path().word_sym()) { Some(sym::local_inner_macros) => true, _ => { cx.adcx().warn_ill_formed_attribute_input(INVALID_MACRO_EXPORT_ARGUMENTS); diff --git a/tests/ui/attributes/args-checked.rs b/tests/ui/attributes/args-checked.rs index 0f4d933e7be4e..c5abfd68ed66c 100644 --- a/tests/ui/attributes/args-checked.rs +++ b/tests/ui/attributes/args-checked.rs @@ -8,4 +8,14 @@ //~^ ERROR malformed fn main() { +} + +#[macro_export(local_inner_macros = 5)] +//~^ ERROR valid forms for the attribute are +//~| WARN previously accepted +#[macro_export(local_inner_macros(x, y, z))] +//~^ ERROR valid forms for the attribute are +//~| WARN previously accepted +macro_rules! m { + () => {}; } \ No newline at end of file diff --git a/tests/ui/attributes/args-checked.stderr b/tests/ui/attributes/args-checked.stderr index cdc08bc4b45f0..2d3cf21e201ea 100644 --- a/tests/ui/attributes/args-checked.stderr +++ b/tests/ui/attributes/args-checked.stderr @@ -70,6 +70,47 @@ LL - #[instruction_set(arm::a32(x, y, z))] LL + #[instruction_set(set)] | -error: aborting due to 4 previous errors +error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` + --> $DIR/args-checked.rs:13:1 + | +LL | #[macro_export(local_inner_macros = 5)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 + = note: `#[deny(invalid_macro_export_arguments)]` (part of `#[deny(future_incompatible)]`) on by default + +error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` + --> $DIR/args-checked.rs:16:1 + | +LL | #[macro_export(local_inner_macros(x, y, z))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0539`. +Future incompatibility report: Future breakage diagnostic: +error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` + --> $DIR/args-checked.rs:13:1 + | +LL | #[macro_export(local_inner_macros = 5)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 + = note: `#[deny(invalid_macro_export_arguments)]` (part of `#[deny(future_incompatible)]`) on by default + +Future breakage diagnostic: +error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` + --> $DIR/args-checked.rs:16:1 + | +LL | #[macro_export(local_inner_macros(x, y, z))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 + = note: `#[deny(invalid_macro_export_arguments)]` (part of `#[deny(future_incompatible)]`) on by default + From 7f9b297bffa2ad7ebef99bd64d733649829f3e30 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Sun, 12 Apr 2026 12:39:09 +0200 Subject: [PATCH 06/14] Properly check arguments of `#[rustc_allow_const_fn_unstable]` --- .../src/attributes/allow_unstable.rs | 2 +- tests/ui/attributes/args-checked.rs | 10 ++++++- tests/ui/attributes/args-checked.stderr | 30 +++++++++++++------ 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs b/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs index e72533fb3c890..05e1557f58b60 100644 --- a/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs +++ b/compiler/rustc_attr_parsing/src/attributes/allow_unstable.rs @@ -91,7 +91,7 @@ fn parse_unstable( for param in list.mixed() { let param_span = param.span(); - if let Some(ident) = param.meta_item().and_then(|i| i.path().word()) { + if let Some(ident) = param.meta_item_no_args().and_then(|i| i.path().word()) { res.push(ident.name); } else { cx.emit_err(session_diagnostics::ExpectsFeatures { diff --git a/tests/ui/attributes/args-checked.rs b/tests/ui/attributes/args-checked.rs index c5abfd68ed66c..462ca307b58a7 100644 --- a/tests/ui/attributes/args-checked.rs +++ b/tests/ui/attributes/args-checked.rs @@ -1,3 +1,5 @@ +#![feature(rustc_attrs)] + #[inline(always = 5)] //~^ ERROR malformed #[inline(always(x, y, z))] @@ -18,4 +20,10 @@ fn main() { //~| WARN previously accepted macro_rules! m { () => {}; -} \ No newline at end of file +} + +#[rustc_allow_const_fn_unstable(x = 5)] +//~^ ERROR `rustc_allow_const_fn_unstable` expects feature names +#[rustc_allow_const_fn_unstable(x(x, y, z))] +//~^ ERROR `rustc_allow_const_fn_unstable` expects feature names +const fn g() {} \ No newline at end of file diff --git a/tests/ui/attributes/args-checked.stderr b/tests/ui/attributes/args-checked.stderr index 2d3cf21e201ea..e523d3c3b5415 100644 --- a/tests/ui/attributes/args-checked.stderr +++ b/tests/ui/attributes/args-checked.stderr @@ -1,5 +1,5 @@ error[E0539]: malformed `inline` attribute input - --> $DIR/args-checked.rs:1:1 + --> $DIR/args-checked.rs:3:1 | LL | #[inline(always = 5)] | ^^^^^^^^^----------^^ @@ -20,7 +20,7 @@ LL + #[inline] | error[E0539]: malformed `inline` attribute input - --> $DIR/args-checked.rs:3:1 + --> $DIR/args-checked.rs:5:1 | LL | #[inline(always(x, y, z))] | ^^^^^^^^^---------------^^ @@ -41,7 +41,7 @@ LL + #[inline] | error[E0539]: malformed `instruction_set` attribute input - --> $DIR/args-checked.rs:5:1 + --> $DIR/args-checked.rs:7:1 | LL | #[instruction_set(arm::a32 = 5)] | ^^^^^^^^^^^^^^^^^^------------^^ @@ -56,7 +56,7 @@ LL + #[instruction_set(set)] | error[E0539]: malformed `instruction_set` attribute input - --> $DIR/args-checked.rs:7:1 + --> $DIR/args-checked.rs:9:1 | LL | #[instruction_set(arm::a32(x, y, z))] | ^^^^^^^^^^^^^^^^^^-----------------^^ @@ -70,8 +70,20 @@ LL - #[instruction_set(arm::a32(x, y, z))] LL + #[instruction_set(set)] | +error: `rustc_allow_const_fn_unstable` expects feature names + --> $DIR/args-checked.rs:25:33 + | +LL | #[rustc_allow_const_fn_unstable(x = 5)] + | ^^^^^ + +error: `rustc_allow_const_fn_unstable` expects feature names + --> $DIR/args-checked.rs:27:33 + | +LL | #[rustc_allow_const_fn_unstable(x(x, y, z))] + | ^^^^^^^^^^ + error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:13:1 + --> $DIR/args-checked.rs:15:1 | LL | #[macro_export(local_inner_macros = 5)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -81,7 +93,7 @@ LL | #[macro_export(local_inner_macros = 5)] = note: `#[deny(invalid_macro_export_arguments)]` (part of `#[deny(future_incompatible)]`) on by default error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:16:1 + --> $DIR/args-checked.rs:18:1 | LL | #[macro_export(local_inner_macros(x, y, z))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -89,12 +101,12 @@ LL | #[macro_export(local_inner_macros(x, y, z))] = 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: aborting due to 6 previous errors +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0539`. Future incompatibility report: Future breakage diagnostic: error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:13:1 + --> $DIR/args-checked.rs:15:1 | LL | #[macro_export(local_inner_macros = 5)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -105,7 +117,7 @@ LL | #[macro_export(local_inner_macros = 5)] Future breakage diagnostic: error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:16:1 + --> $DIR/args-checked.rs:18:1 | LL | #[macro_export(local_inner_macros(x, y, z))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From d54066f6a9758cd2b2e843b66ab260b914d5b7c1 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Sun, 12 Apr 2026 12:40:19 +0200 Subject: [PATCH 07/14] Properly check arguments of `#[optimize]` --- .../src/attributes/codegen_attrs.rs | 2 +- tests/ui/attributes/args-checked.rs | 7 ++ tests/ui/attributes/args-checked.stderr | 74 ++++++++++++++++--- 3 files changed, 71 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs index 791b9de0f763e..b6046253bdfcc 100644 --- a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs @@ -26,7 +26,7 @@ impl SingleAttributeParser for OptimizeParser { fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option { let single = cx.expect_single_element_list(args, cx.attr_span)?; - let res = match single.meta_item().and_then(|i| i.path().word().map(|i| i.name)) { + let res = match single.meta_item_no_args().and_then(|i| i.path().word().map(|i| i.name)) { Some(sym::size) => OptimizeAttr::Size, Some(sym::speed) => OptimizeAttr::Speed, Some(sym::none) => OptimizeAttr::DoNotOptimize, diff --git a/tests/ui/attributes/args-checked.rs b/tests/ui/attributes/args-checked.rs index 462ca307b58a7..b727edc8e9192 100644 --- a/tests/ui/attributes/args-checked.rs +++ b/tests/ui/attributes/args-checked.rs @@ -1,4 +1,6 @@ #![feature(rustc_attrs)] +#![feature(optimize_attribute)] +#![allow(unused_attributes)] #[inline(always = 5)] //~^ ERROR malformed @@ -8,6 +10,11 @@ //~^ ERROR malformed #[instruction_set(arm::a32(x, y, z))] //~^ ERROR malformed +#[optimize(size = 5)] +//~^ ERROR malformed +#[optimize(size(x, y, z))] +//~^ ERROR malformed +//~| ERROR multiple `optimize` attributes fn main() { } diff --git a/tests/ui/attributes/args-checked.stderr b/tests/ui/attributes/args-checked.stderr index e523d3c3b5415..a0c57bc1d3783 100644 --- a/tests/ui/attributes/args-checked.stderr +++ b/tests/ui/attributes/args-checked.stderr @@ -1,5 +1,5 @@ error[E0539]: malformed `inline` attribute input - --> $DIR/args-checked.rs:3:1 + --> $DIR/args-checked.rs:5:1 | LL | #[inline(always = 5)] | ^^^^^^^^^----------^^ @@ -20,7 +20,7 @@ LL + #[inline] | error[E0539]: malformed `inline` attribute input - --> $DIR/args-checked.rs:5:1 + --> $DIR/args-checked.rs:7:1 | LL | #[inline(always(x, y, z))] | ^^^^^^^^^---------------^^ @@ -41,7 +41,7 @@ LL + #[inline] | error[E0539]: malformed `instruction_set` attribute input - --> $DIR/args-checked.rs:7:1 + --> $DIR/args-checked.rs:9:1 | LL | #[instruction_set(arm::a32 = 5)] | ^^^^^^^^^^^^^^^^^^------------^^ @@ -56,7 +56,7 @@ LL + #[instruction_set(set)] | error[E0539]: malformed `instruction_set` attribute input - --> $DIR/args-checked.rs:9:1 + --> $DIR/args-checked.rs:11:1 | LL | #[instruction_set(arm::a32(x, y, z))] | ^^^^^^^^^^^^^^^^^^-----------------^^ @@ -70,20 +70,72 @@ LL - #[instruction_set(arm::a32(x, y, z))] LL + #[instruction_set(set)] | +error[E0539]: malformed `optimize` attribute input + --> $DIR/args-checked.rs:13:1 + | +LL | #[optimize(size = 5)] + | ^^^^^^^^^^^--------^^ + | | + | valid arguments are `size`, `speed` or `none` + | +help: try changing it to one of the following valid forms of the attribute + | +LL - #[optimize(size = 5)] +LL + #[optimize(none)] + | +LL - #[optimize(size = 5)] +LL + #[optimize(size)] + | +LL - #[optimize(size = 5)] +LL + #[optimize(speed)] + | + +error[E0539]: malformed `optimize` attribute input + --> $DIR/args-checked.rs:15:1 + | +LL | #[optimize(size(x, y, z))] + | ^^^^^^^^^^^-------------^^ + | | + | valid arguments are `size`, `speed` or `none` + | +help: try changing it to one of the following valid forms of the attribute + | +LL - #[optimize(size(x, y, z))] +LL + #[optimize(none)] + | +LL - #[optimize(size(x, y, z))] +LL + #[optimize(size)] + | +LL - #[optimize(size(x, y, z))] +LL + #[optimize(speed)] + | + +error: multiple `optimize` attributes + --> $DIR/args-checked.rs:15:1 + | +LL | #[optimize(size(x, y, z))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/args-checked.rs:13:1 + | +LL | #[optimize(size = 5)] + | ^^^^^^^^^^^^^^^^^^^^^ + error: `rustc_allow_const_fn_unstable` expects feature names - --> $DIR/args-checked.rs:25:33 + --> $DIR/args-checked.rs:32:33 | LL | #[rustc_allow_const_fn_unstable(x = 5)] | ^^^^^ error: `rustc_allow_const_fn_unstable` expects feature names - --> $DIR/args-checked.rs:27:33 + --> $DIR/args-checked.rs:34:33 | LL | #[rustc_allow_const_fn_unstable(x(x, y, z))] | ^^^^^^^^^^ error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:15:1 + --> $DIR/args-checked.rs:22:1 | LL | #[macro_export(local_inner_macros = 5)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -93,7 +145,7 @@ LL | #[macro_export(local_inner_macros = 5)] = note: `#[deny(invalid_macro_export_arguments)]` (part of `#[deny(future_incompatible)]`) on by default error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:18:1 + --> $DIR/args-checked.rs:25:1 | LL | #[macro_export(local_inner_macros(x, y, z))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -101,12 +153,12 @@ LL | #[macro_export(local_inner_macros(x, y, z))] = 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: aborting due to 8 previous errors +error: aborting due to 11 previous errors For more information about this error, try `rustc --explain E0539`. Future incompatibility report: Future breakage diagnostic: error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:15:1 + --> $DIR/args-checked.rs:22:1 | LL | #[macro_export(local_inner_macros = 5)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -117,7 +169,7 @@ LL | #[macro_export(local_inner_macros = 5)] Future breakage diagnostic: error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:18:1 + --> $DIR/args-checked.rs:25:1 | LL | #[macro_export(local_inner_macros(x, y, z))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From acdb15c3470a0b0b94d2108a3826005a7e02536c Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Sun, 12 Apr 2026 12:41:06 +0200 Subject: [PATCH 08/14] Properly check arguments of `#[coverage]` --- .../src/attributes/codegen_attrs.rs | 2 +- tests/ui/attributes/args-checked.rs | 5 ++ tests/ui/attributes/args-checked.stderr | 64 ++++++++++++++----- 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs index b6046253bdfcc..2e8adf61719c0 100644 --- a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs @@ -80,7 +80,7 @@ impl SingleAttributeParser for CoverageParser { let mut fail_incorrect_argument = |span| cx.adcx().expected_specific_argument(span, &[sym::on, sym::off]); - let Some(arg) = arg.meta_item() else { + let Some(arg) = arg.meta_item_no_args() else { fail_incorrect_argument(arg.span()); return None; }; diff --git a/tests/ui/attributes/args-checked.rs b/tests/ui/attributes/args-checked.rs index b727edc8e9192..49cf2bdbd03e0 100644 --- a/tests/ui/attributes/args-checked.rs +++ b/tests/ui/attributes/args-checked.rs @@ -1,5 +1,6 @@ #![feature(rustc_attrs)] #![feature(optimize_attribute)] +#![feature(coverage_attribute)] #![allow(unused_attributes)] #[inline(always = 5)] @@ -15,6 +16,10 @@ #[optimize(size(x, y, z))] //~^ ERROR malformed //~| ERROR multiple `optimize` attributes +#[coverage(off = 5)] +//~^ ERROR malformed +#[coverage(off(x, y, z))] +//~^ ERROR malformed fn main() { } diff --git a/tests/ui/attributes/args-checked.stderr b/tests/ui/attributes/args-checked.stderr index a0c57bc1d3783..8d9359dd25e8b 100644 --- a/tests/ui/attributes/args-checked.stderr +++ b/tests/ui/attributes/args-checked.stderr @@ -1,5 +1,5 @@ error[E0539]: malformed `inline` attribute input - --> $DIR/args-checked.rs:5:1 + --> $DIR/args-checked.rs:6:1 | LL | #[inline(always = 5)] | ^^^^^^^^^----------^^ @@ -20,7 +20,7 @@ LL + #[inline] | error[E0539]: malformed `inline` attribute input - --> $DIR/args-checked.rs:7:1 + --> $DIR/args-checked.rs:8:1 | LL | #[inline(always(x, y, z))] | ^^^^^^^^^---------------^^ @@ -41,7 +41,7 @@ LL + #[inline] | error[E0539]: malformed `instruction_set` attribute input - --> $DIR/args-checked.rs:9:1 + --> $DIR/args-checked.rs:10:1 | LL | #[instruction_set(arm::a32 = 5)] | ^^^^^^^^^^^^^^^^^^------------^^ @@ -56,7 +56,7 @@ LL + #[instruction_set(set)] | error[E0539]: malformed `instruction_set` attribute input - --> $DIR/args-checked.rs:11:1 + --> $DIR/args-checked.rs:12:1 | LL | #[instruction_set(arm::a32(x, y, z))] | ^^^^^^^^^^^^^^^^^^-----------------^^ @@ -71,7 +71,7 @@ LL + #[instruction_set(set)] | error[E0539]: malformed `optimize` attribute input - --> $DIR/args-checked.rs:13:1 + --> $DIR/args-checked.rs:14:1 | LL | #[optimize(size = 5)] | ^^^^^^^^^^^--------^^ @@ -91,7 +91,7 @@ LL + #[optimize(speed)] | error[E0539]: malformed `optimize` attribute input - --> $DIR/args-checked.rs:15:1 + --> $DIR/args-checked.rs:16:1 | LL | #[optimize(size(x, y, z))] | ^^^^^^^^^^^-------------^^ @@ -111,31 +111,65 @@ LL + #[optimize(speed)] | error: multiple `optimize` attributes - --> $DIR/args-checked.rs:15:1 + --> $DIR/args-checked.rs:16:1 | LL | #[optimize(size(x, y, z))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute | note: attribute also specified here - --> $DIR/args-checked.rs:13:1 + --> $DIR/args-checked.rs:14:1 | LL | #[optimize(size = 5)] | ^^^^^^^^^^^^^^^^^^^^^ +error[E0539]: malformed `coverage` attribute input + --> $DIR/args-checked.rs:19:1 + | +LL | #[coverage(off = 5)] + | ^^^^^^^^^^^-------^^ + | | + | valid arguments are `on` or `off` + | +help: try changing it to one of the following valid forms of the attribute + | +LL - #[coverage(off = 5)] +LL + #[coverage(off)] + | +LL - #[coverage(off = 5)] +LL + #[coverage(on)] + | + +error[E0539]: malformed `coverage` attribute input + --> $DIR/args-checked.rs:21:1 + | +LL | #[coverage(off(x, y, z))] + | ^^^^^^^^^^^------------^^ + | | + | valid arguments are `on` or `off` + | +help: try changing it to one of the following valid forms of the attribute + | +LL - #[coverage(off(x, y, z))] +LL + #[coverage(off)] + | +LL - #[coverage(off(x, y, z))] +LL + #[coverage(on)] + | + error: `rustc_allow_const_fn_unstable` expects feature names - --> $DIR/args-checked.rs:32:33 + --> $DIR/args-checked.rs:37:33 | LL | #[rustc_allow_const_fn_unstable(x = 5)] | ^^^^^ error: `rustc_allow_const_fn_unstable` expects feature names - --> $DIR/args-checked.rs:34:33 + --> $DIR/args-checked.rs:39:33 | LL | #[rustc_allow_const_fn_unstable(x(x, y, z))] | ^^^^^^^^^^ error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:22:1 + --> $DIR/args-checked.rs:27:1 | LL | #[macro_export(local_inner_macros = 5)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -145,7 +179,7 @@ LL | #[macro_export(local_inner_macros = 5)] = note: `#[deny(invalid_macro_export_arguments)]` (part of `#[deny(future_incompatible)]`) on by default error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:25:1 + --> $DIR/args-checked.rs:30:1 | LL | #[macro_export(local_inner_macros(x, y, z))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -153,12 +187,12 @@ LL | #[macro_export(local_inner_macros(x, y, z))] = 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: aborting due to 11 previous errors +error: aborting due to 13 previous errors For more information about this error, try `rustc --explain E0539`. Future incompatibility report: Future breakage diagnostic: error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:22:1 + --> $DIR/args-checked.rs:27:1 | LL | #[macro_export(local_inner_macros = 5)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -169,7 +203,7 @@ LL | #[macro_export(local_inner_macros = 5)] Future breakage diagnostic: error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:25:1 + --> $DIR/args-checked.rs:30:1 | LL | #[macro_export(local_inner_macros(x, y, z))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From d4fe280e418cd54947095eb7c415148c11efbe32 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Wed, 29 Apr 2026 20:11:50 +0200 Subject: [PATCH 09/14] Properly check arguments of `#[used]` --- .../src/attributes/codegen_attrs.rs | 2 +- tests/ui/attributes/args-checked.rs | 8 +++- tests/ui/attributes/args-checked.stderr | 42 ++++++++++++++++++- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs index 2e8adf61719c0..c2f92ebedddcf 100644 --- a/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs @@ -375,7 +375,7 @@ impl AttributeParser for UsedParser { return; }; - match l.meta_item().and_then(|i| i.path().word_sym()) { + match l.meta_item_no_args().and_then(|i| i.path().word_sym()) { Some(sym::compiler) => { if !cx.features().used_with_arg() { feature_err( diff --git a/tests/ui/attributes/args-checked.rs b/tests/ui/attributes/args-checked.rs index 49cf2bdbd03e0..5a1eb34207c5e 100644 --- a/tests/ui/attributes/args-checked.rs +++ b/tests/ui/attributes/args-checked.rs @@ -38,4 +38,10 @@ macro_rules! m { //~^ ERROR `rustc_allow_const_fn_unstable` expects feature names #[rustc_allow_const_fn_unstable(x(x, y, z))] //~^ ERROR `rustc_allow_const_fn_unstable` expects feature names -const fn g() {} \ No newline at end of file +const fn g() {} + +#[used(always = 5)] +//~^ ERROR malformed +#[used(always(x, y, z))] +//~^ ERROR malformed +static H: u64 = 5; \ No newline at end of file diff --git a/tests/ui/attributes/args-checked.stderr b/tests/ui/attributes/args-checked.stderr index 8d9359dd25e8b..2bc167358396c 100644 --- a/tests/ui/attributes/args-checked.stderr +++ b/tests/ui/attributes/args-checked.stderr @@ -168,6 +168,46 @@ error: `rustc_allow_const_fn_unstable` expects feature names LL | #[rustc_allow_const_fn_unstable(x(x, y, z))] | ^^^^^^^^^^ +error[E0539]: malformed `used` attribute input + --> $DIR/args-checked.rs:43:1 + | +LL | #[used(always = 5)] + | ^^^^^^^----------^^ + | | + | valid arguments are `compiler` or `linker` + | +help: try changing it to one of the following valid forms of the attribute + | +LL - #[used(always = 5)] +LL + #[used(compiler)] + | +LL - #[used(always = 5)] +LL + #[used(linker)] + | +LL - #[used(always = 5)] +LL + #[used] + | + +error[E0539]: malformed `used` attribute input + --> $DIR/args-checked.rs:45:1 + | +LL | #[used(always(x, y, z))] + | ^^^^^^^---------------^^ + | | + | valid arguments are `compiler` or `linker` + | +help: try changing it to one of the following valid forms of the attribute + | +LL - #[used(always(x, y, z))] +LL + #[used(compiler)] + | +LL - #[used(always(x, y, z))] +LL + #[used(linker)] + | +LL - #[used(always(x, y, z))] +LL + #[used] + | + error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` --> $DIR/args-checked.rs:27:1 | @@ -187,7 +227,7 @@ LL | #[macro_export(local_inner_macros(x, y, z))] = 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: aborting due to 13 previous errors +error: aborting due to 15 previous errors For more information about this error, try `rustc --explain E0539`. Future incompatibility report: Future breakage diagnostic: From 56ec3322322b7a6f362c306249be2e1be7ba6ecf Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Sun, 12 Apr 2026 12:44:39 +0200 Subject: [PATCH 10/14] Properly check arguments of `#[rustc_must_implement_one_of]` --- .../src/attributes/rustc_internal.rs | 2 +- tests/ui/attributes/args-checked.rs | 10 ++++++- tests/ui/attributes/args-checked.stderr | 30 ++++++++++++++++++- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index 36acd788b7f1a..0704989cfae32 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -43,7 +43,7 @@ impl SingleAttributeParser for RustcMustImplementOneOfParser { let mut errored = false; for argument in inputs { - let Some(meta) = argument.meta_item() else { + let Some(meta) = argument.meta_item_no_args() else { cx.adcx().expected_identifier(argument.span()); return None; }; diff --git a/tests/ui/attributes/args-checked.rs b/tests/ui/attributes/args-checked.rs index 5a1eb34207c5e..bf2624692a1b1 100644 --- a/tests/ui/attributes/args-checked.rs +++ b/tests/ui/attributes/args-checked.rs @@ -44,4 +44,12 @@ const fn g() {} //~^ ERROR malformed #[used(always(x, y, z))] //~^ ERROR malformed -static H: u64 = 5; \ No newline at end of file +static H: u64 = 5; + +#[rustc_must_implement_one_of(eq = 5, neq)] +//~^ ERROR malformed +#[rustc_must_implement_one_of(eq(x, y, z), neq)] +//~^ ERROR malformed +trait T { + +} \ No newline at end of file diff --git a/tests/ui/attributes/args-checked.stderr b/tests/ui/attributes/args-checked.stderr index 2bc167358396c..c36f2e27bba1d 100644 --- a/tests/ui/attributes/args-checked.stderr +++ b/tests/ui/attributes/args-checked.stderr @@ -208,6 +208,34 @@ LL - #[used(always(x, y, z))] LL + #[used] | +error[E0539]: malformed `rustc_must_implement_one_of` attribute input + --> $DIR/args-checked.rs:49:1 + | +LL | #[rustc_must_implement_one_of(eq = 5, neq)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------^^^^^^^ + | | + | expected a valid identifier here + | +help: must be of the form + | +LL - #[rustc_must_implement_one_of(eq = 5, neq)] +LL + #[rustc_must_implement_one_of(function1, function2, ...)] + | + +error[E0539]: malformed `rustc_must_implement_one_of` attribute input + --> $DIR/args-checked.rs:51:1 + | +LL | #[rustc_must_implement_one_of(eq(x, y, z), neq)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------^^^^^^^ + | | + | expected a valid identifier here + | +help: must be of the form + | +LL - #[rustc_must_implement_one_of(eq(x, y, z), neq)] +LL + #[rustc_must_implement_one_of(function1, function2, ...)] + | + error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` --> $DIR/args-checked.rs:27:1 | @@ -227,7 +255,7 @@ LL | #[macro_export(local_inner_macros(x, y, z))] = 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: aborting due to 15 previous errors +error: aborting due to 17 previous errors For more information about this error, try `rustc --explain E0539`. Future incompatibility report: Future breakage diagnostic: From 2c522babac5b97ec2e755d2e94221770f1cb037e Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Sun, 12 Apr 2026 12:45:39 +0200 Subject: [PATCH 11/14] Properly check arguments of `#[rustc_dump_layout]` --- .../src/attributes/rustc_dump.rs | 2 +- tests/ui/attributes/args-checked.rs | 8 +++++++ tests/ui/attributes/args-checked.stderr | 21 +++++++++++++++++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs index 1158f1c5acf4c..7d81659ddc580 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_dump.rs @@ -101,7 +101,7 @@ impl CombineAttributeParser for RustcDumpLayoutParser { let mut result = Vec::new(); for item in items.mixed() { - let Some(arg) = item.meta_item() else { + let Some(arg) = item.meta_item_no_args() else { cx.adcx().expected_not_literal(item.span()); continue; }; diff --git a/tests/ui/attributes/args-checked.rs b/tests/ui/attributes/args-checked.rs index bf2624692a1b1..e3a9a0b21b993 100644 --- a/tests/ui/attributes/args-checked.rs +++ b/tests/ui/attributes/args-checked.rs @@ -52,4 +52,12 @@ static H: u64 = 5; //~^ ERROR malformed trait T { +} + +#[rustc_dump_layout(debug = 5)] +//~^ ERROR malformed +#[rustc_dump_layout(debug(x, y, z))] +//~^ ERROR malformed +enum E { + } \ No newline at end of file diff --git a/tests/ui/attributes/args-checked.stderr b/tests/ui/attributes/args-checked.stderr index c36f2e27bba1d..ed8c44653effd 100644 --- a/tests/ui/attributes/args-checked.stderr +++ b/tests/ui/attributes/args-checked.stderr @@ -236,6 +236,22 @@ LL - #[rustc_must_implement_one_of(eq(x, y, z), neq)] LL + #[rustc_must_implement_one_of(function1, function2, ...)] | +error[E0565]: malformed `rustc_dump_layout` attribute input + --> $DIR/args-checked.rs:57:1 + | +LL | #[rustc_dump_layout(debug = 5)] + | ^^^^^^^^^^^^^^^^^^^^---------^^ + | | + | didn't expect a literal here + +error[E0565]: malformed `rustc_dump_layout` attribute input + --> $DIR/args-checked.rs:59:1 + | +LL | #[rustc_dump_layout(debug(x, y, z))] + | ^^^^^^^^^^^^^^^^^^^^--------------^^ + | | + | didn't expect a literal here + error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` --> $DIR/args-checked.rs:27:1 | @@ -255,9 +271,10 @@ LL | #[macro_export(local_inner_macros(x, y, z))] = 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: aborting due to 17 previous errors +error: aborting due to 19 previous errors -For more information about this error, try `rustc --explain E0539`. +Some errors have detailed explanations: E0539, E0565. +For more information about an error, try `rustc --explain E0539`. Future incompatibility report: Future breakage diagnostic: error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` --> $DIR/args-checked.rs:27:1 From a01fc9bde307da97edb2a987b4b2e515f0a01c14 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Sun, 12 Apr 2026 12:47:59 +0200 Subject: [PATCH 12/14] Properly check arguments of query dep graph attrs --- compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index 0704989cfae32..7322b78bfa465 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -906,7 +906,7 @@ impl SingleAttributeParser for RustcIfThisChangedParser { ArgParser::NoArgs => Some(AttributeKind::RustcIfThisChanged(cx.attr_span, None)), ArgParser::List(list) => { let item = cx.expect_single(list)?; - let Some(ident) = item.meta_item().and_then(|item| item.ident()) else { + let Some(ident) = item.meta_item_no_args().and_then(|item| item.ident()) else { cx.adcx().expected_identifier(item.span()); return None; }; @@ -964,7 +964,7 @@ impl CombineAttributeParser for RustcThenThisWouldNeedParser { cx.emit_err(AttributeRequiresOpt { span: cx.attr_span, opt: "-Z query-dep-graph" }); } let item = cx.expect_single_element_list(args, cx.attr_span)?; - let Some(ident) = item.meta_item().and_then(|item| item.ident()) else { + let Some(ident) = item.meta_item_no_args().and_then(|item| item.ident()) else { cx.adcx().expected_identifier(item.span()); return None; }; From 40d4617ee24b371d9f625d1e7a72cdcc73200bea Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Sun, 12 Apr 2026 12:48:46 +0200 Subject: [PATCH 13/14] Properly check arguments of `#[rustc_abi]` --- .../src/attributes/test_attrs.rs | 2 +- tests/ui/attributes/args-checked.rs | 4 ++ tests/ui/attributes/args-checked.stderr | 60 +++++++++++++++---- 3 files changed, 52 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs index 25031784c011a..499d37b8c8995 100644 --- a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs @@ -149,7 +149,7 @@ impl SingleAttributeParser for RustcAbiParser { let mut fail_incorrect_argument = |span| cx.adcx().expected_specific_argument(span, &[sym::assert_eq, sym::debug]); - let Some(arg) = arg.meta_item() else { + let Some(arg) = arg.meta_item_no_args() else { fail_incorrect_argument(args.span); return None; }; diff --git a/tests/ui/attributes/args-checked.rs b/tests/ui/attributes/args-checked.rs index e3a9a0b21b993..76cf87e1e6f2d 100644 --- a/tests/ui/attributes/args-checked.rs +++ b/tests/ui/attributes/args-checked.rs @@ -20,6 +20,10 @@ //~^ ERROR malformed #[coverage(off(x, y, z))] //~^ ERROR malformed +#[rustc_abi(debug = 5)] +//~^ ERROR malformed +#[rustc_abi(debug(x, y, z))] +//~^ ERROR malformed fn main() { } diff --git a/tests/ui/attributes/args-checked.stderr b/tests/ui/attributes/args-checked.stderr index ed8c44653effd..f660dd3b684c9 100644 --- a/tests/ui/attributes/args-checked.stderr +++ b/tests/ui/attributes/args-checked.stderr @@ -156,20 +156,54 @@ LL - #[coverage(off(x, y, z))] LL + #[coverage(on)] | +error[E0539]: malformed `rustc_abi` attribute input + --> $DIR/args-checked.rs:23:1 + | +LL | #[rustc_abi(debug = 5)] + | ^^^^^^^^^^^-----------^ + | | + | valid arguments are `assert_eq` or `debug` + | +help: try changing it to one of the following valid forms of the attribute + | +LL - #[rustc_abi(debug = 5)] +LL + #[rustc_abi(assert_eq)] + | +LL - #[rustc_abi(debug = 5)] +LL + #[rustc_abi(debug)] + | + +error[E0539]: malformed `rustc_abi` attribute input + --> $DIR/args-checked.rs:25:1 + | +LL | #[rustc_abi(debug(x, y, z))] + | ^^^^^^^^^^^----------------^ + | | + | valid arguments are `assert_eq` or `debug` + | +help: try changing it to one of the following valid forms of the attribute + | +LL - #[rustc_abi(debug(x, y, z))] +LL + #[rustc_abi(assert_eq)] + | +LL - #[rustc_abi(debug(x, y, z))] +LL + #[rustc_abi(debug)] + | + error: `rustc_allow_const_fn_unstable` expects feature names - --> $DIR/args-checked.rs:37:33 + --> $DIR/args-checked.rs:41:33 | LL | #[rustc_allow_const_fn_unstable(x = 5)] | ^^^^^ error: `rustc_allow_const_fn_unstable` expects feature names - --> $DIR/args-checked.rs:39:33 + --> $DIR/args-checked.rs:43:33 | LL | #[rustc_allow_const_fn_unstable(x(x, y, z))] | ^^^^^^^^^^ error[E0539]: malformed `used` attribute input - --> $DIR/args-checked.rs:43:1 + --> $DIR/args-checked.rs:47:1 | LL | #[used(always = 5)] | ^^^^^^^----------^^ @@ -189,7 +223,7 @@ LL + #[used] | error[E0539]: malformed `used` attribute input - --> $DIR/args-checked.rs:45:1 + --> $DIR/args-checked.rs:49:1 | LL | #[used(always(x, y, z))] | ^^^^^^^---------------^^ @@ -209,7 +243,7 @@ LL + #[used] | error[E0539]: malformed `rustc_must_implement_one_of` attribute input - --> $DIR/args-checked.rs:49:1 + --> $DIR/args-checked.rs:53:1 | LL | #[rustc_must_implement_one_of(eq = 5, neq)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------^^^^^^^ @@ -223,7 +257,7 @@ LL + #[rustc_must_implement_one_of(function1, function2, ...)] | error[E0539]: malformed `rustc_must_implement_one_of` attribute input - --> $DIR/args-checked.rs:51:1 + --> $DIR/args-checked.rs:55:1 | LL | #[rustc_must_implement_one_of(eq(x, y, z), neq)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------^^^^^^^ @@ -237,7 +271,7 @@ LL + #[rustc_must_implement_one_of(function1, function2, ...)] | error[E0565]: malformed `rustc_dump_layout` attribute input - --> $DIR/args-checked.rs:57:1 + --> $DIR/args-checked.rs:61:1 | LL | #[rustc_dump_layout(debug = 5)] | ^^^^^^^^^^^^^^^^^^^^---------^^ @@ -245,7 +279,7 @@ LL | #[rustc_dump_layout(debug = 5)] | didn't expect a literal here error[E0565]: malformed `rustc_dump_layout` attribute input - --> $DIR/args-checked.rs:59:1 + --> $DIR/args-checked.rs:63:1 | LL | #[rustc_dump_layout(debug(x, y, z))] | ^^^^^^^^^^^^^^^^^^^^--------------^^ @@ -253,7 +287,7 @@ LL | #[rustc_dump_layout(debug(x, y, z))] | didn't expect a literal here error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:27:1 + --> $DIR/args-checked.rs:31:1 | LL | #[macro_export(local_inner_macros = 5)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -263,7 +297,7 @@ LL | #[macro_export(local_inner_macros = 5)] = note: `#[deny(invalid_macro_export_arguments)]` (part of `#[deny(future_incompatible)]`) on by default error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:30:1 + --> $DIR/args-checked.rs:34:1 | LL | #[macro_export(local_inner_macros(x, y, z))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -271,13 +305,13 @@ LL | #[macro_export(local_inner_macros(x, y, z))] = 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: aborting due to 19 previous errors +error: aborting due to 21 previous errors Some errors have detailed explanations: E0539, E0565. For more information about an error, try `rustc --explain E0539`. Future incompatibility report: Future breakage diagnostic: error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:27:1 + --> $DIR/args-checked.rs:31:1 | LL | #[macro_export(local_inner_macros = 5)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -288,7 +322,7 @@ LL | #[macro_export(local_inner_macros = 5)] Future breakage diagnostic: error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:30:1 + --> $DIR/args-checked.rs:34:1 | LL | #[macro_export(local_inner_macros(x, y, z))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From 3e5dc2298ae99e4f733fdd944d34d69aa03512d0 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Sun, 12 Apr 2026 12:49:44 +0200 Subject: [PATCH 14/14] Properly check arguments of `#[test_runner]` --- .../src/attributes/test_attrs.rs | 2 +- tests/ui/attributes/args-checked.rs | 8 +- tests/ui/attributes/args-checked.stderr | 78 +++++++++++++------ 3 files changed, 61 insertions(+), 27 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs index 499d37b8c8995..26c803e366437 100644 --- a/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs +++ b/compiler/rustc_attr_parsing/src/attributes/test_attrs.rs @@ -199,7 +199,7 @@ impl SingleAttributeParser for TestRunnerParser { fn convert(cx: &mut AcceptContext<'_, '_>, args: &ArgParser) -> Option { let single = cx.expect_single_element_list(args, cx.attr_span)?; - let Some(meta) = single.meta_item() else { + let Some(meta) = single.meta_item_no_args() else { cx.adcx().expected_not_literal(single.span()); return None; }; diff --git a/tests/ui/attributes/args-checked.rs b/tests/ui/attributes/args-checked.rs index 76cf87e1e6f2d..18369acfea034 100644 --- a/tests/ui/attributes/args-checked.rs +++ b/tests/ui/attributes/args-checked.rs @@ -1,8 +1,14 @@ #![feature(rustc_attrs)] #![feature(optimize_attribute)] #![feature(coverage_attribute)] +#![feature(custom_test_frameworks)] #![allow(unused_attributes)] +#![test_runner(x = 5)] +//~^ ERROR malformed +#![test_runner(x(x,y,z))] +//~^ ERROR malformed + #[inline(always = 5)] //~^ ERROR malformed #[inline(always(x, y, z))] @@ -64,4 +70,4 @@ trait T { //~^ ERROR malformed enum E { -} \ No newline at end of file +} diff --git a/tests/ui/attributes/args-checked.stderr b/tests/ui/attributes/args-checked.stderr index f660dd3b684c9..13dd6fde23cb7 100644 --- a/tests/ui/attributes/args-checked.stderr +++ b/tests/ui/attributes/args-checked.stderr @@ -1,5 +1,33 @@ +error[E0565]: malformed `test_runner` attribute input + --> $DIR/args-checked.rs:7:1 + | +LL | #![test_runner(x = 5)] + | ^^^^^^^^^^^^^^^-----^^ + | | + | didn't expect a literal here + | +help: must be of the form + | +LL - #![test_runner(x = 5)] +LL + #![test_runner(path)] + | + +error[E0565]: malformed `test_runner` attribute input + --> $DIR/args-checked.rs:9:1 + | +LL | #![test_runner(x(x,y,z))] + | ^^^^^^^^^^^^^^^--------^^ + | | + | didn't expect a literal here + | +help: must be of the form + | +LL - #![test_runner(x(x,y,z))] +LL + #![test_runner(path)] + | + error[E0539]: malformed `inline` attribute input - --> $DIR/args-checked.rs:6:1 + --> $DIR/args-checked.rs:12:1 | LL | #[inline(always = 5)] | ^^^^^^^^^----------^^ @@ -20,7 +48,7 @@ LL + #[inline] | error[E0539]: malformed `inline` attribute input - --> $DIR/args-checked.rs:8:1 + --> $DIR/args-checked.rs:14:1 | LL | #[inline(always(x, y, z))] | ^^^^^^^^^---------------^^ @@ -41,7 +69,7 @@ LL + #[inline] | error[E0539]: malformed `instruction_set` attribute input - --> $DIR/args-checked.rs:10:1 + --> $DIR/args-checked.rs:16:1 | LL | #[instruction_set(arm::a32 = 5)] | ^^^^^^^^^^^^^^^^^^------------^^ @@ -56,7 +84,7 @@ LL + #[instruction_set(set)] | error[E0539]: malformed `instruction_set` attribute input - --> $DIR/args-checked.rs:12:1 + --> $DIR/args-checked.rs:18:1 | LL | #[instruction_set(arm::a32(x, y, z))] | ^^^^^^^^^^^^^^^^^^-----------------^^ @@ -71,7 +99,7 @@ LL + #[instruction_set(set)] | error[E0539]: malformed `optimize` attribute input - --> $DIR/args-checked.rs:14:1 + --> $DIR/args-checked.rs:20:1 | LL | #[optimize(size = 5)] | ^^^^^^^^^^^--------^^ @@ -91,7 +119,7 @@ LL + #[optimize(speed)] | error[E0539]: malformed `optimize` attribute input - --> $DIR/args-checked.rs:16:1 + --> $DIR/args-checked.rs:22:1 | LL | #[optimize(size(x, y, z))] | ^^^^^^^^^^^-------------^^ @@ -111,19 +139,19 @@ LL + #[optimize(speed)] | error: multiple `optimize` attributes - --> $DIR/args-checked.rs:16:1 + --> $DIR/args-checked.rs:22:1 | LL | #[optimize(size(x, y, z))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute | note: attribute also specified here - --> $DIR/args-checked.rs:14:1 + --> $DIR/args-checked.rs:20:1 | LL | #[optimize(size = 5)] | ^^^^^^^^^^^^^^^^^^^^^ error[E0539]: malformed `coverage` attribute input - --> $DIR/args-checked.rs:19:1 + --> $DIR/args-checked.rs:25:1 | LL | #[coverage(off = 5)] | ^^^^^^^^^^^-------^^ @@ -140,7 +168,7 @@ LL + #[coverage(on)] | error[E0539]: malformed `coverage` attribute input - --> $DIR/args-checked.rs:21:1 + --> $DIR/args-checked.rs:27:1 | LL | #[coverage(off(x, y, z))] | ^^^^^^^^^^^------------^^ @@ -157,7 +185,7 @@ LL + #[coverage(on)] | error[E0539]: malformed `rustc_abi` attribute input - --> $DIR/args-checked.rs:23:1 + --> $DIR/args-checked.rs:29:1 | LL | #[rustc_abi(debug = 5)] | ^^^^^^^^^^^-----------^ @@ -174,7 +202,7 @@ LL + #[rustc_abi(debug)] | error[E0539]: malformed `rustc_abi` attribute input - --> $DIR/args-checked.rs:25:1 + --> $DIR/args-checked.rs:31:1 | LL | #[rustc_abi(debug(x, y, z))] | ^^^^^^^^^^^----------------^ @@ -191,19 +219,19 @@ LL + #[rustc_abi(debug)] | error: `rustc_allow_const_fn_unstable` expects feature names - --> $DIR/args-checked.rs:41:33 + --> $DIR/args-checked.rs:47:33 | LL | #[rustc_allow_const_fn_unstable(x = 5)] | ^^^^^ error: `rustc_allow_const_fn_unstable` expects feature names - --> $DIR/args-checked.rs:43:33 + --> $DIR/args-checked.rs:49:33 | LL | #[rustc_allow_const_fn_unstable(x(x, y, z))] | ^^^^^^^^^^ error[E0539]: malformed `used` attribute input - --> $DIR/args-checked.rs:47:1 + --> $DIR/args-checked.rs:53:1 | LL | #[used(always = 5)] | ^^^^^^^----------^^ @@ -223,7 +251,7 @@ LL + #[used] | error[E0539]: malformed `used` attribute input - --> $DIR/args-checked.rs:49:1 + --> $DIR/args-checked.rs:55:1 | LL | #[used(always(x, y, z))] | ^^^^^^^---------------^^ @@ -243,7 +271,7 @@ LL + #[used] | error[E0539]: malformed `rustc_must_implement_one_of` attribute input - --> $DIR/args-checked.rs:53:1 + --> $DIR/args-checked.rs:59:1 | LL | #[rustc_must_implement_one_of(eq = 5, neq)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------^^^^^^^ @@ -257,7 +285,7 @@ LL + #[rustc_must_implement_one_of(function1, function2, ...)] | error[E0539]: malformed `rustc_must_implement_one_of` attribute input - --> $DIR/args-checked.rs:55:1 + --> $DIR/args-checked.rs:61:1 | LL | #[rustc_must_implement_one_of(eq(x, y, z), neq)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------^^^^^^^ @@ -271,7 +299,7 @@ LL + #[rustc_must_implement_one_of(function1, function2, ...)] | error[E0565]: malformed `rustc_dump_layout` attribute input - --> $DIR/args-checked.rs:61:1 + --> $DIR/args-checked.rs:67:1 | LL | #[rustc_dump_layout(debug = 5)] | ^^^^^^^^^^^^^^^^^^^^---------^^ @@ -279,7 +307,7 @@ LL | #[rustc_dump_layout(debug = 5)] | didn't expect a literal here error[E0565]: malformed `rustc_dump_layout` attribute input - --> $DIR/args-checked.rs:63:1 + --> $DIR/args-checked.rs:69:1 | LL | #[rustc_dump_layout(debug(x, y, z))] | ^^^^^^^^^^^^^^^^^^^^--------------^^ @@ -287,7 +315,7 @@ LL | #[rustc_dump_layout(debug(x, y, z))] | didn't expect a literal here error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:31:1 + --> $DIR/args-checked.rs:37:1 | LL | #[macro_export(local_inner_macros = 5)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -297,7 +325,7 @@ LL | #[macro_export(local_inner_macros = 5)] = note: `#[deny(invalid_macro_export_arguments)]` (part of `#[deny(future_incompatible)]`) on by default error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:34:1 + --> $DIR/args-checked.rs:40:1 | LL | #[macro_export(local_inner_macros(x, y, z))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -305,13 +333,13 @@ LL | #[macro_export(local_inner_macros(x, y, z))] = 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: aborting due to 21 previous errors +error: aborting due to 23 previous errors Some errors have detailed explanations: E0539, E0565. For more information about an error, try `rustc --explain E0539`. Future incompatibility report: Future breakage diagnostic: error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:31:1 + --> $DIR/args-checked.rs:37:1 | LL | #[macro_export(local_inner_macros = 5)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -322,7 +350,7 @@ LL | #[macro_export(local_inner_macros = 5)] Future breakage diagnostic: error: valid forms for the attribute are `#[macro_export(local_inner_macros)]` and `#[macro_export]` - --> $DIR/args-checked.rs:34:1 + --> $DIR/args-checked.rs:40:1 | LL | #[macro_export(local_inner_macros(x, y, z))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^