diff --git a/src/doc/rustc/src/lints/listing/warn-by-default.md b/src/doc/rustc/src/lints/listing/warn-by-default.md index f090f142c08..6d4aa024c75 100644 --- a/src/doc/rustc/src/lints/listing/warn-by-default.md +++ b/src/doc/rustc/src/lints/listing/warn-by-default.md @@ -728,19 +728,17 @@ This lint detects attributes that were not used by the compiler. Some example code that triggers this lint: ```rust -#![feature(custom_attribute)] - -#![mutable_doc] +#![macro_export] ``` This will produce: ```text warning: unused attribute - --> src/main.rs:4:1 + --> src/main.rs:1:1 | -4 | #![mutable_doc] - | ^^^^^^^^^^^^^^^ +1 | #![macro_export] + | ^^^^^^^^^^^^^^^^ | ``` diff --git a/src/test/ui/lint/lint-obsolete-attr.rs b/src/test/ui/lint/lint-obsolete-attr.rs index 149948b5a6d..49a8dde5da8 100644 --- a/src/test/ui/lint/lint-obsolete-attr.rs +++ b/src/test/ui/lint/lint-obsolete-attr.rs @@ -1,12 +1,8 @@ // When denying at the crate level, be sure to not get random warnings from the // injected intrinsics by the compiler. -#![deny(unused_attributes)] -#![allow(dead_code)] -#![feature(custom_attribute)] +#[ab_isize="stdcall"] extern {} //~ ERROR attribute `ab_isize` is currently unknown -#[ab_isize="stdcall"] extern {} //~ ERROR unused attribute - -#[fixed_stack_segment] fn f() {} //~ ERROR unused attribute +#[fixed_stack_segment] fn f() {} //~ ERROR attribute `fixed_stack_segment` is currently unknown fn main() {} diff --git a/src/test/ui/lint/lint-obsolete-attr.stderr b/src/test/ui/lint/lint-obsolete-attr.stderr index c06bd26df2b..039b07e6ea5 100644 --- a/src/test/ui/lint/lint-obsolete-attr.stderr +++ b/src/test/ui/lint/lint-obsolete-attr.stderr @@ -1,20 +1,21 @@ -error: unused attribute - --> $DIR/lint-obsolete-attr.rs:8:1 - | -LL | #[ab_isize="stdcall"] extern {} - | ^^^^^^^^^^^^^^^^^^^^^ - | -note: lint level defined here - --> $DIR/lint-obsolete-attr.rs:4:9 - | -LL | #![deny(unused_attributes)] - | ^^^^^^^^^^^^^^^^^ - -error: unused attribute - --> $DIR/lint-obsolete-attr.rs:10:1 +error[E0658]: The attribute `fixed_stack_segment` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/lint-obsolete-attr.rs:6:3 | LL | #[fixed_stack_segment] fn f() {} - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: The attribute `ab_isize` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/lint-obsolete-attr.rs:4:3 + | +LL | #[ab_isize="stdcall"] extern {} + | ^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/lint/lint-unknown-attr.rs b/src/test/ui/lint/lint-unknown-attr.rs index 828b869c12e..cddac850c59 100644 --- a/src/test/ui/lint/lint-unknown-attr.rs +++ b/src/test/ui/lint/lint-unknown-attr.rs @@ -1,11 +1,10 @@ // When denying at the crate level, be sure to not get random warnings from the // injected intrinsics by the compiler. -#![feature(custom_attribute)] -#![deny(unused_attributes)] +#![feature(custom_inner_attributes)] -#![mutable_doc] //~ ERROR unused attribute +#![mutable_doc] //~ ERROR attribute `mutable_doc` is currently unknown -#[dance] mod a {} //~ ERROR unused attribute +#[dance] mod a {} //~ ERROR attribute `dance` is currently unknown -#[dance] fn main() {} //~ ERROR unused attribute +#[dance] fn main() {} //~ ERROR attribute `dance` is currently unknown diff --git a/src/test/ui/lint/lint-unknown-attr.stderr b/src/test/ui/lint/lint-unknown-attr.stderr index 9817760c224..4f00a51a5db 100644 --- a/src/test/ui/lint/lint-unknown-attr.stderr +++ b/src/test/ui/lint/lint-unknown-attr.stderr @@ -1,26 +1,30 @@ -error: unused attribute - --> $DIR/lint-unknown-attr.rs:9:1 - | -LL | #[dance] mod a {} - | ^^^^^^^^ - | -note: lint level defined here - --> $DIR/lint-unknown-attr.rs:5:9 - | -LL | #![deny(unused_attributes)] - | ^^^^^^^^^^^^^^^^^ - -error: unused attribute - --> $DIR/lint-unknown-attr.rs:11:1 - | -LL | #[dance] fn main() {} - | ^^^^^^^^ - -error: unused attribute - --> $DIR/lint-unknown-attr.rs:7:1 +error[E0658]: The attribute `mutable_doc` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/lint-unknown-attr.rs:6:4 | LL | #![mutable_doc] - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: The attribute `dance` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/lint-unknown-attr.rs:8:3 + | +LL | #[dance] mod a {} + | ^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: The attribute `dance` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/lint-unknown-attr.rs:10:3 + | +LL | #[dance] fn main() {} + | ^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/proc-macro/resolve-error.rs b/src/test/ui/proc-macro/resolve-error.rs index 82607136f0b..1298c08df84 100644 --- a/src/test/ui/proc-macro/resolve-error.rs +++ b/src/test/ui/proc-macro/resolve-error.rs @@ -2,8 +2,6 @@ // aux-build:derive-clona.rs // aux-build:test-macros.rs -#![feature(custom_attribute)] - #[macro_use] extern crate derive_foo; #[macro_use] @@ -25,10 +23,12 @@ macro_rules! attr_proc_mac { //~^ ERROR cannot find struct Foo; -#[attr_proc_macra] // OK, interpreted as a custom attribute +// Interpreted as a feature gated custom attribute +#[attr_proc_macra] //~ ERROR attribute `attr_proc_macra` is currently unknown struct Bar; -#[FooWithLongNan] // OK, interpreted as a custom attribute +// Interpreted as a feature gated custom attribute +#[FooWithLongNan] //~ ERROR attribute `FooWithLongNan` is currently unknown struct Asdf; #[derive(Dlone)] diff --git a/src/test/ui/proc-macro/resolve-error.stderr b/src/test/ui/proc-macro/resolve-error.stderr index 705ef6006a0..f9f116c15dc 100644 --- a/src/test/ui/proc-macro/resolve-error.stderr +++ b/src/test/ui/proc-macro/resolve-error.stderr @@ -1,5 +1,23 @@ +error[E0658]: The attribute `attr_proc_macra` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/resolve-error.rs:27:3 + | +LL | #[attr_proc_macra] + | ^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + +error[E0658]: The attribute `FooWithLongNan` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/resolve-error.rs:31:3 + | +LL | #[FooWithLongNan] + | ^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + error: cannot find derive macro `FooWithLongNan` in this scope - --> $DIR/resolve-error.rs:24:10 + --> $DIR/resolve-error.rs:22:10 | LL | #[derive(FooWithLongNan)] | ^^^^^^^^^^^^^^ help: try: `FooWithLongName` @@ -46,5 +64,6 @@ error: cannot find macro `bang_proc_macrp!` in this scope LL | bang_proc_macrp!(); | ^^^^^^^^^^^^^^^ help: you could try the macro: `bang_proc_macro` -error: aborting due to 8 previous errors +error: aborting due to 10 previous errors +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/tool-attributes/tool-attributes-misplaced-1.rs b/src/test/ui/tool-attributes/tool-attributes-misplaced-1.rs index 33cffcefd89..ce902b7e7d2 100644 --- a/src/test/ui/tool-attributes/tool-attributes-misplaced-1.rs +++ b/src/test/ui/tool-attributes/tool-attributes-misplaced-1.rs @@ -1,12 +1,11 @@ -#![feature(custom_attribute)] - type A = rustfmt; //~ ERROR expected type, found tool module `rustfmt` type B = rustfmt::skip; //~ ERROR expected type, found tool attribute `rustfmt::skip` #[derive(rustfmt)] //~ ERROR cannot find derive macro `rustfmt` in this scope struct S; -#[rustfmt] // OK, interpreted as a custom attribute +// Interpreted as a feature gated custom attribute +#[rustfmt] //~ ERROR attribute `rustfmt` is currently unknown fn check() {} #[rustfmt::skip] // OK diff --git a/src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr b/src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr index 1c799b41c5a..1df9821f244 100644 --- a/src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr +++ b/src/test/ui/tool-attributes/tool-attributes-misplaced-1.stderr @@ -1,39 +1,49 @@ +error[E0658]: The attribute `rustfmt` is currently unknown to the compiler and may have meaning added to it in the future + --> $DIR/tool-attributes-misplaced-1.rs:8:3 + | +LL | #[rustfmt] + | ^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/29642 + = help: add #![feature(custom_attribute)] to the crate attributes to enable + error: cannot find derive macro `rustfmt` in this scope - --> $DIR/tool-attributes-misplaced-1.rs:6:10 + --> $DIR/tool-attributes-misplaced-1.rs:4:10 | LL | #[derive(rustfmt)] | ^^^^^^^ error: cannot find macro `rustfmt!` in this scope - --> $DIR/tool-attributes-misplaced-1.rs:15:5 + --> $DIR/tool-attributes-misplaced-1.rs:14:5 | LL | rustfmt!(); | ^^^^^^^ error[E0573]: expected type, found tool module `rustfmt` - --> $DIR/tool-attributes-misplaced-1.rs:3:10 + --> $DIR/tool-attributes-misplaced-1.rs:1:10 | LL | type A = rustfmt; | ^^^^^^^ not a type error[E0573]: expected type, found tool attribute `rustfmt::skip` - --> $DIR/tool-attributes-misplaced-1.rs:4:10 + --> $DIR/tool-attributes-misplaced-1.rs:2:10 | LL | type B = rustfmt::skip; | ^^^^^^^^^^^^^ not a type error[E0423]: expected value, found tool module `rustfmt` - --> $DIR/tool-attributes-misplaced-1.rs:14:5 + --> $DIR/tool-attributes-misplaced-1.rs:13:5 | LL | rustfmt; | ^^^^^^^ not a value error[E0423]: expected value, found tool attribute `rustfmt::skip` - --> $DIR/tool-attributes-misplaced-1.rs:17:5 + --> $DIR/tool-attributes-misplaced-1.rs:16:5 | LL | rustfmt::skip; | ^^^^^^^^^^^^^ not a value -error: aborting due to 6 previous errors +error: aborting due to 7 previous errors -For more information about this error, try `rustc --explain E0423`. +Some errors have detailed explanations: E0423, E0658. +For more information about an error, try `rustc --explain E0423`.