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() {}