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
3 changes: 2 additions & 1 deletion src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1838,8 +1838,9 @@ impl<'test> TestCx<'test> {

// Add `-A unused` before `config` flags and in-test (`props`) flags, so that they can
// overwrite this.
// Don't allow `unused_attributes` since these are usually actual mistakes, rather than just unused code.
if let AllowUnused::Yes = allow_unused {
rustc.args(&["-A", "unused"]);
rustc.args(&["-A", "unused", "-W", "unused_attributes"]);
}

// Allow tests to use internal features.
Expand Down
1 change: 1 addition & 0 deletions tests/ui/attributes/attr-mix-new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#[rustc_dummy(bar)]
mod foo {
#![feature(globs)]
//~^ WARN crate-level attribute should be in the root module
}

fn main() {}
10 changes: 10 additions & 0 deletions tests/ui/attributes/attr-mix-new.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
warning: crate-level attribute should be in the root module
--> $DIR/attr-mix-new.rs:7:3
|
LL | #![feature(globs)]
| ^^^^^^^^^^^^^^^^^^
|
= note: requested on the command line with `-W unused-attributes`

warning: 1 warning emitted

1 change: 1 addition & 0 deletions tests/ui/attributes/crate-type-macro-empty.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Tests for the issue in #137589
#[crate_type = foo!()]
//~^ ERROR cannot find macro `foo` in this scope
//~| WARN crate-level attribute should be an inner attribute

macro_rules! foo {} //~ ERROR macros must contain at least one rule

Expand Down
18 changes: 15 additions & 3 deletions tests/ui/attributes/crate-type-macro-empty.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: macros must contain at least one rule
--> $DIR/crate-type-macro-empty.rs:5:1
--> $DIR/crate-type-macro-empty.rs:6:1
|
LL | macro_rules! foo {}
| ^^^^^^^^^^^^^^^^^^^
Expand All @@ -11,10 +11,22 @@ LL | #[crate_type = foo!()]
| ^^^ consider moving the definition of `foo` before this call
|
note: a macro with the same name exists, but it appears later
--> $DIR/crate-type-macro-empty.rs:5:14
--> $DIR/crate-type-macro-empty.rs:6:14
|
LL | macro_rules! foo {}
| ^^^

error: aborting due to 2 previous errors
warning: crate-level attribute should be an inner attribute
--> $DIR/crate-type-macro-empty.rs:2:1
|
LL | #[crate_type = foo!()]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: requested on the command line with `-W unused-attributes`
help: add a `!`
|
LL | #![crate_type = foo!()]
| +

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

1 change: 1 addition & 0 deletions tests/ui/attributes/crate-type-macro-not-found.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Tests for the issue in #137589
#[crate_type = foo!()] //~ ERROR cannot find macro `foo` in this scope
//~| WARN crate-level attribute should be an inner attribute

macro_rules! foo {
($x:expr) => {"rlib"}
Expand Down
16 changes: 14 additions & 2 deletions tests/ui/attributes/crate-type-macro-not-found.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,22 @@ LL | #[crate_type = foo!()]
| ^^^ consider moving the definition of `foo` before this call
|
note: a macro with the same name exists, but it appears later
--> $DIR/crate-type-macro-not-found.rs:4:14
--> $DIR/crate-type-macro-not-found.rs:5:14
|
LL | macro_rules! foo {
| ^^^

error: aborting due to 1 previous error
warning: crate-level attribute should be an inner attribute
--> $DIR/crate-type-macro-not-found.rs:2:1
|
LL | #[crate_type = foo!()]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: requested on the command line with `-W unused-attributes`
help: add a `!`
|
LL | #![crate_type = foo!()]
| +

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

6 changes: 6 additions & 0 deletions tests/ui/attributes/inline/attr-usage-inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@ struct S;

struct I {
#[inline]
//~^ WARN attribute cannot be used on
//~| WARN previously accepted
i: u8,
}

#[macro_export]
#[inline]
//~^ WARN attribute cannot be used on
//~| WARN previously accepted
macro_rules! m_e {
() => {};
}

#[inline] //~ ERROR: attribute should be applied to function or closure
//~^ WARN attribute cannot be used on
//~| WARN previously accepted
macro_rules! m {
() => {};
}
Expand Down
32 changes: 30 additions & 2 deletions tests/ui/attributes/inline/attr-usage-inline.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,39 @@ LL | #[inline]
= help: `#[inline]` can only be applied to functions

error[E0518]: attribute should be applied to function or closure
--> $DIR/attr-usage-inline.rs:21:1
--> $DIR/attr-usage-inline.rs:25:1
|
LL | #[inline]
| ^^^^^^^^^ not a function or closure

error: aborting due to 2 previous errors
warning: `#[inline]` attribute cannot be used on struct fields
--> $DIR/attr-usage-inline.rs:11:5
|
LL | #[inline]
| ^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= help: `#[inline]` can only be applied to functions
= note: requested on the command line with `-W unused-attributes`

warning: `#[inline]` attribute cannot be used on macro defs
--> $DIR/attr-usage-inline.rs:18:1
|
LL | #[inline]
| ^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= help: `#[inline]` can only be applied to functions

warning: `#[inline]` attribute cannot be used on macro defs
--> $DIR/attr-usage-inline.rs:25:1
|
LL | #[inline]
| ^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= help: `#[inline]` can only be applied to functions

error: aborting due to 2 previous errors; 3 warnings emitted

For more information about this error, try `rustc --explain E0518`.
2 changes: 1 addition & 1 deletion tests/ui/attributes/link-dl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//@ revisions: default_fcw allowed
//@[allowed] check-pass

#[cfg_attr(allowed, allow(ill_formed_attribute_input))]
#![cfg_attr(allowed, allow(ill_formed_attribute_input))]

#[link="dl"]
//[default_fcw]~^ ERROR valid forms for the attribute are
Expand Down
9 changes: 9 additions & 0 deletions tests/ui/attributes/malformed-attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
//~| ERROR attribute cannot be used on
#[crate_name]
//~^ ERROR malformed
//~| WARN crate-level attribute should be an inner attribute
#[doc]
//~^ ERROR valid forms for the attribute are
//~| WARN this was previously accepted by the compiler
Expand All @@ -82,8 +83,12 @@
//~^ ERROR malformed
#[link]
//~^ ERROR malformed
//~| WARN attribute should be applied to an `extern` block with non-Rust ABI
//~| WARN previously accepted
#[link_name]
//~^ ERROR malformed
//~| WARN cannot be used on functions
//~| WARN previously accepted
#[link_section]
//~^ ERROR malformed
#[coverage]
Expand All @@ -95,6 +100,8 @@
//~| WARN this was previously accepted by the compiler
#[no_implicit_prelude = 23]
//~^ ERROR malformed
//~| WARN cannot be used on functions
//~| WARN previously accepted
#[proc_macro = 18]
//~^ ERROR malformed
//~| ERROR the `#[proc_macro]` attribute is only usable with crates of the `proc-macro` crate type
Expand Down Expand Up @@ -188,6 +195,8 @@ extern "C" {
//~^ ERROR malformed `debugger_visualizer` attribute input
#[automatically_derived = 18]
//~^ ERROR malformed
//~| WARN cannot be used on modules
//~| WARN previously accepted
mod yooo {

}
Expand Down
Loading
Loading