From 029a24092d56094a69bf7c0842933adadb4001fc Mon Sep 17 00:00:00 2001 From: Amirhossein Akhlaghpour Date: Sat, 25 Jul 2026 19:35:47 +0330 Subject: [PATCH] fix: error in diagnostic on_unmatched_args Signed-off-by: Amirhossein Akhlaghpour --- .../src/attributes/diagnostic/on_unmatched_args.rs | 2 ++ .../disabled-feature-issue-159886.rs | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 tests/ui/diagnostic_namespace/on_unmatched_args/disabled-feature-issue-159886.rs diff --git a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unmatched_args.rs b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unmatched_args.rs index 18f980bfebbe8..df8cee63506cc 100644 --- a/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unmatched_args.rs +++ b/compiler/rustc_attr_parsing/src/attributes/diagnostic/on_unmatched_args.rs @@ -17,6 +17,8 @@ impl AttributeParser for OnUnmatchedArgsParser { AttributeStability::Stable, // Unstable, stability checked manually in the parser |this, cx, args| { if !cx.features().diagnostic_on_unmatched_args() { + // `UnknownDiagnosticAttribute` is emitted in rustc_resolve/macros.rs + args.ignore_args(); return; } diff --git a/tests/ui/diagnostic_namespace/on_unmatched_args/disabled-feature-issue-159886.rs b/tests/ui/diagnostic_namespace/on_unmatched_args/disabled-feature-issue-159886.rs new file mode 100644 index 0000000000000..0892844f51372 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unmatched_args/disabled-feature-issue-159886.rs @@ -0,0 +1,12 @@ +//@ check-pass +//@ needs-rustc-debug-assertions + +#![allow(unknown_or_malformed_diagnostic_attributes)] +#![allow(unused_macros)] + +#[diagnostic::on_unmatched_args(message)] +macro_rules! pair { + () => {}; +} + +fn main() {}