diff --git a/compiler/rustc_attr_parsing/src/attributes/mod.rs b/compiler/rustc_attr_parsing/src/attributes/mod.rs index 66f452040954..27d13cb85c14 100644 --- a/compiler/rustc_attr_parsing/src/attributes/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/mod.rs @@ -159,9 +159,9 @@ impl, S: Stage> AttributeParser for Single if let Some(pa) = T::convert(cx, args) { if let Some((_, used)) = group.1 { T::ON_DUPLICATE.exec::(cx, used, cx.attr_span); + } else { + group.1 = Some((pa, cx.attr_span)); } - - group.1 = Some((pa, cx.attr_span)); } }, )]; diff --git a/tests/ui/attributes/malformed-no-std.stderr b/tests/ui/attributes/malformed-no-std.stderr index e994e28e030f..63b6d628970c 100644 --- a/tests/ui/attributes/malformed-no-std.stderr +++ b/tests/ui/attributes/malformed-no-std.stderr @@ -101,10 +101,10 @@ LL | #![no_std(foo = "bar")] | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute | note: attribute also specified here - --> $DIR/malformed-no-std.rs:5:1 + --> $DIR/malformed-no-std.rs:3:1 | -LL | #![no_std("bar")] - | ^^^^^^^^^^^^^^^^^ +LL | #![no_std = "foo"] + | ^^^^^^^^^^^^^^^^^^ warning: unused attribute --> $DIR/malformed-no-std.rs:13:1 @@ -125,10 +125,10 @@ LL | #![no_core(foo = "bar")] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute | note: attribute also specified here - --> $DIR/malformed-no-std.rs:13:1 + --> $DIR/malformed-no-std.rs:11:1 | -LL | #![no_core("bar")] - | ^^^^^^^^^^^^^^^^^^ +LL | #![no_core = "foo"] + | ^^^^^^^^^^^^^^^^^^^ error: aborting due to 8 previous errors; 4 warnings emitted