Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_attr_parsing/src/attributes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ impl<T: SingleAttributeParser<S>, S: Stage> AttributeParser<S> for Single<T, S>
if let Some(pa) = T::convert(cx, args) {
if let Some((_, used)) = group.1 {
T::ON_DUPLICATE.exec::<T>(cx, used, cx.attr_span);
} else {
group.1 = Some((pa, cx.attr_span));
}

group.1 = Some((pa, cx.attr_span));
}
},
)];
Expand Down
11 changes: 11 additions & 0 deletions tests/ui/attributes/attr-order-deprecated.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#[deprecated = "AAA"]
//~^ NOTE also specified here
#[deprecated = "BBB"]
//~^ ERROR multiple `deprecated` attributes
fn deprecated() { }

fn main() {
deprecated();
//~^ WARN use of deprecated function `deprecated`: AAA [deprecated]
//~| NOTE `#[warn(deprecated)]` on by default
}
22 changes: 22 additions & 0 deletions tests/ui/attributes/attr-order-deprecated.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
error: multiple `deprecated` attributes
--> $DIR/attr-order-deprecated.rs:3:1
|
LL | #[deprecated = "BBB"]
| ^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
|
note: attribute also specified here
--> $DIR/attr-order-deprecated.rs:1:1
|
LL | #[deprecated = "AAA"]
| ^^^^^^^^^^^^^^^^^^^^^

warning: use of deprecated function `deprecated`: AAA
--> $DIR/attr-order-deprecated.rs:8:5
|
LL | deprecated();
| ^^^^^^^^^^
|
= note: `#[warn(deprecated)]` on by default

error: aborting due to 1 previous error; 1 warning emitted

19 changes: 19 additions & 0 deletions tests/ui/attributes/attr-order-must-use.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#![deny(unused)]
//~^ NOTE lint level is defined here

#[must_use = "AAA"]
//~^ NOTE also specified here
#[must_use = "BBB"]
//~^ ERROR unused attribute
//~| WARN previously accepted
//~| NOTE `#[deny(unused_attributes)]` implied by `#[deny(unused)]`
fn must_use() -> usize {
0
}

fn main() {
must_use();
//~^ ERROR unused return value of `must_use` that must be used
//~| NOTE AAA
//~| NOTE `#[deny(unused_must_use)]` implied by `#[deny(unused)]`
}
34 changes: 34 additions & 0 deletions tests/ui/attributes/attr-order-must-use.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
error: unused attribute
--> $DIR/attr-order-must-use.rs:6:1
|
LL | #[must_use = "BBB"]
| ^^^^^^^^^^^^^^^^^^^ help: remove this attribute
|
note: attribute also specified here
--> $DIR/attr-order-must-use.rs:4:1
|
LL | #[must_use = "AAA"]
| ^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
note: the lint level is defined here
--> $DIR/attr-order-must-use.rs:1:9
|
LL | #![deny(unused)]
| ^^^^^^
= note: `#[deny(unused_attributes)]` implied by `#[deny(unused)]`

error: unused return value of `must_use` that must be used
--> $DIR/attr-order-must-use.rs:15:5
|
LL | must_use();
| ^^^^^^^^^^
|
= note: AAA
= note: `#[deny(unused_must_use)]` implied by `#[deny(unused)]`
help: use `let _ = ...` to ignore the resulting value
|
LL | let _ = must_use();
| +++++++

error: aborting due to 2 previous errors

12 changes: 6 additions & 6 deletions tests/ui/attributes/malformed-no-std.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Loading