about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tests/crashes/138510.rs7
-rw-r--r--tests/rustdoc-ui/check-doc-alias-attr-location.stderr4
-rw-r--r--tests/ui/asm/naked-invalid-attr.rs12
-rw-r--r--tests/ui/asm/naked-invalid-attr.stderr73
-rw-r--r--tests/ui/attributes/attrs-on-params.rs2
-rw-r--r--tests/ui/attributes/attrs-on-params.stderr9
-rw-r--r--tests/ui/attributes/cold-attribute-application-54044.rs12
-rw-r--r--tests/ui/attributes/cold-attribute-application-54044.stderr12
-rw-r--r--tests/ui/attributes/empty-repr.rs14
-rw-r--r--tests/ui/attributes/empty-repr.stderr14
-rw-r--r--tests/ui/attributes/inline-attribute-enum-variant-error.rs2
-rw-r--r--tests/ui/attributes/inline-attribute-enum-variant-error.stderr8
-rw-r--r--tests/ui/attributes/inline/attr-usage-inline.rs2
-rw-r--r--tests/ui/attributes/inline/attr-usage-inline.stderr6
-rw-r--r--tests/ui/attributes/issue-105594-invalid-attr-validation.rs2
-rw-r--r--tests/ui/attributes/issue-105594-invalid-attr-validation.stderr7
-rw-r--r--tests/ui/attributes/linkage.rs12
-rw-r--r--tests/ui/attributes/linkage.stderr49
-rw-r--r--tests/ui/attributes/lint_on_root.rs1
-rw-r--r--tests/ui/attributes/lint_on_root.stderr10
-rw-r--r--tests/ui/attributes/malformed-attrs.rs5
-rw-r--r--tests/ui/attributes/malformed-attrs.stderr186
-rw-r--r--tests/ui/attributes/malformed-fn-align.rs10
-rw-r--r--tests/ui/attributes/malformed-fn-align.stderr50
-rw-r--r--tests/ui/attributes/multiple-invalid.rs4
-rw-r--r--tests/ui/attributes/multiple-invalid.stderr23
-rw-r--r--tests/ui/attributes/optimize.rs8
-rw-r--r--tests/ui/attributes/optimize.stderr30
-rw-r--r--tests/ui/attributes/positions/used.rs10
-rw-r--r--tests/ui/attributes/positions/used.stderr30
-rw-r--r--tests/ui/attributes/rustc_confusables.rs3
-rw-r--r--tests/ui/attributes/rustc_confusables.stderr4
-rw-r--r--tests/ui/attributes/rustc_skip_during_method_dispatch.rs2
-rw-r--r--tests/ui/attributes/rustc_skip_during_method_dispatch.stderr7
-rw-r--r--tests/ui/coroutine/invalid_attr_usage.rs4
-rw-r--r--tests/ui/coroutine/invalid_attr_usage.stderr8
-rw-r--r--tests/ui/coverage-attr/allowed-positions.rs34
-rw-r--r--tests/ui/coverage-attr/allowed-positions.stderr163
-rw-r--r--tests/ui/coverage-attr/name-value.rs7
-rw-r--r--tests/ui/coverage-attr/name-value.stderr76
-rw-r--r--tests/ui/coverage-attr/word-only.rs7
-rw-r--r--tests/ui/coverage-attr/word-only.stderr76
-rw-r--r--tests/ui/deprecation/deprecation-sanity.rs5
-rw-r--r--tests/ui/deprecation/deprecation-sanity.stderr28
-rw-r--r--tests/ui/error-codes/E0518.rs9
-rw-r--r--tests/ui/error-codes/E0518.stderr20
-rw-r--r--tests/ui/error-codes/E0718.stderr2
-rw-r--r--tests/ui/extern/extern-no-mangle.rs12
-rw-r--r--tests/ui/extern/extern-no-mangle.stderr30
-rw-r--r--tests/ui/extern/issue-47725.rs17
-rw-r--r--tests/ui/extern/issue-47725.stderr34
-rw-r--r--tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs2
-rw-r--r--tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr7
-rw-r--r--tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs50
-rw-r--r--tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr293
-rw-r--r--tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs311
-rw-r--r--tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr1272
-rw-r--r--tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.rs19
-rw-r--r--tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.stderr48
-rw-r--r--tests/ui/ffi-attrs/ffi_const.rs6
-rw-r--r--tests/ui/ffi-attrs/ffi_const.stderr13
-rw-r--r--tests/ui/ffi-attrs/ffi_pure.rs6
-rw-r--r--tests/ui/ffi-attrs/ffi_pure.stderr13
-rw-r--r--tests/ui/force-inlining/invalid.rs60
-rw-r--r--tests/ui/force-inlining/invalid.stderr372
-rw-r--r--tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr19
-rw-r--r--tests/ui/issues/issue-31769.rs2
-rw-r--r--tests/ui/issues/issue-31769.stderr9
-rw-r--r--tests/ui/issues/issue-43988.rs4
-rw-r--r--tests/ui/issues/issue-43988.stderr48
-rw-r--r--tests/ui/issues/issue-78957.rs18
-rw-r--r--tests/ui/issues/issue-78957.stderr84
-rw-r--r--tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.rs6
-rw-r--r--tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.stderr12
-rw-r--r--tests/ui/lint/inline-trait-and-foreign-items.rs18
-rw-r--r--tests/ui/lint/inline-trait-and-foreign-items.stderr75
-rw-r--r--tests/ui/lint/unused/unused-attr-macro-rules.rs6
-rw-r--r--tests/ui/lint/unused/unused-attr-macro-rules.stderr14
-rw-r--r--tests/ui/lint/unused/unused_attributes-must_use.stderr42
-rw-r--r--tests/ui/lint/warn-unused-inline-on-fn-prototypes.rs6
-rw-r--r--tests/ui/lint/warn-unused-inline-on-fn-prototypes.stderr11
-rw-r--r--tests/ui/loop-match/invalid-attribute.rs24
-rw-r--r--tests/ui/loop-match/invalid-attribute.stderr160
-rw-r--r--tests/ui/macros/issue-68060.rs3
-rw-r--r--tests/ui/macros/issue-68060.stderr7
-rw-r--r--tests/ui/marker_trait_attr/marker-attribute-on-non-trait.rs12
-rw-r--r--tests/ui/marker_trait_attr/marker-attribute-on-non-trait.stderr42
-rw-r--r--tests/ui/panic-handler/panic-handler-wrong-location.stderr2
-rw-r--r--tests/ui/proc-macro/illegal-proc-macro-derive-use.rs2
-rw-r--r--tests/ui/proc-macro/illegal-proc-macro-derive-use.stderr4
-rw-r--r--tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.rs4
-rw-r--r--tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr24
-rw-r--r--tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.rs2
-rw-r--r--tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.stderr7
-rw-r--r--tests/ui/rustdoc/check-doc-alias-attr-location.stderr4
-rw-r--r--tests/ui/target-feature/invalid-attribute.rs51
-rw-r--r--tests/ui/target-feature/invalid-attribute.stderr189
-rw-r--r--tests/ui/traits/alias/not-a-marker.rs2
-rw-r--r--tests/ui/traits/alias/not-a-marker.stderr7
-rw-r--r--tests/ui/traits/const-traits/attr-misuse.rs4
-rw-r--r--tests/ui/traits/const-traits/attr-misuse.stderr20
-rw-r--r--tests/ui/unstable-feature-bound/unstable_inherent_method.rs4
-rw-r--r--tests/ui/unstable-feature-bound/unstable_inherent_method.stderr14
-rw-r--r--tests/ui/where-clauses/unsupported_attribute.rs20
-rw-r--r--tests/ui/where-clauses/unsupported_attribute.stderr100
105 files changed, 2449 insertions, 2267 deletions
diff --git a/tests/crashes/138510.rs b/tests/crashes/138510.rs
deleted file mode 100644
index f429e8bb33b..00000000000
--- a/tests/crashes/138510.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-//@ known-bug: #138510
-fn main()
-where
-    #[repr()]
-    _: Sized,
-{
-}
diff --git a/tests/rustdoc-ui/check-doc-alias-attr-location.stderr b/tests/rustdoc-ui/check-doc-alias-attr-location.stderr
index 9d3ce5e63ef..85c9516236c 100644
--- a/tests/rustdoc-ui/check-doc-alias-attr-location.stderr
+++ b/tests/rustdoc-ui/check-doc-alias-attr-location.stderr
@@ -4,13 +4,13 @@ error: `#[doc(alias = "...")]` isn't allowed on foreign module
 LL | #[doc(alias = "foo")]
    |       ^^^^^^^^^^^^^
 
-error: `#[doc(alias = "...")]` isn't allowed on inherent implementation block
+error: `#[doc(alias = "...")]` isn't allowed on implementation block
   --> $DIR/check-doc-alias-attr-location.rs:10:7
    |
 LL | #[doc(alias = "bar")]
    |       ^^^^^^^^^^^^^
 
-error: `#[doc(alias = "...")]` isn't allowed on trait implementation block
+error: `#[doc(alias = "...")]` isn't allowed on implementation block
   --> $DIR/check-doc-alias-attr-location.rs:16:7
    |
 LL | #[doc(alias = "foobar")]
diff --git a/tests/ui/asm/naked-invalid-attr.rs b/tests/ui/asm/naked-invalid-attr.rs
index 6ac9cb9e3a9..c9e0949abfb 100644
--- a/tests/ui/asm/naked-invalid-attr.rs
+++ b/tests/ui/asm/naked-invalid-attr.rs
@@ -1,25 +1,25 @@
 // Checks that the #[unsafe(naked)] attribute can be placed on function definitions only.
 //
 //@ needs-asm-support
-#![unsafe(naked)] //~ ERROR should be applied to a function definition
+#![unsafe(naked)] //~ ERROR attribute cannot be used on
 
 use std::arch::naked_asm;
 
 extern "C" {
-    #[unsafe(naked)] //~ ERROR should be applied to a function definition
+    #[unsafe(naked)] //~ ERROR attribute cannot be used on
     fn f();
 }
 
-#[unsafe(naked)] //~ ERROR should be applied to a function definition
+#[unsafe(naked)] //~ ERROR attribute cannot be used on
 #[repr(C)]
 struct S {
-    #[unsafe(naked)] //~ ERROR should be applied to a function definition
+    #[unsafe(naked)] //~ ERROR attribute cannot be used on
     a: u32,
     b: u32,
 }
 
 trait Invoke {
-    #[unsafe(naked)] //~ ERROR should be applied to a function definition
+    #[unsafe(naked)] //~ ERROR attribute cannot be used on
     extern "C" fn invoke(&self);
 }
 
@@ -48,7 +48,7 @@ impl S {
 }
 
 fn main() {
-    #[unsafe(naked)] //~ ERROR should be applied to a function definition
+    #[unsafe(naked)] //~ ERROR attribute cannot be used on
     || {};
 }
 
diff --git a/tests/ui/asm/naked-invalid-attr.stderr b/tests/ui/asm/naked-invalid-attr.stderr
index 2571c8fa989..936a36cd92e 100644
--- a/tests/ui/asm/naked-invalid-attr.stderr
+++ b/tests/ui/asm/naked-invalid-attr.stderr
@@ -4,65 +4,62 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `a`
 LL | #[::a]
    |     ^ use of unresolved module or unlinked crate `a`
 
-error[E0736]: attribute incompatible with `#[unsafe(naked)]`
-  --> $DIR/naked-invalid-attr.rs:56:3
+error: `#[naked]` attribute cannot be used on crates
+  --> $DIR/naked-invalid-attr.rs:4:1
    |
-LL | #[::a]
-   |   ^^^ the `::a` attribute is incompatible with `#[unsafe(naked)]`
-...
-LL | #[unsafe(naked)]
-   | ---------------- function marked with `#[unsafe(naked)]` here
-
-error: attribute should be applied to a function definition
-  --> $DIR/naked-invalid-attr.rs:13:1
+LL | #![unsafe(naked)]
+   | ^^^^^^^^^^^^^^^^^
    |
-LL |   #[unsafe(naked)]
-   |   ^^^^^^^^^^^^^^^^
-LL |   #[repr(C)]
-LL | / struct S {
-LL | |     #[unsafe(naked)]
-LL | |     a: u32,
-LL | |     b: u32,
-LL | | }
-   | |_- not a function definition
+   = help: `#[naked]` can only be applied to functions
 
-error: attribute should be applied to a function definition
-  --> $DIR/naked-invalid-attr.rs:16:5
+error: `#[naked]` attribute cannot be used on foreign functions
+  --> $DIR/naked-invalid-attr.rs:9:5
    |
 LL |     #[unsafe(naked)]
    |     ^^^^^^^^^^^^^^^^
-LL |     a: u32,
-   |     ------ not a function definition
+   |
+   = help: `#[naked]` can be applied to methods, functions
 
-error: attribute should be applied to a function definition
-  --> $DIR/naked-invalid-attr.rs:51:5
+error: `#[naked]` attribute cannot be used on structs
+  --> $DIR/naked-invalid-attr.rs:13:1
+   |
+LL | #[unsafe(naked)]
+   | ^^^^^^^^^^^^^^^^
+   |
+   = help: `#[naked]` can only be applied to functions
+
+error: `#[naked]` attribute cannot be used on struct fields
+  --> $DIR/naked-invalid-attr.rs:16:5
    |
 LL |     #[unsafe(naked)]
    |     ^^^^^^^^^^^^^^^^
-LL |     || {};
-   |     ----- not a function definition
+   |
+   = help: `#[naked]` can only be applied to functions
 
-error: attribute should be applied to a function definition
+error: `#[naked]` attribute cannot be used on required trait methods
   --> $DIR/naked-invalid-attr.rs:22:5
    |
 LL |     #[unsafe(naked)]
    |     ^^^^^^^^^^^^^^^^
-LL |     extern "C" fn invoke(&self);
-   |     ---------------------------- not a function definition
+   |
+   = help: `#[naked]` can be applied to functions, inherent methods, provided trait methods, trait methods in impl blocks
 
-error: attribute should be applied to a function definition
-  --> $DIR/naked-invalid-attr.rs:9:5
+error: `#[naked]` attribute cannot be used on closures
+  --> $DIR/naked-invalid-attr.rs:51:5
    |
 LL |     #[unsafe(naked)]
    |     ^^^^^^^^^^^^^^^^
-LL |     fn f();
-   |     ------- not a function definition
+   |
+   = help: `#[naked]` can be applied to methods, functions
 
-error: attribute should be applied to a function definition
-  --> $DIR/naked-invalid-attr.rs:4:1
+error[E0736]: attribute incompatible with `#[unsafe(naked)]`
+  --> $DIR/naked-invalid-attr.rs:56:3
    |
-LL | #![unsafe(naked)]
-   | ^^^^^^^^^^^^^^^^^ cannot be applied to crates
+LL | #[::a]
+   |   ^^^ the `::a` attribute is incompatible with `#[unsafe(naked)]`
+...
+LL | #[unsafe(naked)]
+   | ---------------- function marked with `#[unsafe(naked)]` here
 
 error: aborting due to 8 previous errors
 
diff --git a/tests/ui/attributes/attrs-on-params.rs b/tests/ui/attributes/attrs-on-params.rs
index 158a4500bde..c8e9810327c 100644
--- a/tests/ui/attributes/attrs-on-params.rs
+++ b/tests/ui/attributes/attrs-on-params.rs
@@ -1,7 +1,7 @@
 // This checks that incorrect params on function parameters are caught
 
 fn function(#[inline] param: u32) {
-    //~^ ERROR attribute should be applied to function or closure
+    //~^ ERROR attribute cannot be used on
     //~| ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes
 }
 
diff --git a/tests/ui/attributes/attrs-on-params.stderr b/tests/ui/attributes/attrs-on-params.stderr
index 306e862cb58..91f87a954c5 100644
--- a/tests/ui/attributes/attrs-on-params.stderr
+++ b/tests/ui/attributes/attrs-on-params.stderr
@@ -4,14 +4,13 @@ error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed
 LL | fn function(#[inline] param: u32) {
    |             ^^^^^^^^^
 
-error[E0518]: attribute should be applied to function or closure
+error: `#[inline]` attribute cannot be used on function params
   --> $DIR/attrs-on-params.rs:3:13
    |
 LL | fn function(#[inline] param: u32) {
-   |             ^^^^^^^^^-----------
-   |             |
-   |             not a function or closure
+   |             ^^^^^^^^^
+   |
+   = help: `#[inline]` can only be applied to functions
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0518`.
diff --git a/tests/ui/attributes/cold-attribute-application-54044.rs b/tests/ui/attributes/cold-attribute-application-54044.rs
index 2e644b91c07..cf027ac02b0 100644
--- a/tests/ui/attributes/cold-attribute-application-54044.rs
+++ b/tests/ui/attributes/cold-attribute-application-54044.rs
@@ -2,13 +2,13 @@
 #![deny(unused_attributes)] //~ NOTE lint level is defined here
 
 #[cold]
-//~^ ERROR attribute should be applied to a function
-//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-struct Foo; //~ NOTE not a function
+//~^ ERROR attribute cannot be used on
+//~| WARN previously accepted
+struct Foo;
 
 fn main() {
     #[cold]
-    //~^ ERROR attribute should be applied to a function
-    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-    5; //~ NOTE not a function
+    //~^ ERROR attribute cannot be used on
+    //~| WARN previously accepted
+    5;
 }
diff --git a/tests/ui/attributes/cold-attribute-application-54044.stderr b/tests/ui/attributes/cold-attribute-application-54044.stderr
index efdf5e0de52..367686f02cb 100644
--- a/tests/ui/attributes/cold-attribute-application-54044.stderr
+++ b/tests/ui/attributes/cold-attribute-application-54044.stderr
@@ -1,29 +1,25 @@
-error: attribute should be applied to a function definition
+error: `#[cold]` attribute cannot be used on structs
   --> $DIR/cold-attribute-application-54044.rs:4:1
    |
 LL | #[cold]
    | ^^^^^^^
-...
-LL | struct Foo;
-   | ----------- not a function definition
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[cold]` can only be applied to functions
 note: the lint level is defined here
   --> $DIR/cold-attribute-application-54044.rs:2:9
    |
 LL | #![deny(unused_attributes)]
    |         ^^^^^^^^^^^^^^^^^
 
-error: attribute should be applied to a function definition
+error: `#[cold]` attribute cannot be used on expressions
   --> $DIR/cold-attribute-application-54044.rs:10:5
    |
 LL |     #[cold]
    |     ^^^^^^^
-...
-LL |     5;
-   |     - not a function definition
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[cold]` can only be applied to functions
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/attributes/empty-repr.rs b/tests/ui/attributes/empty-repr.rs
new file mode 100644
index 00000000000..e6ba1baf031
--- /dev/null
+++ b/tests/ui/attributes/empty-repr.rs
@@ -0,0 +1,14 @@
+// Regression test for https://github.com/rust-lang/rust/issues/138510
+
+#![feature(where_clause_attrs)]
+#![deny(unused_attributes)]
+
+fn main() {
+}
+
+fn test() where
+#[repr()]
+//~^ ERROR unused attribute
+(): Sized {
+
+}
diff --git a/tests/ui/attributes/empty-repr.stderr b/tests/ui/attributes/empty-repr.stderr
new file mode 100644
index 00000000000..92901fa170c
--- /dev/null
+++ b/tests/ui/attributes/empty-repr.stderr
@@ -0,0 +1,14 @@
+error: unused attribute
+  --> $DIR/empty-repr.rs:10:1
+   |
+LL | #[repr()]
+   | ^^^^^^^^^ help: remove this attribute
+   |
+note: the lint level is defined here
+  --> $DIR/empty-repr.rs:4:9
+   |
+LL | #![deny(unused_attributes)]
+   |         ^^^^^^^^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/attributes/inline-attribute-enum-variant-error.rs b/tests/ui/attributes/inline-attribute-enum-variant-error.rs
index 305b285d2a4..fd2cd49be16 100644
--- a/tests/ui/attributes/inline-attribute-enum-variant-error.rs
+++ b/tests/ui/attributes/inline-attribute-enum-variant-error.rs
@@ -2,7 +2,7 @@
 
 enum Foo {
     #[inline]
-    //~^ ERROR attribute should be applied
+    //~^ ERROR attribute cannot be used on
     Variant,
 }
 
diff --git a/tests/ui/attributes/inline-attribute-enum-variant-error.stderr b/tests/ui/attributes/inline-attribute-enum-variant-error.stderr
index a4564d8f722..03954388c2e 100644
--- a/tests/ui/attributes/inline-attribute-enum-variant-error.stderr
+++ b/tests/ui/attributes/inline-attribute-enum-variant-error.stderr
@@ -1,12 +1,10 @@
-error[E0518]: attribute should be applied to function or closure
+error: `#[inline]` attribute cannot be used on enum variants
   --> $DIR/inline-attribute-enum-variant-error.rs:4:5
    |
 LL |     #[inline]
    |     ^^^^^^^^^
-LL |
-LL |     Variant,
-   |     ------- not a function or closure
+   |
+   = help: `#[inline]` can only be applied to functions
 
 error: aborting due to 1 previous error
 
-For more information about this error, try `rustc --explain E0518`.
diff --git a/tests/ui/attributes/inline/attr-usage-inline.rs b/tests/ui/attributes/inline/attr-usage-inline.rs
index d8ca0fce163..8217b9834ff 100644
--- a/tests/ui/attributes/inline/attr-usage-inline.rs
+++ b/tests/ui/attributes/inline/attr-usage-inline.rs
@@ -4,7 +4,7 @@
 #[inline]
 fn f() {}
 
-#[inline] //~ ERROR: attribute should be applied to function or closure
+#[inline] //~ ERROR: attribute cannot be used on
 struct S;
 
 struct I {
diff --git a/tests/ui/attributes/inline/attr-usage-inline.stderr b/tests/ui/attributes/inline/attr-usage-inline.stderr
index 2123438032c..9fca17d90ca 100644
--- a/tests/ui/attributes/inline/attr-usage-inline.stderr
+++ b/tests/ui/attributes/inline/attr-usage-inline.stderr
@@ -1,10 +1,10 @@
-error[E0518]: attribute should be applied to function or closure
+error: `#[inline]` attribute cannot be used on structs
   --> $DIR/attr-usage-inline.rs:7:1
    |
 LL | #[inline]
    | ^^^^^^^^^
-LL | struct S;
-   | --------- not a function or closure
+   |
+   = 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
diff --git a/tests/ui/attributes/issue-105594-invalid-attr-validation.rs b/tests/ui/attributes/issue-105594-invalid-attr-validation.rs
index cb196471fd7..f9e01cd1507 100644
--- a/tests/ui/attributes/issue-105594-invalid-attr-validation.rs
+++ b/tests/ui/attributes/issue-105594-invalid-attr-validation.rs
@@ -3,5 +3,5 @@
 
 fn main() {}
 
-#[track_caller] //~ ERROR attribute should be applied to a function
+#[track_caller] //~ ERROR attribute cannot be used on
 static _A: () = ();
diff --git a/tests/ui/attributes/issue-105594-invalid-attr-validation.stderr b/tests/ui/attributes/issue-105594-invalid-attr-validation.stderr
index 1248967c47b..337d3808d28 100644
--- a/tests/ui/attributes/issue-105594-invalid-attr-validation.stderr
+++ b/tests/ui/attributes/issue-105594-invalid-attr-validation.stderr
@@ -1,11 +1,10 @@
-error[E0739]: attribute should be applied to a function definition
+error: `#[track_caller]` attribute cannot be used on statics
   --> $DIR/issue-105594-invalid-attr-validation.rs:6:1
    |
 LL | #[track_caller]
    | ^^^^^^^^^^^^^^^
-LL | static _A: () = ();
-   | ------------------- not a function definition
+   |
+   = help: `#[track_caller]` can only be applied to functions
 
 error: aborting due to 1 previous error
 
-For more information about this error, try `rustc --explain E0739`.
diff --git a/tests/ui/attributes/linkage.rs b/tests/ui/attributes/linkage.rs
index 0d5ce699fa8..932bfa88fc5 100644
--- a/tests/ui/attributes/linkage.rs
+++ b/tests/ui/attributes/linkage.rs
@@ -3,16 +3,16 @@
 #![deny(unused_attributes)]
 #![allow(dead_code)]
 
-#[linkage = "weak"] //~ ERROR attribute should be applied to a function or static
+#[linkage = "weak"] //~ ERROR attribute cannot be used on
 type InvalidTy = ();
 
-#[linkage = "weak"] //~ ERROR attribute should be applied to a function or static
+#[linkage = "weak"] //~ ERROR attribute cannot be used on
 mod invalid_module {}
 
-#[linkage = "weak"] //~ ERROR attribute should be applied to a function or static
+#[linkage = "weak"] //~ ERROR attribute cannot be used on
 struct F;
 
-#[linkage = "weak"] //~ ERROR attribute should be applied to a function or static
+#[linkage = "weak"] //~ ERROR attribute cannot be used on
 impl F {
     #[linkage = "weak"]
     fn valid(&self) {}
@@ -24,7 +24,7 @@ fn f() {
     {
         1
     };
-    //~^^^^ ERROR attribute should be applied to a function or static
+    //~^^^^ ERROR attribute cannot be used on
 }
 
 extern "C" {
@@ -38,5 +38,5 @@ extern "C" {
 fn main() {
     let _ = #[linkage = "weak"]
     (|| 1);
-    //~^^ ERROR attribute should be applied to a function or static
+    //~^^ ERROR attribute cannot be used on
 }
diff --git a/tests/ui/attributes/linkage.stderr b/tests/ui/attributes/linkage.stderr
index d5595529f40..2e7ff0e7936 100644
--- a/tests/ui/attributes/linkage.stderr
+++ b/tests/ui/attributes/linkage.stderr
@@ -1,55 +1,50 @@
-error: attribute should be applied to a function or static
+error: `#[linkage]` attribute cannot be used on type aliases
   --> $DIR/linkage.rs:6:1
    |
 LL | #[linkage = "weak"]
    | ^^^^^^^^^^^^^^^^^^^
-LL | type InvalidTy = ();
-   | -------------------- not a function definition or static
+   |
+   = help: `#[linkage]` can be applied to functions, statics, foreign statics
 
-error: attribute should be applied to a function or static
+error: `#[linkage]` attribute cannot be used on modules
   --> $DIR/linkage.rs:9:1
    |
 LL | #[linkage = "weak"]
    | ^^^^^^^^^^^^^^^^^^^
-LL | mod invalid_module {}
-   | --------------------- not a function definition or static
+   |
+   = help: `#[linkage]` can be applied to functions, statics, foreign statics
 
-error: attribute should be applied to a function or static
+error: `#[linkage]` attribute cannot be used on structs
   --> $DIR/linkage.rs:12:1
    |
 LL | #[linkage = "weak"]
    | ^^^^^^^^^^^^^^^^^^^
-LL | struct F;
-   | --------- not a function definition or static
+   |
+   = help: `#[linkage]` can be applied to functions, statics, foreign statics
 
-error: attribute should be applied to a function or static
+error: `#[linkage]` attribute cannot be used on inherent impl blocks
   --> $DIR/linkage.rs:15:1
    |
-LL |   #[linkage = "weak"]
-   |   ^^^^^^^^^^^^^^^^^^^
-LL | / impl F {
-LL | |     #[linkage = "weak"]
-LL | |     fn valid(&self) {}
-LL | | }
-   | |_- not a function definition or static
+LL | #[linkage = "weak"]
+   | ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[linkage]` can be applied to functions, statics, foreign statics
 
-error: attribute should be applied to a function or static
+error: `#[linkage]` attribute cannot be used on expressions
   --> $DIR/linkage.rs:23:5
    |
-LL |       #[linkage = "weak"]
-   |       ^^^^^^^^^^^^^^^^^^^
-LL | /     {
-LL | |         1
-LL | |     };
-   | |_____- not a function definition or static
+LL |     #[linkage = "weak"]
+   |     ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[linkage]` can be applied to functions, statics, foreign statics
 
-error: attribute should be applied to a function or static
+error: `#[linkage]` attribute cannot be used on closures
   --> $DIR/linkage.rs:39:13
    |
 LL |     let _ = #[linkage = "weak"]
    |             ^^^^^^^^^^^^^^^^^^^
-LL |     (|| 1);
-   |     ------ not a function definition or static
+   |
+   = help: `#[linkage]` can be applied to methods, functions, statics, foreign statics, foreign functions
 
 error: aborting due to 6 previous errors
 
diff --git a/tests/ui/attributes/lint_on_root.rs b/tests/ui/attributes/lint_on_root.rs
index 9029da7dc97..bafdb46883f 100644
--- a/tests/ui/attributes/lint_on_root.rs
+++ b/tests/ui/attributes/lint_on_root.rs
@@ -3,5 +3,6 @@
 #![inline = ""]
 //~^ ERROR: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]` [ill_formed_attribute_input]
 //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+//~| ERROR attribute cannot be used on
 
 fn main() {}
diff --git a/tests/ui/attributes/lint_on_root.stderr b/tests/ui/attributes/lint_on_root.stderr
index 91b72730530..9d8d1495c1b 100644
--- a/tests/ui/attributes/lint_on_root.stderr
+++ b/tests/ui/attributes/lint_on_root.stderr
@@ -1,3 +1,11 @@
+error: `#[inline]` attribute cannot be used on crates
+  --> $DIR/lint_on_root.rs:3:1
+   |
+LL | #![inline = ""]
+   | ^^^^^^^^^^^^^^^
+   |
+   = help: `#[inline]` can only be applied to functions
+
 error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]`
   --> $DIR/lint_on_root.rs:3:1
    |
@@ -8,7 +16,7 @@ LL | #![inline = ""]
    = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
    = note: `#[deny(ill_formed_attribute_input)]` on by default
 
-error: aborting due to 1 previous error
+error: aborting due to 2 previous errors
 
 Future incompatibility report: Future breakage diagnostic:
 error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]`
diff --git a/tests/ui/attributes/malformed-attrs.rs b/tests/ui/attributes/malformed-attrs.rs
index 3261b29fe7e..3293f75fba9 100644
--- a/tests/ui/attributes/malformed-attrs.rs
+++ b/tests/ui/attributes/malformed-attrs.rs
@@ -35,6 +35,7 @@
 //~^ ERROR `allow_internal_unstable` expects a list of feature names
 #[rustc_confusables]
 //~^ ERROR malformed
+//~| ERROR attribute cannot be used on
 #[deprecated = 5]
 //~^ ERROR malformed
 #[doc]
@@ -42,9 +43,10 @@
 //~| WARN this was previously accepted by the compiler
 #[rustc_macro_transparency]
 //~^ ERROR malformed
+//~| ERROR attribute cannot be used on
 #[repr]
 //~^ ERROR malformed
-//~| ERROR is not supported on function items
+//~| ERROR is not supported on functions
 #[rustc_as_ptr = 5]
 //~^ ERROR malformed
 #[inline = 5]
@@ -68,6 +70,7 @@
 //~^ ERROR malformed
 #[used()]
 //~^ ERROR malformed
+//~| ERROR attribute cannot be used on
 #[crate_name]
 //~^ ERROR malformed
 #[doc]
diff --git a/tests/ui/attributes/malformed-attrs.stderr b/tests/ui/attributes/malformed-attrs.stderr
index aa4891459aa..9c31765149b 100644
--- a/tests/ui/attributes/malformed-attrs.stderr
+++ b/tests/ui/attributes/malformed-attrs.stderr
@@ -1,5 +1,5 @@
 error[E0539]: malformed `cfg` attribute input
-  --> $DIR/malformed-attrs.rs:99:1
+  --> $DIR/malformed-attrs.rs:102:1
    |
 LL | #[cfg]
    | ^^^^^^
@@ -10,7 +10,7 @@ LL | #[cfg]
    = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute>
 
 error: malformed `cfg_attr` attribute input
-  --> $DIR/malformed-attrs.rs:101:1
+  --> $DIR/malformed-attrs.rs:104:1
    |
 LL | #[cfg_attr]
    | ^^^^^^^^^^^
@@ -22,7 +22,7 @@ LL | #[cfg_attr(condition, attribute, other_attribute, ...)]
    |           ++++++++++++++++++++++++++++++++++++++++++++
 
 error[E0463]: can't find crate for `wloop`
-  --> $DIR/malformed-attrs.rs:208:1
+  --> $DIR/malformed-attrs.rs:211:1
    |
 LL | extern crate wloop;
    | ^^^^^^^^^^^^^^^^^^^ can't find crate
@@ -42,7 +42,7 @@ LL | #![windows_subsystem = "windows"]
    |                      +++++++++++
 
 error: malformed `crate_name` attribute input
-  --> $DIR/malformed-attrs.rs:71:1
+  --> $DIR/malformed-attrs.rs:74:1
    |
 LL | #[crate_name]
    | ^^^^^^^^^^^^^ help: must be of the form: `#[crate_name = "name"]`
@@ -50,13 +50,13 @@ LL | #[crate_name]
    = note: for more information, visit <https://doc.rust-lang.org/reference/crates-and-source-files.html#the-crate_name-attribute>
 
 error: malformed `no_sanitize` attribute input
-  --> $DIR/malformed-attrs.rs:89:1
+  --> $DIR/malformed-attrs.rs:92:1
    |
 LL | #[no_sanitize]
    | ^^^^^^^^^^^^^^ help: must be of the form: `#[no_sanitize(address, kcfi, memory, thread)]`
 
 error: malformed `instruction_set` attribute input
-  --> $DIR/malformed-attrs.rs:103:1
+  --> $DIR/malformed-attrs.rs:106:1
    |
 LL | #[instruction_set]
    | ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[instruction_set(set)]`
@@ -64,13 +64,13 @@ LL | #[instruction_set]
    = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/codegen.html#the-instruction_set-attribute>
 
 error: malformed `patchable_function_entry` attribute input
-  --> $DIR/malformed-attrs.rs:105:1
+  --> $DIR/malformed-attrs.rs:108:1
    |
 LL | #[patchable_function_entry]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]`
 
 error: malformed `must_not_suspend` attribute input
-  --> $DIR/malformed-attrs.rs:129:1
+  --> $DIR/malformed-attrs.rs:132:1
    |
 LL | #[must_not_suspend()]
    | ^^^^^^^^^^^^^^^^^^^^^
@@ -85,13 +85,13 @@ LL + #[must_not_suspend]
    |
 
 error: malformed `cfi_encoding` attribute input
-  --> $DIR/malformed-attrs.rs:131:1
+  --> $DIR/malformed-attrs.rs:134:1
    |
 LL | #[cfi_encoding]
    | ^^^^^^^^^^^^^^^ help: must be of the form: `#[cfi_encoding = "encoding"]`
 
 error: malformed `allow` attribute input
-  --> $DIR/malformed-attrs.rs:175:1
+  --> $DIR/malformed-attrs.rs:178:1
    |
 LL | #[allow]
    | ^^^^^^^^
@@ -107,7 +107,7 @@ LL | #[allow(lint1, lint2, lint3, reason = "...")]
    |        +++++++++++++++++++++++++++++++++++++
 
 error: malformed `expect` attribute input
-  --> $DIR/malformed-attrs.rs:177:1
+  --> $DIR/malformed-attrs.rs:180:1
    |
 LL | #[expect]
    | ^^^^^^^^^
@@ -123,7 +123,7 @@ LL | #[expect(lint1, lint2, lint3, reason = "...")]
    |         +++++++++++++++++++++++++++++++++++++
 
 error: malformed `warn` attribute input
-  --> $DIR/malformed-attrs.rs:179:1
+  --> $DIR/malformed-attrs.rs:182:1
    |
 LL | #[warn]
    | ^^^^^^^
@@ -139,7 +139,7 @@ LL | #[warn(lint1, lint2, lint3, reason = "...")]
    |       +++++++++++++++++++++++++++++++++++++
 
 error: malformed `deny` attribute input
-  --> $DIR/malformed-attrs.rs:181:1
+  --> $DIR/malformed-attrs.rs:184:1
    |
 LL | #[deny]
    | ^^^^^^^
@@ -155,7 +155,7 @@ LL | #[deny(lint1, lint2, lint3, reason = "...")]
    |       +++++++++++++++++++++++++++++++++++++
 
 error: malformed `forbid` attribute input
-  --> $DIR/malformed-attrs.rs:183:1
+  --> $DIR/malformed-attrs.rs:186:1
    |
 LL | #[forbid]
    | ^^^^^^^^^
@@ -171,7 +171,7 @@ LL | #[forbid(lint1, lint2, lint3, reason = "...")]
    |         +++++++++++++++++++++++++++++++++++++
 
 error: malformed `debugger_visualizer` attribute input
-  --> $DIR/malformed-attrs.rs:185:1
+  --> $DIR/malformed-attrs.rs:188:1
    |
 LL | #[debugger_visualizer]
    | ^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[debugger_visualizer(natvis_file = "...", gdb_script_file = "...")]`
@@ -179,13 +179,13 @@ LL | #[debugger_visualizer]
    = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/debugger.html#the-debugger_visualizer-attribute>
 
 error: malformed `thread_local` attribute input
-  --> $DIR/malformed-attrs.rs:200:1
+  --> $DIR/malformed-attrs.rs:203:1
    |
 LL | #[thread_local()]
    | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[thread_local]`
 
 error: malformed `no_link` attribute input
-  --> $DIR/malformed-attrs.rs:204:1
+  --> $DIR/malformed-attrs.rs:207:1
    |
 LL | #[no_link()]
    | ^^^^^^^^^^^^ help: must be of the form: `#[no_link]`
@@ -193,7 +193,7 @@ LL | #[no_link()]
    = note: for more information, visit <https://doc.rust-lang.org/reference/items/extern-crates.html#the-no_link-attribute>
 
 error: malformed `macro_export` attribute input
-  --> $DIR/malformed-attrs.rs:211:1
+  --> $DIR/malformed-attrs.rs:214:1
    |
 LL | #[macro_export = 18]
    | ^^^^^^^^^^^^^^^^^^^^
@@ -209,25 +209,25 @@ LL + #[macro_export]
    |
 
 error: the `#[proc_macro]` attribute is only usable with crates of the `proc-macro` crate type
-  --> $DIR/malformed-attrs.rs:96:1
+  --> $DIR/malformed-attrs.rs:99:1
    |
 LL | #[proc_macro = 18]
    | ^^^^^^^^^^^^^^^^^^
 
 error: the `#[proc_macro_attribute]` attribute is only usable with crates of the `proc-macro` crate type
-  --> $DIR/malformed-attrs.rs:113:1
+  --> $DIR/malformed-attrs.rs:116:1
    |
 LL | #[proc_macro_attribute = 19]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type
-  --> $DIR/malformed-attrs.rs:120:1
+  --> $DIR/malformed-attrs.rs:123:1
    |
 LL | #[proc_macro_derive]
    | ^^^^^^^^^^^^^^^^^^^^
 
 error[E0658]: allow_internal_unsafe side-steps the unsafe_code lint
-  --> $DIR/malformed-attrs.rs:213:1
+  --> $DIR/malformed-attrs.rs:216:1
    |
 LL | #[allow_internal_unsafe = 1]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -236,7 +236,7 @@ LL | #[allow_internal_unsafe = 1]
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
 
 error: valid forms for the attribute are `#[doc(hidden)]`, `#[doc(inline)]`, and `#[doc = "string"]`
-  --> $DIR/malformed-attrs.rs:40:1
+  --> $DIR/malformed-attrs.rs:41:1
    |
 LL | #[doc]
    | ^^^^^^
@@ -247,7 +247,7 @@ LL | #[doc]
    = note: `#[deny(ill_formed_attribute_input)]` on by default
 
 error: valid forms for the attribute are `#[doc(hidden)]`, `#[doc(inline)]`, and `#[doc = "string"]`
-  --> $DIR/malformed-attrs.rs:73:1
+  --> $DIR/malformed-attrs.rs:76:1
    |
 LL | #[doc]
    | ^^^^^^
@@ -257,7 +257,7 @@ LL | #[doc]
    = note: for more information, visit <https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html>
 
 error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]`
-  --> $DIR/malformed-attrs.rs:80:1
+  --> $DIR/malformed-attrs.rs:83:1
    |
 LL | #[link]
    | ^^^^^^^
@@ -267,7 +267,7 @@ LL | #[link]
    = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute>
 
 error: invalid argument
-  --> $DIR/malformed-attrs.rs:185:1
+  --> $DIR/malformed-attrs.rs:188:1
    |
 LL | #[debugger_visualizer]
    | ^^^^^^^^^^^^^^^^^^^^^^
@@ -303,8 +303,16 @@ LL | #[rustc_confusables]
    | expected this to be a list
    | help: must be of the form: `#[rustc_confusables("name1", "name2", ...)]`
 
+error: `#[rustc_confusables]` attribute cannot be used on functions
+  --> $DIR/malformed-attrs.rs:36:1
+   |
+LL | #[rustc_confusables]
+   | ^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[rustc_confusables]` can only be applied to inherent methods
+
 error[E0539]: malformed `deprecated` attribute input
-  --> $DIR/malformed-attrs.rs:38:1
+  --> $DIR/malformed-attrs.rs:39:1
    |
 LL | #[deprecated = 5]
    | ^^^^^^^^^^^^^^^-^
@@ -328,7 +336,7 @@ LL + #[deprecated(since = "version", note = "reason")]
    = and 1 other candidate
 
 error[E0539]: malformed `rustc_macro_transparency` attribute input
-  --> $DIR/malformed-attrs.rs:43:1
+  --> $DIR/malformed-attrs.rs:44:1
    |
 LL | #[rustc_macro_transparency]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -342,8 +350,16 @@ LL | #[rustc_macro_transparency = "semitransparent"]
 LL | #[rustc_macro_transparency = "transparent"]
    |                            +++++++++++++++
 
+error: `#[rustc_macro_transparency]` attribute cannot be used on functions
+  --> $DIR/malformed-attrs.rs:44:1
+   |
+LL | #[rustc_macro_transparency]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[rustc_macro_transparency]` can only be applied to macro defs
+
 error[E0539]: malformed `repr` attribute input
-  --> $DIR/malformed-attrs.rs:45:1
+  --> $DIR/malformed-attrs.rs:47:1
    |
 LL | #[repr]
    | ^^^^^^^ expected this to be a list
@@ -362,7 +378,7 @@ LL | #[repr(align(...))]
    = and 2 other candidates
 
 error[E0565]: malformed `rustc_as_ptr` attribute input
-  --> $DIR/malformed-attrs.rs:48:1
+  --> $DIR/malformed-attrs.rs:50:1
    |
 LL | #[rustc_as_ptr = 5]
    | ^^^^^^^^^^^^^^^---^
@@ -371,7 +387,7 @@ LL | #[rustc_as_ptr = 5]
    | help: must be of the form: `#[rustc_as_ptr]`
 
 error[E0539]: malformed `rustc_align` attribute input
-  --> $DIR/malformed-attrs.rs:53:1
+  --> $DIR/malformed-attrs.rs:55:1
    |
 LL | #[rustc_align]
    | ^^^^^^^^^^^^^^
@@ -380,7 +396,7 @@ LL | #[rustc_align]
    | help: must be of the form: `#[rustc_align(<alignment in bytes>)]`
 
 error[E0539]: malformed `optimize` attribute input
-  --> $DIR/malformed-attrs.rs:55:1
+  --> $DIR/malformed-attrs.rs:57:1
    |
 LL | #[optimize]
    | ^^^^^^^^^^^ expected this to be a list
@@ -395,7 +411,7 @@ LL | #[optimize(speed)]
    |           +++++++
 
 error[E0565]: malformed `cold` attribute input
-  --> $DIR/malformed-attrs.rs:57:1
+  --> $DIR/malformed-attrs.rs:59:1
    |
 LL | #[cold = 1]
    | ^^^^^^^---^
@@ -404,13 +420,13 @@ LL | #[cold = 1]
    | help: must be of the form: `#[cold]`
 
 error: valid forms for the attribute are `#[must_use = "reason"]` and `#[must_use]`
-  --> $DIR/malformed-attrs.rs:59:1
+  --> $DIR/malformed-attrs.rs:61:1
    |
 LL | #[must_use()]
    | ^^^^^^^^^^^^^
 
 error[E0565]: malformed `no_mangle` attribute input
-  --> $DIR/malformed-attrs.rs:61:1
+  --> $DIR/malformed-attrs.rs:63:1
    |
 LL | #[no_mangle = 1]
    | ^^^^^^^^^^^^---^
@@ -419,7 +435,7 @@ LL | #[no_mangle = 1]
    | help: must be of the form: `#[no_mangle]`
 
 error[E0565]: malformed `naked` attribute input
-  --> $DIR/malformed-attrs.rs:63:1
+  --> $DIR/malformed-attrs.rs:65:1
    |
 LL | #[unsafe(naked())]
    | ^^^^^^^^^^^^^^--^^
@@ -428,7 +444,7 @@ LL | #[unsafe(naked())]
    | help: must be of the form: `#[naked]`
 
 error[E0565]: malformed `track_caller` attribute input
-  --> $DIR/malformed-attrs.rs:65:1
+  --> $DIR/malformed-attrs.rs:67:1
    |
 LL | #[track_caller()]
    | ^^^^^^^^^^^^^^--^
@@ -437,13 +453,13 @@ LL | #[track_caller()]
    | help: must be of the form: `#[track_caller]`
 
 error[E0539]: malformed `export_name` attribute input
-  --> $DIR/malformed-attrs.rs:67:1
+  --> $DIR/malformed-attrs.rs:69:1
    |
 LL | #[export_name()]
    | ^^^^^^^^^^^^^^^^ help: must be of the form: `#[export_name = "name"]`
 
 error[E0805]: malformed `used` attribute input
-  --> $DIR/malformed-attrs.rs:69:1
+  --> $DIR/malformed-attrs.rs:71:1
    |
 LL | #[used()]
    | ^^^^^^--^
@@ -460,8 +476,16 @@ LL - #[used()]
 LL + #[used]
    |
 
+error: `#[used]` attribute cannot be used on functions
+  --> $DIR/malformed-attrs.rs:71:1
+   |
+LL | #[used()]
+   | ^^^^^^^^^
+   |
+   = help: `#[used]` can only be applied to statics
+
 error[E0539]: malformed `target_feature` attribute input
-  --> $DIR/malformed-attrs.rs:76:1
+  --> $DIR/malformed-attrs.rs:79:1
    |
 LL | #[target_feature]
    | ^^^^^^^^^^^^^^^^^
@@ -470,7 +494,7 @@ LL | #[target_feature]
    | help: must be of the form: `#[target_feature(enable = "feat1, feat2")]`
 
 error[E0565]: malformed `export_stable` attribute input
-  --> $DIR/malformed-attrs.rs:78:1
+  --> $DIR/malformed-attrs.rs:81:1
    |
 LL | #[export_stable = 1]
    | ^^^^^^^^^^^^^^^^---^
@@ -479,7 +503,7 @@ LL | #[export_stable = 1]
    | help: must be of the form: `#[export_stable]`
 
 error[E0539]: malformed `link_name` attribute input
-  --> $DIR/malformed-attrs.rs:83:1
+  --> $DIR/malformed-attrs.rs:86:1
    |
 LL | #[link_name]
    | ^^^^^^^^^^^^ help: must be of the form: `#[link_name = "name"]`
@@ -487,7 +511,7 @@ LL | #[link_name]
    = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_name-attribute>
 
 error[E0539]: malformed `link_section` attribute input
-  --> $DIR/malformed-attrs.rs:85:1
+  --> $DIR/malformed-attrs.rs:88:1
    |
 LL | #[link_section]
    | ^^^^^^^^^^^^^^^ help: must be of the form: `#[link_section = "name"]`
@@ -495,7 +519,7 @@ LL | #[link_section]
    = note: for more information, visit <https://doc.rust-lang.org/reference/abi.html#the-link_section-attribute>
 
 error[E0539]: malformed `coverage` attribute input
-  --> $DIR/malformed-attrs.rs:87:1
+  --> $DIR/malformed-attrs.rs:90:1
    |
 LL | #[coverage]
    | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -508,7 +532,7 @@ LL | #[coverage(on)]
    |           ++++
 
 error[E0565]: malformed `no_implicit_prelude` attribute input
-  --> $DIR/malformed-attrs.rs:94:1
+  --> $DIR/malformed-attrs.rs:97:1
    |
 LL | #[no_implicit_prelude = 23]
    | ^^^^^^^^^^^^^^^^^^^^^^----^
@@ -517,7 +541,7 @@ LL | #[no_implicit_prelude = 23]
    | help: must be of the form: `#[no_implicit_prelude]`
 
 error[E0565]: malformed `proc_macro` attribute input
-  --> $DIR/malformed-attrs.rs:96:1
+  --> $DIR/malformed-attrs.rs:99:1
    |
 LL | #[proc_macro = 18]
    | ^^^^^^^^^^^^^----^
@@ -526,7 +550,7 @@ LL | #[proc_macro = 18]
    | help: must be of the form: `#[proc_macro]`
 
 error[E0565]: malformed `coroutine` attribute input
-  --> $DIR/malformed-attrs.rs:108:5
+  --> $DIR/malformed-attrs.rs:111:5
    |
 LL |     #[coroutine = 63] || {}
    |     ^^^^^^^^^^^^----^
@@ -535,7 +559,7 @@ LL |     #[coroutine = 63] || {}
    |     help: must be of the form: `#[coroutine]`
 
 error[E0565]: malformed `proc_macro_attribute` attribute input
-  --> $DIR/malformed-attrs.rs:113:1
+  --> $DIR/malformed-attrs.rs:116:1
    |
 LL | #[proc_macro_attribute = 19]
    | ^^^^^^^^^^^^^^^^^^^^^^^----^
@@ -544,7 +568,7 @@ LL | #[proc_macro_attribute = 19]
    | help: must be of the form: `#[proc_macro_attribute]`
 
 error[E0539]: malformed `must_use` attribute input
-  --> $DIR/malformed-attrs.rs:116:1
+  --> $DIR/malformed-attrs.rs:119:1
    |
 LL | #[must_use = 1]
    | ^^^^^^^^^^^^^-^
@@ -562,7 +586,7 @@ LL + #[must_use]
    |
 
 error[E0539]: malformed `proc_macro_derive` attribute input
-  --> $DIR/malformed-attrs.rs:120:1
+  --> $DIR/malformed-attrs.rs:123:1
    |
 LL | #[proc_macro_derive]
    | ^^^^^^^^^^^^^^^^^^^^ expected this to be a list
@@ -576,7 +600,7 @@ LL | #[proc_macro_derive(TraitName, attributes(name1, name2, ...))]
    |                    ++++++++++++++++++++++++++++++++++++++++++
 
 error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input
-  --> $DIR/malformed-attrs.rs:125:1
+  --> $DIR/malformed-attrs.rs:128:1
    |
 LL | #[rustc_layout_scalar_valid_range_start]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -585,7 +609,7 @@ LL | #[rustc_layout_scalar_valid_range_start]
    | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]`
 
 error[E0539]: malformed `rustc_layout_scalar_valid_range_end` attribute input
-  --> $DIR/malformed-attrs.rs:127:1
+  --> $DIR/malformed-attrs.rs:130:1
    |
 LL | #[rustc_layout_scalar_valid_range_end]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -594,7 +618,7 @@ LL | #[rustc_layout_scalar_valid_range_end]
    | help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]`
 
 error[E0565]: malformed `marker` attribute input
-  --> $DIR/malformed-attrs.rs:152:1
+  --> $DIR/malformed-attrs.rs:155:1
    |
 LL | #[marker = 3]
    | ^^^^^^^^^---^
@@ -603,7 +627,7 @@ LL | #[marker = 3]
    | help: must be of the form: `#[marker]`
 
 error[E0565]: malformed `fundamental` attribute input
-  --> $DIR/malformed-attrs.rs:154:1
+  --> $DIR/malformed-attrs.rs:157:1
    |
 LL | #[fundamental()]
    | ^^^^^^^^^^^^^--^
@@ -612,7 +636,7 @@ LL | #[fundamental()]
    | help: must be of the form: `#[fundamental]`
 
 error[E0565]: malformed `ffi_pure` attribute input
-  --> $DIR/malformed-attrs.rs:162:5
+  --> $DIR/malformed-attrs.rs:165:5
    |
 LL |     #[unsafe(ffi_pure = 1)]
    |     ^^^^^^^^^^^^^^^^^^---^^
@@ -621,7 +645,7 @@ LL |     #[unsafe(ffi_pure = 1)]
    |     help: must be of the form: `#[ffi_pure]`
 
 error[E0539]: malformed `link_ordinal` attribute input
-  --> $DIR/malformed-attrs.rs:164:5
+  --> $DIR/malformed-attrs.rs:167:5
    |
 LL |     #[link_ordinal]
    |     ^^^^^^^^^^^^^^^
@@ -632,7 +656,7 @@ LL |     #[link_ordinal]
    = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_ordinal-attribute>
 
 error[E0565]: malformed `ffi_const` attribute input
-  --> $DIR/malformed-attrs.rs:168:5
+  --> $DIR/malformed-attrs.rs:171:5
    |
 LL |     #[unsafe(ffi_const = 1)]
    |     ^^^^^^^^^^^^^^^^^^^---^^
@@ -641,7 +665,7 @@ LL |     #[unsafe(ffi_const = 1)]
    |     help: must be of the form: `#[ffi_const]`
 
 error[E0539]: malformed `linkage` attribute input
-  --> $DIR/malformed-attrs.rs:170:5
+  --> $DIR/malformed-attrs.rs:173:5
    |
 LL |     #[linkage]
    |     ^^^^^^^^^^ expected this to be of the form `linkage = "..."`
@@ -659,7 +683,7 @@ LL |     #[linkage = "external"]
    = and 5 other candidates
 
 error[E0565]: malformed `automatically_derived` attribute input
-  --> $DIR/malformed-attrs.rs:188:1
+  --> $DIR/malformed-attrs.rs:191:1
    |
 LL | #[automatically_derived = 18]
    | ^^^^^^^^^^^^^^^^^^^^^^^^----^
@@ -668,7 +692,7 @@ LL | #[automatically_derived = 18]
    | help: must be of the form: `#[automatically_derived]`
 
 error[E0565]: malformed `non_exhaustive` attribute input
-  --> $DIR/malformed-attrs.rs:194:1
+  --> $DIR/malformed-attrs.rs:197:1
    |
 LL | #[non_exhaustive = 1]
    | ^^^^^^^^^^^^^^^^^---^
@@ -677,13 +701,13 @@ LL | #[non_exhaustive = 1]
    | help: must be of the form: `#[non_exhaustive]`
 
 error: valid forms for the attribute are `#[macro_use(name1, name2, ...)]` and `#[macro_use]`
-  --> $DIR/malformed-attrs.rs:206:1
+  --> $DIR/malformed-attrs.rs:209:1
    |
 LL | #[macro_use = 1]
    | ^^^^^^^^^^^^^^^^
 
 error[E0565]: malformed `allow_internal_unsafe` attribute input
-  --> $DIR/malformed-attrs.rs:213:1
+  --> $DIR/malformed-attrs.rs:216:1
    |
 LL | #[allow_internal_unsafe = 1]
    | ^^^^^^^^^^^^^^^^^^^^^^^^---^
@@ -692,7 +716,7 @@ LL | #[allow_internal_unsafe = 1]
    | help: must be of the form: `#[allow_internal_unsafe]`
 
 error[E0565]: malformed `type_const` attribute input
-  --> $DIR/malformed-attrs.rs:140:5
+  --> $DIR/malformed-attrs.rs:143:5
    |
 LL |     #[type_const = 1]
    |     ^^^^^^^^^^^^^---^
@@ -712,20 +736,20 @@ LL | |     #[coroutine = 63] || {}
 LL | | }
    | |_- not a `const fn`
 
-error: `#[repr(align(...))]` is not supported on function items
-  --> $DIR/malformed-attrs.rs:45:1
+error: `#[repr(align(...))]` is not supported on functions
+  --> $DIR/malformed-attrs.rs:47:1
    |
 LL | #[repr]
    | ^^^^^^^
    |
 help: use `#[rustc_align(...)]` instead
-  --> $DIR/malformed-attrs.rs:45:1
+  --> $DIR/malformed-attrs.rs:47:1
    |
 LL | #[repr]
    | ^^^^^^^
 
 warning: `#[diagnostic::do_not_recommend]` does not expect any arguments
-  --> $DIR/malformed-attrs.rs:146:1
+  --> $DIR/malformed-attrs.rs:149:1
    |
 LL | #[diagnostic::do_not_recommend()]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -733,7 +757,7 @@ LL | #[diagnostic::do_not_recommend()]
    = note: `#[warn(malformed_diagnostic_attributes)]` on by default
 
 warning: missing options for `on_unimplemented` attribute
-  --> $DIR/malformed-attrs.rs:135:1
+  --> $DIR/malformed-attrs.rs:138:1
    |
 LL | #[diagnostic::on_unimplemented]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -741,7 +765,7 @@ LL | #[diagnostic::on_unimplemented]
    = help: at least one of the `message`, `note` and `label` options are expected
 
 warning: malformed `on_unimplemented` attribute
-  --> $DIR/malformed-attrs.rs:137:1
+  --> $DIR/malformed-attrs.rs:140:1
    |
 LL | #[diagnostic::on_unimplemented = 1]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here
@@ -749,7 +773,7 @@ LL | #[diagnostic::on_unimplemented = 1]
    = help: only `message`, `note` and `label` are allowed as options
 
 error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]`
-  --> $DIR/malformed-attrs.rs:50:1
+  --> $DIR/malformed-attrs.rs:52:1
    |
 LL | #[inline = 5]
    | ^^^^^^^^^^^^^
@@ -758,7 +782,7 @@ LL | #[inline = 5]
    = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
 
 error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]`
-  --> $DIR/malformed-attrs.rs:91:1
+  --> $DIR/malformed-attrs.rs:94:1
    |
 LL | #[ignore()]
    | ^^^^^^^^^^^
@@ -767,7 +791,7 @@ LL | #[ignore()]
    = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
 
 error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]`
-  --> $DIR/malformed-attrs.rs:220:1
+  --> $DIR/malformed-attrs.rs:223:1
    |
 LL | #[ignore = 1]
    | ^^^^^^^^^^^^^
@@ -776,7 +800,7 @@ LL | #[ignore = 1]
    = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
 
 error[E0308]: mismatched types
-  --> $DIR/malformed-attrs.rs:108:23
+  --> $DIR/malformed-attrs.rs:111:23
    |
 LL | fn test() {
    |          - help: a return type might be missing here: `-> _`
@@ -784,15 +808,15 @@ LL |     #[coroutine = 63] || {}
    |                       ^^^^^ expected `()`, found coroutine
    |
    = note: expected unit type `()`
-              found coroutine `{coroutine@$DIR/malformed-attrs.rs:108:23: 108:25}`
+              found coroutine `{coroutine@$DIR/malformed-attrs.rs:111:23: 111:25}`
 
-error: aborting due to 74 previous errors; 3 warnings emitted
+error: aborting due to 77 previous errors; 3 warnings emitted
 
 Some errors have detailed explanations: E0308, E0463, E0539, E0565, E0658, E0805.
 For more information about an error, try `rustc --explain E0308`.
 Future incompatibility report: Future breakage diagnostic:
 error: valid forms for the attribute are `#[doc(hidden)]`, `#[doc(inline)]`, and `#[doc = "string"]`
-  --> $DIR/malformed-attrs.rs:40:1
+  --> $DIR/malformed-attrs.rs:41:1
    |
 LL | #[doc]
    | ^^^^^^
@@ -804,7 +828,7 @@ LL | #[doc]
 
 Future breakage diagnostic:
 error: valid forms for the attribute are `#[doc(hidden)]`, `#[doc(inline)]`, and `#[doc = "string"]`
-  --> $DIR/malformed-attrs.rs:73:1
+  --> $DIR/malformed-attrs.rs:76:1
    |
 LL | #[doc]
    | ^^^^^^
@@ -816,7 +840,7 @@ LL | #[doc]
 
 Future breakage diagnostic:
 error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]`
-  --> $DIR/malformed-attrs.rs:80:1
+  --> $DIR/malformed-attrs.rs:83:1
    |
 LL | #[link]
    | ^^^^^^^
@@ -828,7 +852,7 @@ LL | #[link]
 
 Future breakage diagnostic:
 error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]`
-  --> $DIR/malformed-attrs.rs:50:1
+  --> $DIR/malformed-attrs.rs:52:1
    |
 LL | #[inline = 5]
    | ^^^^^^^^^^^^^
@@ -839,7 +863,7 @@ LL | #[inline = 5]
 
 Future breakage diagnostic:
 error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]`
-  --> $DIR/malformed-attrs.rs:91:1
+  --> $DIR/malformed-attrs.rs:94:1
    |
 LL | #[ignore()]
    | ^^^^^^^^^^^
@@ -850,7 +874,7 @@ LL | #[ignore()]
 
 Future breakage diagnostic:
 error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]`
-  --> $DIR/malformed-attrs.rs:220:1
+  --> $DIR/malformed-attrs.rs:223:1
    |
 LL | #[ignore = 1]
    | ^^^^^^^^^^^^^
diff --git a/tests/ui/attributes/malformed-fn-align.rs b/tests/ui/attributes/malformed-fn-align.rs
index cf143b28e54..adce84763ab 100644
--- a/tests/ui/attributes/malformed-fn-align.rs
+++ b/tests/ui/attributes/malformed-fn-align.rs
@@ -23,7 +23,7 @@ fn f2() {}
 #[rustc_align(0)] //~ ERROR invalid alignment value: not a power of two
 fn f3() {}
 
-#[repr(align(16))] //~ ERROR `#[repr(align(...))]` is not supported on function items
+#[repr(align(16))] //~ ERROR `#[repr(align(...))]` is not supported on functions
 fn f4() {}
 
 #[rustc_align(-1)] //~ ERROR expected unsuffixed literal, found `-`
@@ -41,14 +41,14 @@ fn f7() {}
 #[rustc_align(16)]
 fn f8() {}
 
-#[rustc_align(16)] //~ ERROR `#[rustc_align(...)]` is not supported on struct items
+#[rustc_align(16)] //~ ERROR attribute cannot be used on
 struct S1;
 
-#[rustc_align(32)] //~ ERROR `#[rustc_align(...)]` should be applied to a function item
+#[rustc_align(32)] //~ ERROR attribute cannot be used on
 const FOO: i32 = 42;
 
-#[rustc_align(32)] //~ ERROR `#[rustc_align(...)]` should be applied to a function item
+#[rustc_align(32)] //~ ERROR attribute cannot be used on
 mod test {}
 
-#[rustc_align(32)] //~ ERROR `#[rustc_align(...)]` should be applied to a function item
+#[rustc_align(32)] //~ ERROR attribute cannot be used on
 use ::std::iter;
diff --git a/tests/ui/attributes/malformed-fn-align.stderr b/tests/ui/attributes/malformed-fn-align.stderr
index d995a7bf070..346fe2b4b7f 100644
--- a/tests/ui/attributes/malformed-fn-align.stderr
+++ b/tests/ui/attributes/malformed-fn-align.stderr
@@ -69,53 +69,49 @@ error[E0589]: invalid alignment value: not a power of two
 LL | #[rustc_align(3)]
    |               ^
 
-error: `#[repr(align(...))]` is not supported on function items
-  --> $DIR/malformed-fn-align.rs:26:8
-   |
-LL | #[repr(align(16))]
-   |        ^^^^^^^^^
-   |
-help: use `#[rustc_align(...)]` instead
-  --> $DIR/malformed-fn-align.rs:26:8
-   |
-LL | #[repr(align(16))]
-   |        ^^^^^^^^^
-
-error: `#[rustc_align(...)]` is not supported on struct items
+error: `#[rustc_align]` attribute cannot be used on structs
   --> $DIR/malformed-fn-align.rs:44:1
    |
 LL | #[rustc_align(16)]
    | ^^^^^^^^^^^^^^^^^^
    |
-help: use `#[repr(align(...))]` instead
-   |
-LL - #[rustc_align(16)]
-LL + #[repr(align(16))]
-   |
+   = help: `#[rustc_align]` can only be applied to functions
 
-error: `#[rustc_align(...)]` should be applied to a function item
+error: `#[rustc_align]` attribute cannot be used on constants
   --> $DIR/malformed-fn-align.rs:47:1
    |
 LL | #[rustc_align(32)]
    | ^^^^^^^^^^^^^^^^^^
-LL | const FOO: i32 = 42;
-   | -------------------- not a function item
+   |
+   = help: `#[rustc_align]` can only be applied to functions
 
-error: `#[rustc_align(...)]` should be applied to a function item
+error: `#[rustc_align]` attribute cannot be used on modules
   --> $DIR/malformed-fn-align.rs:50:1
    |
 LL | #[rustc_align(32)]
    | ^^^^^^^^^^^^^^^^^^
-LL | mod test {}
-   | ----------- not a function item
+   |
+   = help: `#[rustc_align]` can only be applied to functions
 
-error: `#[rustc_align(...)]` should be applied to a function item
+error: `#[rustc_align]` attribute cannot be used on use statements
   --> $DIR/malformed-fn-align.rs:53:1
    |
 LL | #[rustc_align(32)]
    | ^^^^^^^^^^^^^^^^^^
-LL | use ::std::iter;
-   | ---------------- not a function item
+   |
+   = help: `#[rustc_align]` can only be applied to functions
+
+error: `#[repr(align(...))]` is not supported on functions
+  --> $DIR/malformed-fn-align.rs:26:8
+   |
+LL | #[repr(align(16))]
+   |        ^^^^^^^^^
+   |
+help: use `#[rustc_align(...)]` instead
+  --> $DIR/malformed-fn-align.rs:26:8
+   |
+LL | #[repr(align(16))]
+   |        ^^^^^^^^^
 
 error: aborting due to 15 previous errors
 
diff --git a/tests/ui/attributes/multiple-invalid.rs b/tests/ui/attributes/multiple-invalid.rs
index ae044eb843b..49d1aeed604 100644
--- a/tests/ui/attributes/multiple-invalid.rs
+++ b/tests/ui/attributes/multiple-invalid.rs
@@ -2,9 +2,9 @@
 // on an item.
 
 #[inline]
-//~^ ERROR attribute should be applied to function or closure [E0518]
+//~^ ERROR attribute cannot be used on
 #[target_feature(enable = "sse2")]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 const FOO: u8 = 0;
 
 fn main() { }
diff --git a/tests/ui/attributes/multiple-invalid.stderr b/tests/ui/attributes/multiple-invalid.stderr
index f4f7dd7c4f1..182d39b14bc 100644
--- a/tests/ui/attributes/multiple-invalid.stderr
+++ b/tests/ui/attributes/multiple-invalid.stderr
@@ -1,21 +1,18 @@
-error: attribute should be applied to a function definition
+error: `#[inline]` attribute cannot be used on constants
+  --> $DIR/multiple-invalid.rs:4:1
+   |
+LL | #[inline]
+   | ^^^^^^^^^
+   |
+   = help: `#[inline]` can only be applied to functions
+
+error: `#[target_feature]` attribute cannot be used on constants
   --> $DIR/multiple-invalid.rs:6:1
    |
 LL | #[target_feature(enable = "sse2")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | const FOO: u8 = 0;
-   | ------------------ not a function definition
-
-error[E0518]: attribute should be applied to function or closure
-  --> $DIR/multiple-invalid.rs:4:1
    |
-LL | #[inline]
-   | ^^^^^^^^^
-...
-LL | const FOO: u8 = 0;
-   | ------------------ not a function or closure
+   = help: `#[target_feature]` can only be applied to functions
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0518`.
diff --git a/tests/ui/attributes/optimize.rs b/tests/ui/attributes/optimize.rs
index 7a1cc1be9ee..78e05f111e7 100644
--- a/tests/ui/attributes/optimize.rs
+++ b/tests/ui/attributes/optimize.rs
@@ -5,11 +5,11 @@
 
 //@ edition: 2018
 
-#[optimize(speed)] //~ ERROR attribute applied to an invalid target
+#[optimize(speed)] //~ ERROR attribute cannot be used on
 struct F;
 
 fn invalid() {
-    #[optimize(speed)] //~ ERROR attribute applied to an invalid target
+    #[optimize(speed)] //~ ERROR attribute cannot be used on
     {
         1
     };
@@ -18,10 +18,10 @@ fn invalid() {
 #[optimize(speed)]
 fn valid() {}
 
-#[optimize(speed)] //~ ERROR attribute applied to an invalid target
+#[optimize(speed)] //~ ERROR attribute cannot be used on
 mod valid_module {}
 
-#[optimize(speed)] //~ ERROR attribute applied to an invalid target
+#[optimize(speed)] //~ ERROR attribute cannot be used on
 impl F {}
 
 fn main() {
diff --git a/tests/ui/attributes/optimize.stderr b/tests/ui/attributes/optimize.stderr
index ad9309d27a5..2ded1a973f3 100644
--- a/tests/ui/attributes/optimize.stderr
+++ b/tests/ui/attributes/optimize.stderr
@@ -1,36 +1,34 @@
-error: attribute applied to an invalid target
+error: `#[optimize]` attribute cannot be used on structs
   --> $DIR/optimize.rs:8:1
    |
 LL | #[optimize(speed)]
    | ^^^^^^^^^^^^^^^^^^
-LL | struct F;
-   | --------- invalid target
+   |
+   = help: `#[optimize]` can only be applied to functions
 
-error: attribute applied to an invalid target
+error: `#[optimize]` attribute cannot be used on expressions
   --> $DIR/optimize.rs:12:5
    |
-LL |       #[optimize(speed)]
-   |       ^^^^^^^^^^^^^^^^^^
-LL | /     {
-LL | |         1
-LL | |     };
-   | |_____- invalid target
+LL |     #[optimize(speed)]
+   |     ^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[optimize]` can only be applied to functions
 
-error: attribute applied to an invalid target
+error: `#[optimize]` attribute cannot be used on modules
   --> $DIR/optimize.rs:21:1
    |
 LL | #[optimize(speed)]
    | ^^^^^^^^^^^^^^^^^^
-LL | mod valid_module {}
-   | ------------------- invalid target
+   |
+   = help: `#[optimize]` can only be applied to functions
 
-error: attribute applied to an invalid target
+error: `#[optimize]` attribute cannot be used on inherent impl blocks
   --> $DIR/optimize.rs:24:1
    |
 LL | #[optimize(speed)]
    | ^^^^^^^^^^^^^^^^^^
-LL | impl F {}
-   | --------- invalid target
+   |
+   = help: `#[optimize]` can only be applied to functions
 
 error: aborting due to 4 previous errors
 
diff --git a/tests/ui/attributes/positions/used.rs b/tests/ui/attributes/positions/used.rs
index 7950fa773a1..7e106d278f2 100644
--- a/tests/ui/attributes/positions/used.rs
+++ b/tests/ui/attributes/positions/used.rs
@@ -4,20 +4,20 @@
 #[used]
 static FOO: u32 = 0; // OK
 
-#[used] //~ ERROR attribute must be applied to a `static` variable
+#[used] //~ ERROR attribute cannot be used on
 fn foo() {}
 
-#[used] //~ ERROR attribute must be applied to a `static` variable
+#[used] //~ ERROR attribute cannot be used on
 struct Foo {}
 
-#[used] //~ ERROR attribute must be applied to a `static` variable
+#[used] //~ ERROR attribute cannot be used on
 trait Bar {}
 
-#[used] //~ ERROR attribute must be applied to a `static` variable
+#[used] //~ ERROR attribute cannot be used on
 impl Bar for Foo {}
 
 // Regression test for <https://github.com/rust-lang/rust/issues/126789>.
 extern "C" {
-    #[used] //~ ERROR attribute must be applied to a `static` variable
+    #[used] //~ ERROR attribute cannot be used on
     static BAR: i32;
 }
diff --git a/tests/ui/attributes/positions/used.stderr b/tests/ui/attributes/positions/used.stderr
index 64460c178cb..79011f3a758 100644
--- a/tests/ui/attributes/positions/used.stderr
+++ b/tests/ui/attributes/positions/used.stderr
@@ -1,42 +1,42 @@
-error: attribute must be applied to a `static` variable
+error: `#[used]` attribute cannot be used on functions
   --> $DIR/used.rs:7:1
    |
 LL | #[used]
    | ^^^^^^^
-LL | fn foo() {}
-   | ----------- but this is a function
+   |
+   = help: `#[used]` can only be applied to statics
 
-error: attribute must be applied to a `static` variable
+error: `#[used]` attribute cannot be used on structs
   --> $DIR/used.rs:10:1
    |
 LL | #[used]
    | ^^^^^^^
-LL | struct Foo {}
-   | ------------- but this is a struct
+   |
+   = help: `#[used]` can only be applied to statics
 
-error: attribute must be applied to a `static` variable
+error: `#[used]` attribute cannot be used on traits
   --> $DIR/used.rs:13:1
    |
 LL | #[used]
    | ^^^^^^^
-LL | trait Bar {}
-   | ------------ but this is a trait
+   |
+   = help: `#[used]` can only be applied to statics
 
-error: attribute must be applied to a `static` variable
+error: `#[used]` attribute cannot be used on trait impl blocks
   --> $DIR/used.rs:16:1
    |
 LL | #[used]
    | ^^^^^^^
-LL | impl Bar for Foo {}
-   | ------------------- but this is a trait implementation block
+   |
+   = help: `#[used]` can only be applied to statics
 
-error: attribute must be applied to a `static` variable
+error: `#[used]` attribute cannot be used on foreign statics
   --> $DIR/used.rs:21:5
    |
 LL |     #[used]
    |     ^^^^^^^
-LL |     static BAR: i32;
-   |     ---------------- but this is a foreign static item
+   |
+   = help: `#[used]` can only be applied to statics
 
 error: aborting due to 5 previous errors
 
diff --git a/tests/ui/attributes/rustc_confusables.rs b/tests/ui/attributes/rustc_confusables.rs
index a8095936cff..91c66a75cc3 100644
--- a/tests/ui/attributes/rustc_confusables.rs
+++ b/tests/ui/attributes/rustc_confusables.rs
@@ -43,5 +43,6 @@ impl Bar {
 }
 
 #[rustc_confusables("blah")]
-//~^ ERROR attribute should be applied to an inherent method
+//~^ ERROR attribute cannot be used on
+//~| HELP can only be applied to
 fn not_inherent_impl_method() {}
diff --git a/tests/ui/attributes/rustc_confusables.stderr b/tests/ui/attributes/rustc_confusables.stderr
index 3ed4efeb4db..c714257ee77 100644
--- a/tests/ui/attributes/rustc_confusables.stderr
+++ b/tests/ui/attributes/rustc_confusables.stderr
@@ -22,11 +22,13 @@ LL |     #[rustc_confusables(invalid_meta_item)]
    |     |                   expected a string literal here
    |     help: must be of the form: `#[rustc_confusables("name1", "name2", ...)]`
 
-error: attribute should be applied to an inherent method
+error: `#[rustc_confusables]` attribute cannot be used on functions
   --> $DIR/rustc_confusables.rs:45:1
    |
 LL | #[rustc_confusables("blah")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[rustc_confusables]` can only be applied to inherent methods
 
 error[E0599]: no method named `inser` found for struct `rustc_confusables_across_crate::BTreeSet` in the current scope
   --> $DIR/rustc_confusables.rs:12:7
diff --git a/tests/ui/attributes/rustc_skip_during_method_dispatch.rs b/tests/ui/attributes/rustc_skip_during_method_dispatch.rs
index 25b473d5a58..e1bd0ca3896 100644
--- a/tests/ui/attributes/rustc_skip_during_method_dispatch.rs
+++ b/tests/ui/attributes/rustc_skip_during_method_dispatch.rs
@@ -32,7 +32,7 @@ trait String {}
 trait OK {}
 
 #[rustc_skip_during_method_dispatch(array)]
-//~^ ERROR: attribute should be applied to a trait
+//~^ ERROR: attribute cannot be used on
 impl OK for () {}
 
 fn main() {}
diff --git a/tests/ui/attributes/rustc_skip_during_method_dispatch.stderr b/tests/ui/attributes/rustc_skip_during_method_dispatch.stderr
index 2f5d7968489..094987e944f 100644
--- a/tests/ui/attributes/rustc_skip_during_method_dispatch.stderr
+++ b/tests/ui/attributes/rustc_skip_during_method_dispatch.stderr
@@ -61,14 +61,13 @@ LL | #[rustc_skip_during_method_dispatch("array")]
    | |                                   didn't expect a literal here
    | help: must be of the form: `#[rustc_skip_during_method_dispatch(array, boxed_slice)]`
 
-error: attribute should be applied to a trait
+error: `#[rustc_skip_during_method_dispatch]` attribute cannot be used on trait impl blocks
   --> $DIR/rustc_skip_during_method_dispatch.rs:34:1
    |
 LL | #[rustc_skip_during_method_dispatch(array)]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | impl OK for () {}
-   | ----------------- not a trait
+   |
+   = help: `#[rustc_skip_during_method_dispatch]` can only be applied to traits
 
 error: aborting due to 8 previous errors
 
diff --git a/tests/ui/coroutine/invalid_attr_usage.rs b/tests/ui/coroutine/invalid_attr_usage.rs
index 995a3aa3100..5081c17de4b 100644
--- a/tests/ui/coroutine/invalid_attr_usage.rs
+++ b/tests/ui/coroutine/invalid_attr_usage.rs
@@ -3,9 +3,9 @@
 #![feature(coroutines)]
 
 #[coroutine]
-//~^ ERROR: attribute should be applied to closures
+//~^ ERROR: attribute cannot be used on
 struct Foo;
 
 #[coroutine]
-//~^ ERROR: attribute should be applied to closures
+//~^ ERROR: attribute cannot be used on
 fn main() {}
diff --git a/tests/ui/coroutine/invalid_attr_usage.stderr b/tests/ui/coroutine/invalid_attr_usage.stderr
index 316a0117e5d..46fc80c1bad 100644
--- a/tests/ui/coroutine/invalid_attr_usage.stderr
+++ b/tests/ui/coroutine/invalid_attr_usage.stderr
@@ -1,14 +1,18 @@
-error: attribute should be applied to closures
+error: `#[coroutine]` attribute cannot be used on structs
   --> $DIR/invalid_attr_usage.rs:5:1
    |
 LL | #[coroutine]
    | ^^^^^^^^^^^^
+   |
+   = help: `#[coroutine]` can only be applied to closures
 
-error: attribute should be applied to closures
+error: `#[coroutine]` attribute cannot be used on functions
   --> $DIR/invalid_attr_usage.rs:9:1
    |
 LL | #[coroutine]
    | ^^^^^^^^^^^^
+   |
+   = help: `#[coroutine]` can only be applied to closures
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/coverage-attr/allowed-positions.rs b/tests/ui/coverage-attr/allowed-positions.rs
index f1169fa6570..cfbc7f5e6c0 100644
--- a/tests/ui/coverage-attr/allowed-positions.rs
+++ b/tests/ui/coverage-attr/allowed-positions.rs
@@ -11,24 +11,24 @@
 #[coverage(off)]
 mod submod {}
 
-#[coverage(off)] //~ ERROR coverage attribute not allowed here [E0788]
+#[coverage(off)] //~ ERROR attribute cannot be used on
 type MyTypeAlias = ();
 
-#[coverage(off)] //~ ERROR [E0788]
+#[coverage(off)] //~ ERROR attribute cannot be used on
 trait MyTrait {
-    #[coverage(off)] //~ ERROR [E0788]
+    #[coverage(off)] //~ ERROR attribute cannot be used on
     const TRAIT_ASSOC_CONST: u32;
 
-    #[coverage(off)] //~ ERROR [E0788]
+    #[coverage(off)] //~ ERROR attribute cannot be used on
     type TraitAssocType;
 
-    #[coverage(off)] //~ ERROR [E0788]
+    #[coverage(off)] //~ ERROR attribute cannot be used on
     fn trait_method(&self);
 
     #[coverage(off)]
     fn trait_method_with_default(&self) {}
 
-    #[coverage(off)] //~ ERROR [E0788]
+    #[coverage(off)] //~ ERROR attribute cannot be used on
     fn trait_assoc_fn();
 }
 
@@ -36,7 +36,7 @@ trait MyTrait {
 impl MyTrait for () {
     const TRAIT_ASSOC_CONST: u32 = 0;
 
-    #[coverage(off)] //~ ERROR [E0788]
+    #[coverage(off)] //~ ERROR attribute cannot be used on
     type TraitAssocType = Self;
 
     #[coverage(off)]
@@ -53,14 +53,14 @@ trait HasAssocType {
 }
 
 impl HasAssocType for () {
-    #[coverage(off)] //~ ERROR [E0788]
+    #[coverage(off)] //~ ERROR attribute cannot be used on
     type T = impl Copy;
     fn constrain_assoc_type() -> Self::T {}
 }
 
-#[coverage(off)] //~ ERROR [E0788]
+#[coverage(off)] //~ ERROR attribute cannot be used on
 struct MyStruct {
-    #[coverage(off)] //~ ERROR [E0788]
+    #[coverage(off)] //~ ERROR attribute cannot be used on
     field: u32,
 }
 
@@ -73,25 +73,25 @@ impl MyStruct {
 }
 
 extern "C" {
-    #[coverage(off)] //~ ERROR [E0788]
+    #[coverage(off)] //~ ERROR attribute cannot be used on
     static X: u32;
 
-    #[coverage(off)] //~ ERROR [E0788]
+    #[coverage(off)] //~ ERROR attribute cannot be used on
     type T;
 
-    #[coverage(off)] //~ ERROR [E0788]
+    #[coverage(off)] //~ ERROR attribute cannot be used on
     fn foreign_fn();
 }
 
 #[coverage(off)]
 fn main() {
-    #[coverage(off)] //~ ERROR [E0788]
+    #[coverage(off)] //~ ERROR attribute cannot be used on
     let _ = ();
 
     // Currently not allowed on let statements, even if they bind to a closure.
     // It might be nice to support this as a special case someday, but trying
     // to define the precise boundaries of that special case might be tricky.
-    #[coverage(off)] //~ ERROR [E0788]
+    #[coverage(off)] //~ ERROR attribute cannot be used on
     let _let_closure = || ();
 
     // In situations where attributes can already be applied to expressions,
@@ -107,10 +107,10 @@ fn main() {
     //~^ ERROR attributes on expressions are experimental [E0658]
 
     match () {
-        #[coverage(off)] //~ ERROR [E0788]
+        #[coverage(off)] //~ ERROR attribute cannot be used on
         () => (),
     }
 
-    #[coverage(off)] //~ ERROR [E0788]
+    #[coverage(off)] //~ ERROR attribute cannot be used on
     return ();
 }
diff --git a/tests/ui/coverage-attr/allowed-positions.stderr b/tests/ui/coverage-attr/allowed-positions.stderr
index 34562a4da1b..aaef3ad0203 100644
--- a/tests/ui/coverage-attr/allowed-positions.stderr
+++ b/tests/ui/coverage-attr/allowed-positions.stderr
@@ -8,185 +8,142 @@ LL |     let _closure_expr = #[coverage(off)] || ();
    = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
 
-error[E0788]: coverage attribute not allowed here
+error: `#[coverage]` attribute cannot be used on type aliases
   --> $DIR/allowed-positions.rs:14:1
    |
 LL | #[coverage(off)]
    | ^^^^^^^^^^^^^^^^
-LL | type MyTypeAlias = ();
-   | ---------------------- not a function, impl block, or module
    |
-   = help: coverage attribute can be applied to a function (with body), impl block, or module
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
 
-error[E0788]: coverage attribute not allowed here
+error: `#[coverage]` attribute cannot be used on traits
   --> $DIR/allowed-positions.rs:17:1
    |
-LL |   #[coverage(off)]
-   |   ^^^^^^^^^^^^^^^^
-LL | / trait MyTrait {
-LL | |     #[coverage(off)]
-LL | |     const TRAIT_ASSOC_CONST: u32;
-...  |
-LL | |     fn trait_assoc_fn();
-LL | | }
-   | |_- not a function, impl block, or module
+LL | #[coverage(off)]
+   | ^^^^^^^^^^^^^^^^
    |
-   = help: coverage attribute can be applied to a function (with body), impl block, or module
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
 
-error[E0788]: coverage attribute not allowed here
-  --> $DIR/allowed-positions.rs:61:1
+error: `#[coverage]` attribute cannot be used on associated consts
+  --> $DIR/allowed-positions.rs:19:5
    |
-LL |   #[coverage(off)]
-   |   ^^^^^^^^^^^^^^^^
-LL | / struct MyStruct {
-LL | |     #[coverage(off)]
-LL | |     field: u32,
-LL | | }
-   | |_- not a function, impl block, or module
+LL |     #[coverage(off)]
+   |     ^^^^^^^^^^^^^^^^
    |
-   = help: coverage attribute can be applied to a function (with body), impl block, or module
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
 
-error[E0788]: coverage attribute not allowed here
-  --> $DIR/allowed-positions.rs:63:5
+error: `#[coverage]` attribute cannot be used on associated types
+  --> $DIR/allowed-positions.rs:22:5
    |
 LL |     #[coverage(off)]
    |     ^^^^^^^^^^^^^^^^
-LL |     field: u32,
-   |     ---------- not a function, impl block, or module
    |
-   = help: coverage attribute can be applied to a function (with body), impl block, or module
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
 
-error[E0788]: coverage attribute not allowed here
-  --> $DIR/allowed-positions.rs:88:5
+error: `#[coverage]` attribute cannot be used on required trait methods
+  --> $DIR/allowed-positions.rs:25:5
    |
 LL |     #[coverage(off)]
    |     ^^^^^^^^^^^^^^^^
-LL |     let _ = ();
-   |     ----------- not a function, impl block, or module
    |
-   = help: coverage attribute can be applied to a function (with body), impl block, or module
+   = help: `#[coverage]` can be applied to impl blocks, functions, closures, provided trait methods, trait methods in impl blocks, inherent methods, modules, crates
 
-error[E0788]: coverage attribute not allowed here
-  --> $DIR/allowed-positions.rs:94:5
+error: `#[coverage]` attribute cannot be used on required trait methods
+  --> $DIR/allowed-positions.rs:31:5
    |
 LL |     #[coverage(off)]
    |     ^^^^^^^^^^^^^^^^
-LL |     let _let_closure = || ();
-   |     ------------------------- not a function, impl block, or module
    |
-   = help: coverage attribute can be applied to a function (with body), impl block, or module
+   = help: `#[coverage]` can be applied to impl blocks, functions, closures, provided trait methods, trait methods in impl blocks, inherent methods, modules, crates
 
-error[E0788]: coverage attribute not allowed here
-  --> $DIR/allowed-positions.rs:110:9
+error: `#[coverage]` attribute cannot be used on associated types
+  --> $DIR/allowed-positions.rs:39:5
    |
-LL |         #[coverage(off)]
-   |         ^^^^^^^^^^^^^^^^
-LL |         () => (),
-   |         -------- not a function, impl block, or module
+LL |     #[coverage(off)]
+   |     ^^^^^^^^^^^^^^^^
    |
-   = help: coverage attribute can be applied to a function (with body), impl block, or module
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
 
-error[E0788]: coverage attribute not allowed here
-  --> $DIR/allowed-positions.rs:114:5
+error: `#[coverage]` attribute cannot be used on associated types
+  --> $DIR/allowed-positions.rs:56:5
    |
 LL |     #[coverage(off)]
    |     ^^^^^^^^^^^^^^^^
-LL |     return ();
-   |     --------- not a function, impl block, or module
    |
-   = help: coverage attribute can be applied to a function (with body), impl block, or module
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
 
-error[E0788]: coverage attribute not allowed here
-  --> $DIR/allowed-positions.rs:19:5
+error: `#[coverage]` attribute cannot be used on structs
+  --> $DIR/allowed-positions.rs:61:1
    |
-LL |     #[coverage(off)]
-   |     ^^^^^^^^^^^^^^^^
-LL |     const TRAIT_ASSOC_CONST: u32;
-   |     ----------------------------- not a function, impl block, or module
+LL | #[coverage(off)]
+   | ^^^^^^^^^^^^^^^^
    |
-   = help: coverage attribute can be applied to a function (with body), impl block, or module
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
 
-error[E0788]: coverage attribute not allowed here
-  --> $DIR/allowed-positions.rs:22:5
+error: `#[coverage]` attribute cannot be used on struct fields
+  --> $DIR/allowed-positions.rs:63:5
    |
 LL |     #[coverage(off)]
    |     ^^^^^^^^^^^^^^^^
-LL |     type TraitAssocType;
-   |     -------------------- not a function, impl block, or module
    |
-   = help: coverage attribute can be applied to a function (with body), impl block, or module
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
 
-error[E0788]: coverage attribute not allowed here
-  --> $DIR/allowed-positions.rs:25:5
+error: `#[coverage]` attribute cannot be used on foreign statics
+  --> $DIR/allowed-positions.rs:76:5
    |
 LL |     #[coverage(off)]
    |     ^^^^^^^^^^^^^^^^
-LL |     fn trait_method(&self);
-   |     ----------------------- function has no body
    |
-   = help: coverage attribute can be applied to a function (with body), impl block, or module
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
 
-error[E0788]: coverage attribute not allowed here
-  --> $DIR/allowed-positions.rs:31:5
+error: `#[coverage]` attribute cannot be used on foreign types
+  --> $DIR/allowed-positions.rs:79:5
    |
 LL |     #[coverage(off)]
    |     ^^^^^^^^^^^^^^^^
-LL |     fn trait_assoc_fn();
-   |     -------------------- function has no body
    |
-   = help: coverage attribute can be applied to a function (with body), impl block, or module
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
 
-error[E0788]: coverage attribute not allowed here
-  --> $DIR/allowed-positions.rs:39:5
+error: `#[coverage]` attribute cannot be used on foreign functions
+  --> $DIR/allowed-positions.rs:82:5
    |
 LL |     #[coverage(off)]
    |     ^^^^^^^^^^^^^^^^
-LL |     type TraitAssocType = Self;
-   |     --------------------------- not a function, impl block, or module
    |
-   = help: coverage attribute can be applied to a function (with body), impl block, or module
+   = help: `#[coverage]` can be applied to methods, impl blocks, functions, closures, modules, crates
 
-error[E0788]: coverage attribute not allowed here
-  --> $DIR/allowed-positions.rs:56:5
+error: `#[coverage]` attribute cannot be used on statements
+  --> $DIR/allowed-positions.rs:88:5
    |
 LL |     #[coverage(off)]
    |     ^^^^^^^^^^^^^^^^
-LL |     type T = impl Copy;
-   |     ------------------- not a function, impl block, or module
    |
-   = help: coverage attribute can be applied to a function (with body), impl block, or module
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
 
-error[E0788]: coverage attribute not allowed here
-  --> $DIR/allowed-positions.rs:76:5
+error: `#[coverage]` attribute cannot be used on statements
+  --> $DIR/allowed-positions.rs:94:5
    |
 LL |     #[coverage(off)]
    |     ^^^^^^^^^^^^^^^^
-LL |     static X: u32;
-   |     -------------- not a function, impl block, or module
    |
-   = help: coverage attribute can be applied to a function (with body), impl block, or module
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
 
-error[E0788]: coverage attribute not allowed here
-  --> $DIR/allowed-positions.rs:79:5
+error: `#[coverage]` attribute cannot be used on match arms
+  --> $DIR/allowed-positions.rs:110:9
    |
-LL |     #[coverage(off)]
-   |     ^^^^^^^^^^^^^^^^
-LL |     type T;
-   |     ------- not a function, impl block, or module
+LL |         #[coverage(off)]
+   |         ^^^^^^^^^^^^^^^^
    |
-   = help: coverage attribute can be applied to a function (with body), impl block, or module
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
 
-error[E0788]: coverage attribute not allowed here
-  --> $DIR/allowed-positions.rs:82:5
+error: `#[coverage]` attribute cannot be used on expressions
+  --> $DIR/allowed-positions.rs:114:5
    |
 LL |     #[coverage(off)]
    |     ^^^^^^^^^^^^^^^^
-LL |     fn foreign_fn();
-   |     ---------------- function has no body
    |
-   = help: coverage attribute can be applied to a function (with body), impl block, or module
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
 
 error: aborting due to 18 previous errors
 
-Some errors have detailed explanations: E0658, E0788.
-For more information about an error, try `rustc --explain E0658`.
+For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/coverage-attr/name-value.rs b/tests/ui/coverage-attr/name-value.rs
index 8171dbbf692..6e81ab89616 100644
--- a/tests/ui/coverage-attr/name-value.rs
+++ b/tests/ui/coverage-attr/name-value.rs
@@ -20,6 +20,7 @@ mod my_mod_inner {
 
 #[coverage = "off"]
 //~^ ERROR malformed `coverage` attribute input
+//~| ERROR attribute cannot be used on
 struct MyStruct;
 
 #[coverage = "off"]
@@ -27,18 +28,22 @@ struct MyStruct;
 impl MyStruct {
     #[coverage = "off"]
     //~^ ERROR malformed `coverage` attribute input
+    //~| ERROR attribute cannot be used on
     const X: u32 = 7;
 }
 
 #[coverage = "off"]
 //~^ ERROR malformed `coverage` attribute input
+//~| ERROR attribute cannot be used on
 trait MyTrait {
     #[coverage = "off"]
     //~^ ERROR malformed `coverage` attribute input
+    //~| ERROR attribute cannot be used on
     const X: u32;
 
     #[coverage = "off"]
     //~^ ERROR malformed `coverage` attribute input
+    //~| ERROR attribute cannot be used on
     type T;
 }
 
@@ -47,10 +52,12 @@ trait MyTrait {
 impl MyTrait for MyStruct {
     #[coverage = "off"]
     //~^ ERROR malformed `coverage` attribute input
+    //~| ERROR attribute cannot be used on
     const X: u32 = 8;
 
     #[coverage = "off"]
     //~^ ERROR malformed `coverage` attribute input
+    //~| ERROR attribute cannot be used on
     type T = ();
 }
 
diff --git a/tests/ui/coverage-attr/name-value.stderr b/tests/ui/coverage-attr/name-value.stderr
index a838ec5df8e..2dac2401e3c 100644
--- a/tests/ui/coverage-attr/name-value.stderr
+++ b/tests/ui/coverage-attr/name-value.stderr
@@ -43,8 +43,16 @@ LL - #[coverage = "off"]
 LL + #[coverage(on)]
    |
 
+error: `#[coverage]` attribute cannot be used on structs
+  --> $DIR/name-value.rs:21:1
+   |
+LL | #[coverage = "off"]
+   | ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
+
 error[E0539]: malformed `coverage` attribute input
-  --> $DIR/name-value.rs:25:1
+  --> $DIR/name-value.rs:26:1
    |
 LL | #[coverage = "off"]
    | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -59,7 +67,7 @@ LL + #[coverage(on)]
    |
 
 error[E0539]: malformed `coverage` attribute input
-  --> $DIR/name-value.rs:28:5
+  --> $DIR/name-value.rs:29:5
    |
 LL |     #[coverage = "off"]
    |     ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -73,8 +81,16 @@ LL -     #[coverage = "off"]
 LL +     #[coverage(on)]
    |
 
+error: `#[coverage]` attribute cannot be used on associated consts
+  --> $DIR/name-value.rs:29:5
+   |
+LL |     #[coverage = "off"]
+   |     ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
+
 error[E0539]: malformed `coverage` attribute input
-  --> $DIR/name-value.rs:33:1
+  --> $DIR/name-value.rs:35:1
    |
 LL | #[coverage = "off"]
    | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -88,8 +104,16 @@ LL - #[coverage = "off"]
 LL + #[coverage(on)]
    |
 
+error: `#[coverage]` attribute cannot be used on traits
+  --> $DIR/name-value.rs:35:1
+   |
+LL | #[coverage = "off"]
+   | ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
+
 error[E0539]: malformed `coverage` attribute input
-  --> $DIR/name-value.rs:36:5
+  --> $DIR/name-value.rs:39:5
    |
 LL |     #[coverage = "off"]
    |     ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -103,8 +127,16 @@ LL -     #[coverage = "off"]
 LL +     #[coverage(on)]
    |
 
+error: `#[coverage]` attribute cannot be used on associated consts
+  --> $DIR/name-value.rs:39:5
+   |
+LL |     #[coverage = "off"]
+   |     ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
+
 error[E0539]: malformed `coverage` attribute input
-  --> $DIR/name-value.rs:40:5
+  --> $DIR/name-value.rs:44:5
    |
 LL |     #[coverage = "off"]
    |     ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -118,8 +150,16 @@ LL -     #[coverage = "off"]
 LL +     #[coverage(on)]
    |
 
+error: `#[coverage]` attribute cannot be used on associated types
+  --> $DIR/name-value.rs:44:5
+   |
+LL |     #[coverage = "off"]
+   |     ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
+
 error[E0539]: malformed `coverage` attribute input
-  --> $DIR/name-value.rs:45:1
+  --> $DIR/name-value.rs:50:1
    |
 LL | #[coverage = "off"]
    | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -134,7 +174,7 @@ LL + #[coverage(on)]
    |
 
 error[E0539]: malformed `coverage` attribute input
-  --> $DIR/name-value.rs:48:5
+  --> $DIR/name-value.rs:53:5
    |
 LL |     #[coverage = "off"]
    |     ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -148,8 +188,16 @@ LL -     #[coverage = "off"]
 LL +     #[coverage(on)]
    |
 
+error: `#[coverage]` attribute cannot be used on associated consts
+  --> $DIR/name-value.rs:53:5
+   |
+LL |     #[coverage = "off"]
+   |     ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
+
 error[E0539]: malformed `coverage` attribute input
-  --> $DIR/name-value.rs:52:5
+  --> $DIR/name-value.rs:58:5
    |
 LL |     #[coverage = "off"]
    |     ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -163,8 +211,16 @@ LL -     #[coverage = "off"]
 LL +     #[coverage(on)]
    |
 
+error: `#[coverage]` attribute cannot be used on associated types
+  --> $DIR/name-value.rs:58:5
+   |
+LL |     #[coverage = "off"]
+   |     ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
+
 error[E0539]: malformed `coverage` attribute input
-  --> $DIR/name-value.rs:57:1
+  --> $DIR/name-value.rs:64:1
    |
 LL | #[coverage = "off"]
    | ^^^^^^^^^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -178,6 +234,6 @@ LL - #[coverage = "off"]
 LL + #[coverage(on)]
    |
 
-error: aborting due to 12 previous errors
+error: aborting due to 19 previous errors
 
 For more information about this error, try `rustc --explain E0539`.
diff --git a/tests/ui/coverage-attr/word-only.rs b/tests/ui/coverage-attr/word-only.rs
index 81bd558b8b0..e47279f74ca 100644
--- a/tests/ui/coverage-attr/word-only.rs
+++ b/tests/ui/coverage-attr/word-only.rs
@@ -20,6 +20,7 @@ mod my_mod_inner {
 
 #[coverage]
 //~^ ERROR malformed `coverage` attribute input
+//~| ERROR attribute cannot be used on
 struct MyStruct;
 
 #[coverage]
@@ -27,18 +28,22 @@ struct MyStruct;
 impl MyStruct {
     #[coverage]
     //~^ ERROR malformed `coverage` attribute input
+    //~| ERROR attribute cannot be used on
     const X: u32 = 7;
 }
 
 #[coverage]
 //~^ ERROR malformed `coverage` attribute input
+//~| ERROR attribute cannot be used on
 trait MyTrait {
     #[coverage]
     //~^ ERROR malformed `coverage` attribute input
+    //~| ERROR attribute cannot be used on
     const X: u32;
 
     #[coverage]
     //~^ ERROR malformed `coverage` attribute input
+    //~| ERROR attribute cannot be used on
     type T;
 }
 
@@ -47,10 +52,12 @@ trait MyTrait {
 impl MyTrait for MyStruct {
     #[coverage]
     //~^ ERROR malformed `coverage` attribute input
+    //~| ERROR attribute cannot be used on
     const X: u32 = 8;
 
     #[coverage]
     //~^ ERROR malformed `coverage` attribute input
+    //~| ERROR attribute cannot be used on
     type T = ();
 }
 
diff --git a/tests/ui/coverage-attr/word-only.stderr b/tests/ui/coverage-attr/word-only.stderr
index dd161360a5c..e916a817e36 100644
--- a/tests/ui/coverage-attr/word-only.stderr
+++ b/tests/ui/coverage-attr/word-only.stderr
@@ -39,8 +39,16 @@ LL | #[coverage(off)]
 LL | #[coverage(on)]
    |           ++++
 
+error: `#[coverage]` attribute cannot be used on structs
+  --> $DIR/word-only.rs:21:1
+   |
+LL | #[coverage]
+   | ^^^^^^^^^^^
+   |
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
+
 error[E0539]: malformed `coverage` attribute input
-  --> $DIR/word-only.rs:25:1
+  --> $DIR/word-only.rs:26:1
    |
 LL | #[coverage]
    | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -53,7 +61,7 @@ LL | #[coverage(on)]
    |           ++++
 
 error[E0539]: malformed `coverage` attribute input
-  --> $DIR/word-only.rs:28:5
+  --> $DIR/word-only.rs:29:5
    |
 LL |     #[coverage]
    |     ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -65,8 +73,16 @@ LL |     #[coverage(off)]
 LL |     #[coverage(on)]
    |               ++++
 
+error: `#[coverage]` attribute cannot be used on associated consts
+  --> $DIR/word-only.rs:29:5
+   |
+LL |     #[coverage]
+   |     ^^^^^^^^^^^
+   |
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
+
 error[E0539]: malformed `coverage` attribute input
-  --> $DIR/word-only.rs:33:1
+  --> $DIR/word-only.rs:35:1
    |
 LL | #[coverage]
    | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -78,8 +94,16 @@ LL | #[coverage(off)]
 LL | #[coverage(on)]
    |           ++++
 
+error: `#[coverage]` attribute cannot be used on traits
+  --> $DIR/word-only.rs:35:1
+   |
+LL | #[coverage]
+   | ^^^^^^^^^^^
+   |
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
+
 error[E0539]: malformed `coverage` attribute input
-  --> $DIR/word-only.rs:36:5
+  --> $DIR/word-only.rs:39:5
    |
 LL |     #[coverage]
    |     ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -91,8 +115,16 @@ LL |     #[coverage(off)]
 LL |     #[coverage(on)]
    |               ++++
 
+error: `#[coverage]` attribute cannot be used on associated consts
+  --> $DIR/word-only.rs:39:5
+   |
+LL |     #[coverage]
+   |     ^^^^^^^^^^^
+   |
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
+
 error[E0539]: malformed `coverage` attribute input
-  --> $DIR/word-only.rs:40:5
+  --> $DIR/word-only.rs:44:5
    |
 LL |     #[coverage]
    |     ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -104,8 +136,16 @@ LL |     #[coverage(off)]
 LL |     #[coverage(on)]
    |               ++++
 
+error: `#[coverage]` attribute cannot be used on associated types
+  --> $DIR/word-only.rs:44:5
+   |
+LL |     #[coverage]
+   |     ^^^^^^^^^^^
+   |
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
+
 error[E0539]: malformed `coverage` attribute input
-  --> $DIR/word-only.rs:45:1
+  --> $DIR/word-only.rs:50:1
    |
 LL | #[coverage]
    | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -118,7 +158,7 @@ LL | #[coverage(on)]
    |           ++++
 
 error[E0539]: malformed `coverage` attribute input
-  --> $DIR/word-only.rs:48:5
+  --> $DIR/word-only.rs:53:5
    |
 LL |     #[coverage]
    |     ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -130,8 +170,16 @@ LL |     #[coverage(off)]
 LL |     #[coverage(on)]
    |               ++++
 
+error: `#[coverage]` attribute cannot be used on associated consts
+  --> $DIR/word-only.rs:53:5
+   |
+LL |     #[coverage]
+   |     ^^^^^^^^^^^
+   |
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
+
 error[E0539]: malformed `coverage` attribute input
-  --> $DIR/word-only.rs:52:5
+  --> $DIR/word-only.rs:58:5
    |
 LL |     #[coverage]
    |     ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -143,8 +191,16 @@ LL |     #[coverage(off)]
 LL |     #[coverage(on)]
    |               ++++
 
+error: `#[coverage]` attribute cannot be used on associated types
+  --> $DIR/word-only.rs:58:5
+   |
+LL |     #[coverage]
+   |     ^^^^^^^^^^^
+   |
+   = help: `#[coverage]` can be applied to functions, impl blocks, modules, crates
+
 error[E0539]: malformed `coverage` attribute input
-  --> $DIR/word-only.rs:57:1
+  --> $DIR/word-only.rs:64:1
    |
 LL | #[coverage]
    | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument
@@ -156,6 +212,6 @@ LL | #[coverage(off)]
 LL | #[coverage(on)]
    |           ++++
 
-error: aborting due to 12 previous errors
+error: aborting due to 19 previous errors
 
 For more information about this error, try `rustc --explain E0539`.
diff --git a/tests/ui/deprecation/deprecation-sanity.rs b/tests/ui/deprecation/deprecation-sanity.rs
index 80198ab8196..9698a376025 100644
--- a/tests/ui/deprecation/deprecation-sanity.rs
+++ b/tests/ui/deprecation/deprecation-sanity.rs
@@ -1,3 +1,5 @@
+#![deny(unused_attributes)]
+
 // Various checks that deprecation attributes are used correctly
 
 mod bogus_attribute_types_1 {
@@ -32,7 +34,8 @@ fn f1() { }
 
 struct X;
 
-#[deprecated = "hello"] //~ ERROR this `#[deprecated]` annotation has no effect
+#[deprecated = "hello"] //~ ERROR attribute cannot be used on
+//~| WARN previously accepted
 impl Default for X {
     fn default() -> Self {
         X
diff --git a/tests/ui/deprecation/deprecation-sanity.stderr b/tests/ui/deprecation/deprecation-sanity.stderr
index 856f51a4b24..1d44215731d 100644
--- a/tests/ui/deprecation/deprecation-sanity.stderr
+++ b/tests/ui/deprecation/deprecation-sanity.stderr
@@ -1,11 +1,11 @@
 error[E0541]: unknown meta item 'reason'
-  --> $DIR/deprecation-sanity.rs:4:43
+  --> $DIR/deprecation-sanity.rs:6:43
    |
 LL |     #[deprecated(since = "a", note = "a", reason)]
    |                                           ^^^^^^ expected one of `since`, `note`
 
 error[E0539]: malformed `deprecated` attribute input
-  --> $DIR/deprecation-sanity.rs:7:5
+  --> $DIR/deprecation-sanity.rs:9:5
    |
 LL |     #[deprecated(since = "a", note)]
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^----^^
@@ -29,7 +29,7 @@ LL +     #[deprecated(since = "version", note = "reason")]
    = and 1 other candidate
 
 error[E0539]: malformed `deprecated` attribute input
-  --> $DIR/deprecation-sanity.rs:10:5
+  --> $DIR/deprecation-sanity.rs:12:5
    |
 LL |     #[deprecated(since, note = "a")]
    |     ^^^^^^^^^^^^^-----^^^^^^^^^^^^^^
@@ -53,7 +53,7 @@ LL +     #[deprecated(since = "version", note = "reason")]
    = and 1 other candidate
 
 error[E0539]: malformed `deprecated` attribute input
-  --> $DIR/deprecation-sanity.rs:13:5
+  --> $DIR/deprecation-sanity.rs:15:5
    |
 LL |     #[deprecated(since = "a", note(b))]
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^-------^^
@@ -77,7 +77,7 @@ LL +     #[deprecated(since = "version", note = "reason")]
    = and 1 other candidate
 
 error[E0539]: malformed `deprecated` attribute input
-  --> $DIR/deprecation-sanity.rs:16:5
+  --> $DIR/deprecation-sanity.rs:18:5
    |
 LL |     #[deprecated(since(b), note = "a")]
    |     ^^^^^^^^^^^^^--------^^^^^^^^^^^^^^
@@ -101,7 +101,7 @@ LL +     #[deprecated(since = "version", note = "reason")]
    = and 1 other candidate
 
 error[E0539]: malformed `deprecated` attribute input
-  --> $DIR/deprecation-sanity.rs:19:5
+  --> $DIR/deprecation-sanity.rs:21:5
    |
 LL |     #[deprecated(note = b"test")]
    |     ^^^^^^^^^^^^^^^^^^^^-^^^^^^^^
@@ -111,7 +111,7 @@ LL |     #[deprecated(note = b"test")]
    = note: expected a normal string literal, not a byte string literal
 
 error[E0565]: malformed `deprecated` attribute input
-  --> $DIR/deprecation-sanity.rs:22:5
+  --> $DIR/deprecation-sanity.rs:24:5
    |
 LL |     #[deprecated("test")]
    |     ^^^^^^^^^^^^^------^^
@@ -135,19 +135,19 @@ LL +     #[deprecated(since = "version", note = "reason")]
    = and 1 other candidate
 
 error: multiple `deprecated` attributes
-  --> $DIR/deprecation-sanity.rs:27:1
+  --> $DIR/deprecation-sanity.rs:29:1
    |
 LL | #[deprecated(since = "a", note = "b")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
    |
 note: attribute also specified here
-  --> $DIR/deprecation-sanity.rs:26:1
+  --> $DIR/deprecation-sanity.rs:28:1
    |
 LL | #[deprecated(since = "a", note = "b")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0538]: malformed `deprecated` attribute input
-  --> $DIR/deprecation-sanity.rs:30:1
+  --> $DIR/deprecation-sanity.rs:32:1
    |
 LL | #[deprecated(since = "a", since = "b", note = "c")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^-----------^^^^^^^^^^^^^^
@@ -170,12 +170,14 @@ LL + #[deprecated(since = "version", note = "reason")]
    |
    = and 1 other candidate
 
-error: this `#[deprecated]` annotation has no effect
-  --> $DIR/deprecation-sanity.rs:35:1
+error: `#[deprecated]` attribute cannot be used on trait impl blocks
+  --> $DIR/deprecation-sanity.rs:37:1
    |
 LL | #[deprecated = "hello"]
-   | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove the unnecessary deprecation attribute
+   | ^^^^^^^^^^^^^^^^^^^^^^^
    |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, crates
    = note: `#[deny(useless_deprecated)]` on by default
 
 error: aborting due to 10 previous errors
diff --git a/tests/ui/error-codes/E0518.rs b/tests/ui/error-codes/E0518.rs
deleted file mode 100644
index 9c99702ada8..00000000000
--- a/tests/ui/error-codes/E0518.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-#[inline(always)] //~ ERROR: E0518
-struct Foo;
-
-#[inline(never)] //~ ERROR: E0518
-impl Foo {
-}
-
-fn main() {
-}
diff --git a/tests/ui/error-codes/E0518.stderr b/tests/ui/error-codes/E0518.stderr
deleted file mode 100644
index 561446f8175..00000000000
--- a/tests/ui/error-codes/E0518.stderr
+++ /dev/null
@@ -1,20 +0,0 @@
-error[E0518]: attribute should be applied to function or closure
-  --> $DIR/E0518.rs:1:1
-   |
-LL | #[inline(always)]
-   | ^^^^^^^^^^^^^^^^^
-LL | struct Foo;
-   | ----------- not a function or closure
-
-error[E0518]: attribute should be applied to function or closure
-  --> $DIR/E0518.rs:4:1
-   |
-LL |   #[inline(never)]
-   |   ^^^^^^^^^^^^^^^^
-LL | / impl Foo {
-LL | | }
-   | |_- not a function or closure
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0518`.
diff --git a/tests/ui/error-codes/E0718.stderr b/tests/ui/error-codes/E0718.stderr
index ec7462765f8..e7784d193ba 100644
--- a/tests/ui/error-codes/E0718.stderr
+++ b/tests/ui/error-codes/E0718.stderr
@@ -2,7 +2,7 @@ error[E0718]: `owned_box` lang item must be applied to a struct
   --> $DIR/E0718.rs:4:1
    |
 LL | #[lang = "owned_box"]
-   | ^^^^^^^^^^^^^^^^^^^^^ attribute should be applied to a struct, not a static item
+   | ^^^^^^^^^^^^^^^^^^^^^ attribute should be applied to a struct, not a static
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/extern/extern-no-mangle.rs b/tests/ui/extern/extern-no-mangle.rs
index dba9689a075..6f2d125b923 100644
--- a/tests/ui/extern/extern-no-mangle.rs
+++ b/tests/ui/extern/extern-no-mangle.rs
@@ -9,21 +9,21 @@
 
 extern "C" {
     #[no_mangle]
-    //~^ WARNING `#[no_mangle]` has no effect on a foreign static
-    //~^^ WARNING this was previously accepted by the compiler
+    //~^ WARNING attribute cannot be used on
+    //~| WARN previously accepted
     pub static FOO: u8;
 
     #[no_mangle]
-    //~^ WARNING `#[no_mangle]` has no effect on a foreign function
-    //~^^ WARNING this was previously accepted by the compiler
+    //~^ WARNING attribute cannot be used on
+    //~| WARN previously accepted
     pub fn bar();
 }
 
 fn no_new_warn() {
     // Should emit the generic "not a function or static" warning
     #[no_mangle]
-    //~^ WARNING attribute should be applied to a free function, impl method or static
-    //~^^ WARNING this was previously accepted by the compiler
+    //~^ WARNING attribute cannot be used on
+    //~| WARN previously accepted
     let x = 0_u8;
 }
 
diff --git a/tests/ui/extern/extern-no-mangle.stderr b/tests/ui/extern/extern-no-mangle.stderr
index f20ee158ac4..b07cf0d4b4d 100644
--- a/tests/ui/extern/extern-no-mangle.stderr
+++ b/tests/ui/extern/extern-no-mangle.stderr
@@ -1,42 +1,34 @@
-warning: attribute should be applied to a free function, impl method or static
-  --> $DIR/extern-no-mangle.rs:24:5
+warning: `#[no_mangle]` attribute cannot be used on foreign statics
+  --> $DIR/extern-no-mangle.rs:11:5
    |
 LL |     #[no_mangle]
    |     ^^^^^^^^^^^^
-...
-LL |     let x = 0_u8;
-   |     ------------- not a free function, impl method or static
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[no_mangle]` can be applied to functions, statics
 note: the lint level is defined here
   --> $DIR/extern-no-mangle.rs:1:9
    |
 LL | #![warn(unused_attributes)]
    |         ^^^^^^^^^^^^^^^^^
 
-warning: `#[no_mangle]` has no effect on a foreign static
-  --> $DIR/extern-no-mangle.rs:11:5
+warning: `#[no_mangle]` attribute cannot be used on foreign functions
+  --> $DIR/extern-no-mangle.rs:16:5
    |
 LL |     #[no_mangle]
-   |     ^^^^^^^^^^^^ help: remove this attribute
-...
-LL |     pub static FOO: u8;
-   |     ------------------- foreign static
+   |     ^^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-   = note: symbol names in extern blocks are not mangled
+   = help: `#[no_mangle]` can be applied to methods, functions, statics
 
-warning: `#[no_mangle]` has no effect on a foreign function
-  --> $DIR/extern-no-mangle.rs:16:5
+warning: `#[no_mangle]` attribute cannot be used on statements
+  --> $DIR/extern-no-mangle.rs:24:5
    |
 LL |     #[no_mangle]
-   |     ^^^^^^^^^^^^ help: remove this attribute
-...
-LL |     pub fn bar();
-   |     ------------- foreign function
+   |     ^^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-   = note: symbol names in extern blocks are not mangled
+   = help: `#[no_mangle]` can be applied to functions, statics
 
 warning: 3 warnings emitted
 
diff --git a/tests/ui/extern/issue-47725.rs b/tests/ui/extern/issue-47725.rs
index 8ac866dc7d9..b0a0af930de 100644
--- a/tests/ui/extern/issue-47725.rs
+++ b/tests/ui/extern/issue-47725.rs
@@ -1,22 +1,25 @@
 #![warn(unused_attributes)] //~ NOTE lint level is defined here
 
 #[link_name = "foo"]
-//~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
-//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-struct Foo; //~ NOTE not a foreign function or static
+//~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+//~| HELP can be applied to
+struct Foo;
 
 #[link_name = "foobar"]
-//~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
-//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-//~| HELP try `#[link(name = "foobar")]` instead
+//~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+//~| HELP can be applied to
 extern "C" {
     fn foo() -> u32;
 }
-//~^^^ NOTE not a foreign function or static
 
 #[link_name]
 //~^ ERROR malformed `link_name` attribute input
 //~| HELP must be of the form
+//~| WARN attribute cannot be used on
+//~| WARN previously accepted
+//~| HELP can be applied to
 //~| NOTE for more information, visit
 extern "C" {
     fn bar() -> u32;
diff --git a/tests/ui/extern/issue-47725.stderr b/tests/ui/extern/issue-47725.stderr
index c5af54b8029..704b1d81b63 100644
--- a/tests/ui/extern/issue-47725.stderr
+++ b/tests/ui/extern/issue-47725.stderr
@@ -6,40 +6,38 @@ LL | #[link_name]
    |
    = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_name-attribute>
 
-warning: attribute should be applied to a foreign function or static
+warning: `#[link_name]` attribute cannot be used on structs
   --> $DIR/issue-47725.rs:3:1
    |
 LL | #[link_name = "foo"]
    | ^^^^^^^^^^^^^^^^^^^^
-...
-LL | struct Foo;
-   | ----------- not a foreign function or static
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[link_name]` can be applied to foreign functions, foreign statics
 note: the lint level is defined here
   --> $DIR/issue-47725.rs:1:9
    |
 LL | #![warn(unused_attributes)]
    |         ^^^^^^^^^^^^^^^^^
 
-warning: attribute should be applied to a foreign function or static
-  --> $DIR/issue-47725.rs:8:1
+warning: `#[link_name]` attribute cannot be used on foreign modules
+  --> $DIR/issue-47725.rs:9:1
    |
-LL |   #[link_name = "foobar"]
-   |   ^^^^^^^^^^^^^^^^^^^^^^^
-...
-LL | / extern "C" {
-LL | |     fn foo() -> u32;
-LL | | }
-   | |_- not a foreign function or static
+LL | #[link_name = "foobar"]
+   | ^^^^^^^^^^^^^^^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-help: try `#[link(name = "foobar")]` instead
-  --> $DIR/issue-47725.rs:8:1
+   = help: `#[link_name]` can be applied to foreign functions, foreign statics
+
+warning: `#[link_name]` attribute cannot be used on foreign modules
+  --> $DIR/issue-47725.rs:17:1
    |
-LL | #[link_name = "foobar"]
-   | ^^^^^^^^^^^^^^^^^^^^^^^
+LL | #[link_name]
+   | ^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[link_name]` can be applied to foreign functions, foreign statics
 
-error: aborting due to 1 previous error; 2 warnings emitted
+error: aborting due to 1 previous error; 3 warnings emitted
 
 For more information about this error, try `rustc --explain E0539`.
diff --git a/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs
index 81b7fe3db2b..91caba81cb6 100644
--- a/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs
+++ b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs
@@ -4,7 +4,7 @@
 // FIXME(jdonszelmann): empty attributes are currently ignored, since when its empty no actual
 // change is applied. This should be fixed when later moving this check to attribute parsing.
 #[allow_internal_unstable(something)] //~ ERROR allow_internal_unstable side-steps
-//~| ERROR attribute should
+//~| ERROR attribute cannot be used on
 struct S;
 
 fn main() {}
diff --git a/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr
index 076f2df28e3..cb8cf29e99d 100644
--- a/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr
+++ b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr
@@ -7,14 +7,13 @@ LL | #[allow_internal_unstable(something)]
    = help: add `#![feature(allow_internal_unstable)]` to the crate attributes to enable
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
 
-error: attribute should be applied to a macro
+error: `#[allow_internal_unstable]` attribute cannot be used on structs
   --> $DIR/feature-gate-allow-internal-unstable-struct.rs:6:1
    |
 LL | #[allow_internal_unstable(something)]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | struct S;
-   | --------- not a macro
+   |
+   = help: `#[allow_internal_unstable]` can be applied to macro defs, functions
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs
index 7fb11b7bde7..130dd48b0fe 100644
--- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs
+++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.rs
@@ -1,6 +1,4 @@
 //~ NOTE: not an `extern crate` item
-//~^ NOTE: not a free function, impl method or static
-//~^^ NOTE: not a function or closure
 // This is testing whether various builtin attributes signals an
 // error or warning when put in "weird" places.
 //
@@ -19,29 +17,25 @@
 #![repr()]
 //~^ ERROR: `repr` attribute cannot be used at crate level
 #![path = "3800"]
-//~^ ERROR: `path` attribute cannot be used at crate level
+//~^ ERROR: attribute cannot be used on
 #![automatically_derived]
-//~^ ERROR: `automatically_derived` attribute cannot be used at crate level
+//~^ ERROR: attribute cannot be used on
 #![no_mangle]
 #![no_link]
 //~^ ERROR: attribute should be applied to an `extern crate` item
 #![export_name = "2200"]
-//~^ ERROR: attribute should be applied to a free function, impl method or static
+//~^ ERROR: attribute cannot be used on
 #![inline]
-//~^ ERROR: attribute should be applied to function or closure
+//~^ ERROR: attribute cannot be used on
 #[inline]
-//~^ ERROR attribute should be applied to function or closure
+//~^ ERROR attribute cannot be used on
 mod inline {
-    //~^ NOTE not a function or closure
-    //~| NOTE the inner attribute doesn't annotate this module
-    //~| NOTE the inner attribute doesn't annotate this module
-    //~| NOTE the inner attribute doesn't annotate this module
+    //~^ NOTE the inner attribute doesn't annotate this module
     //~| NOTE the inner attribute doesn't annotate this module
     //~| NOTE the inner attribute doesn't annotate this module
 
     mod inner { #![inline] }
-    //~^ ERROR attribute should be applied to function or closure
-    //~| NOTE not a function or closure
+    //~^ ERROR attribute cannot be used on
 
     #[inline = "2100"] fn f() { }
     //~^ ERROR valid forms for the attribute are
@@ -50,16 +44,13 @@ mod inline {
     //~| NOTE for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
 
     #[inline] struct S;
-    //~^ ERROR attribute should be applied to function or closure
-    //~| NOTE not a function or closure
+    //~^ ERROR attribute cannot be used on
 
     #[inline] type T = S;
-    //~^ ERROR attribute should be applied to function or closure
-    //~| NOTE not a function or closure
+    //~^ ERROR attribute cannot be used on
 
     #[inline] impl S { }
-    //~^ ERROR attribute should be applied to function or closure
-    //~| NOTE not a function or closure
+    //~^ ERROR attribute cannot be used on
 }
 
 #[no_link]
@@ -89,36 +80,27 @@ mod no_link {
 }
 
 #[export_name = "2200"]
-//~^ ERROR attribute should be applied to a free function, impl method or static
+//~^ ERROR attribute cannot be used on
 mod export_name {
-    //~^ NOTE not a free function, impl method or static
-
     mod inner { #![export_name="2200"] }
-    //~^ ERROR attribute should be applied to a free function, impl method or static
-    //~| NOTE not a free function, impl method or static
+    //~^ ERROR attribute cannot be used on
 
     #[export_name = "2200"] fn f() { }
 
     #[export_name = "2200"] struct S;
-    //~^ ERROR attribute should be applied to a free function, impl method or static
-    //~| NOTE not a free function, impl method or static
+    //~^ ERROR attribute cannot be used on
 
     #[export_name = "2200"] type T = S;
-    //~^ ERROR attribute should be applied to a free function, impl method or static
-    //~| NOTE not a free function, impl method or static
+    //~^ ERROR attribute cannot be used on
 
     #[export_name = "2200"] impl S { }
-    //~^ ERROR attribute should be applied to a free function, impl method or static
-    //~| NOTE not a free function, impl method or static
+    //~^ ERROR attribute cannot be used on
 
     trait Tr {
         #[export_name = "2200"] fn foo();
-        //~^ ERROR attribute should be applied to a free function, impl method or static
-        //~| NOTE not a free function, impl method or static
+        //~^ ERROR attribute cannot be used on
 
         #[export_name = "2200"] fn bar() {}
-        //~^ ERROR attribute should be applied to a free function, impl method or static
-        //~| NOTE not a free function, impl method or static
     }
 }
 
diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr
index 7550e26f4a7..13dce72a882 100644
--- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr
+++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr
@@ -1,5 +1,5 @@
 error[E0658]: use of an internal attribute
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:14:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:12:1
    |
 LL | #![rustc_main]
    | ^^^^^^^^^^^^^^
@@ -8,19 +8,128 @@ LL | #![rustc_main]
    = note: the `#[rustc_main]` attribute is an internal implementation detail that will never be stable
    = note: the `#[rustc_main]` attribute is used internally to specify test entry point function
 
-error[E0518]: attribute should be applied to function or closure
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:32:1
+error: `#[path]` attribute cannot be used on crates
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:19:1
    |
-LL |   #[inline]
-   |   ^^^^^^^^^
-LL |
-LL | / mod inline {
-...  |
-LL | | }
-   | |_- not a function or closure
+LL | #![path = "3800"]
+   | ^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[path]` can only be applied to modules
+
+error: `#[automatically_derived]` attribute cannot be used on crates
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:21:1
+   |
+LL | #![automatically_derived]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[automatically_derived]` can only be applied to trait impl blocks
+
+error: `#[export_name]` attribute cannot be used on crates
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:26:1
+   |
+LL | #![export_name = "2200"]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[export_name]` can be applied to functions, statics
+
+error: `#[inline]` attribute cannot be used on crates
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:28:1
+   |
+LL | #![inline]
+   | ^^^^^^^^^^
+   |
+   = help: `#[inline]` can only be applied to functions
+
+error: `#[inline]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:30:1
+   |
+LL | #[inline]
+   | ^^^^^^^^^
+   |
+   = help: `#[inline]` can only be applied to functions
+
+error: `#[inline]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:37:17
+   |
+LL |     mod inner { #![inline] }
+   |                 ^^^^^^^^^^
+   |
+   = help: `#[inline]` can only be applied to functions
+
+error: `#[inline]` attribute cannot be used on structs
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:46:5
+   |
+LL |     #[inline] struct S;
+   |     ^^^^^^^^^
+   |
+   = help: `#[inline]` can only be applied to functions
+
+error: `#[inline]` attribute cannot be used on type aliases
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:49:5
+   |
+LL |     #[inline] type T = S;
+   |     ^^^^^^^^^
+   |
+   = help: `#[inline]` can only be applied to functions
+
+error: `#[inline]` attribute cannot be used on inherent impl blocks
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:52:5
+   |
+LL |     #[inline] impl S { }
+   |     ^^^^^^^^^
+   |
+   = help: `#[inline]` can only be applied to functions
+
+error: `#[export_name]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:82:1
+   |
+LL | #[export_name = "2200"]
+   | ^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[export_name]` can be applied to functions, statics
+
+error: `#[export_name]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:85:17
+   |
+LL |     mod inner { #![export_name="2200"] }
+   |                 ^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[export_name]` can be applied to functions, statics
+
+error: `#[export_name]` attribute cannot be used on structs
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:90:5
+   |
+LL |     #[export_name = "2200"] struct S;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[export_name]` can be applied to functions, statics
+
+error: `#[export_name]` attribute cannot be used on type aliases
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:93:5
+   |
+LL |     #[export_name = "2200"] type T = S;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[export_name]` can be applied to functions, statics
+
+error: `#[export_name]` attribute cannot be used on inherent impl blocks
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:96:5
+   |
+LL |     #[export_name = "2200"] impl S { }
+   |     ^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[export_name]` can be applied to functions, statics
+
+error: `#[export_name]` attribute cannot be used on required trait methods
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:100:9
+   |
+LL |         #[export_name = "2200"] fn foo();
+   |         ^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[export_name]` can be applied to statics, functions, inherent methods, provided trait methods, trait methods in impl blocks
 
 error: attribute should be applied to an `extern crate` item
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:65:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:56:1
    |
 LL |   #[no_link]
    |   ^^^^^^^^^^
@@ -33,22 +142,8 @@ LL | |     mod inner { #![no_link] }
 LL | | }
    | |_- not an `extern crate` item
 
-error: attribute should be applied to a free function, impl method or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:91:1
-   |
-LL |   #[export_name = "2200"]
-   |   ^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | / mod export_name {
-LL | |
-LL | |
-LL | |     mod inner { #![export_name="2200"] }
-...  |
-LL | | }
-   | |_- not a free function, impl method or static
-
 error[E0517]: attribute should be applied to a struct, enum, or union
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:125:8
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:107:8
    |
 LL |   #[repr(C)]
    |          ^
@@ -61,7 +156,7 @@ LL | | }
    | |_- not a struct, enum, or union
 
 error[E0517]: attribute should be applied to a struct, enum, or union
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:149:8
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:131:8
    |
 LL |   #[repr(Rust)]
    |          ^^^^
@@ -74,25 +169,13 @@ LL | | }
    | |_- not a struct, enum, or union
 
 error: attribute should be applied to an `extern crate` item
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:26:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:24:1
    |
 LL | #![no_link]
    | ^^^^^^^^^^^ not an `extern crate` item
 
-error: attribute should be applied to a free function, impl method or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:28:1
-   |
-LL | #![export_name = "2200"]
-   | ^^^^^^^^^^^^^^^^^^^^^^^^ not a free function, impl method or static
-
-error[E0518]: attribute should be applied to function or closure
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:30:1
-   |
-LL | #![inline]
-   | ^^^^^^^^^^ not a function or closure
-
 error: `macro_export` attribute cannot be used at crate level
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:12:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:10:1
    |
 LL | #![macro_export]
    | ^^^^^^^^^^^^^^^^
@@ -107,7 +190,7 @@ LL + #[macro_export]
    |
 
 error: `rustc_main` attribute cannot be used at crate level
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:14:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:12:1
    |
 LL | #![rustc_main]
    | ^^^^^^^^^^^^^^
@@ -122,7 +205,7 @@ LL + #[rustc_main]
    |
 
 error: `repr` attribute cannot be used at crate level
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:19:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:17:1
    |
 LL | #![repr()]
    | ^^^^^^^^^^
@@ -136,176 +219,86 @@ LL - #![repr()]
 LL + #[repr()]
    |
 
-error: `path` attribute cannot be used at crate level
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:21:1
-   |
-LL | #![path = "3800"]
-   | ^^^^^^^^^^^^^^^^^
-...
-LL | mod inline {
-   |     ------ the inner attribute doesn't annotate this module
-   |
-help: perhaps you meant to use an outer attribute
-   |
-LL - #![path = "3800"]
-LL + #[path = "3800"]
-   |
-
-error: `automatically_derived` attribute cannot be used at crate level
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:23:1
-   |
-LL | #![automatically_derived]
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^
-...
-LL | mod inline {
-   |     ------ the inner attribute doesn't annotate this module
-   |
-help: perhaps you meant to use an outer attribute
-   |
-LL - #![automatically_derived]
-LL + #[automatically_derived]
-   |
-
-error[E0518]: attribute should be applied to function or closure
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:42:17
-   |
-LL |     mod inner { #![inline] }
-   |     ------------^^^^^^^^^^-- not a function or closure
-
-error[E0518]: attribute should be applied to function or closure
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:52:5
-   |
-LL |     #[inline] struct S;
-   |     ^^^^^^^^^ --------- not a function or closure
-
-error[E0518]: attribute should be applied to function or closure
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:56:5
-   |
-LL |     #[inline] type T = S;
-   |     ^^^^^^^^^ ----------- not a function or closure
-
-error[E0518]: attribute should be applied to function or closure
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:60:5
-   |
-LL |     #[inline] impl S { }
-   |     ^^^^^^^^^ ---------- not a function or closure
-
 error: attribute should be applied to an `extern crate` item
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:70:17
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:61:17
    |
 LL |     mod inner { #![no_link] }
    |     ------------^^^^^^^^^^^-- not an `extern crate` item
 
 error: attribute should be applied to an `extern crate` item
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:74:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:65:5
    |
 LL |     #[no_link] fn f() { }
    |     ^^^^^^^^^^ ---------- not an `extern crate` item
 
 error: attribute should be applied to an `extern crate` item
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:78:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:69:5
    |
 LL |     #[no_link] struct S;
    |     ^^^^^^^^^^ --------- not an `extern crate` item
 
 error: attribute should be applied to an `extern crate` item
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:82:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:73:5
    |
 LL |     #[no_link]type T = S;
    |     ^^^^^^^^^^----------- not an `extern crate` item
 
 error: attribute should be applied to an `extern crate` item
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:86:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:77:5
    |
 LL |     #[no_link] impl S { }
    |     ^^^^^^^^^^ ---------- not an `extern crate` item
 
-error: attribute should be applied to a free function, impl method or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:96:17
-   |
-LL |     mod inner { #![export_name="2200"] }
-   |     ------------^^^^^^^^^^^^^^^^^^^^^^-- not a free function, impl method or static
-
-error: attribute should be applied to a free function, impl method or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:102:5
-   |
-LL |     #[export_name = "2200"] struct S;
-   |     ^^^^^^^^^^^^^^^^^^^^^^^ --------- not a free function, impl method or static
-
-error: attribute should be applied to a free function, impl method or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:106:5
-   |
-LL |     #[export_name = "2200"] type T = S;
-   |     ^^^^^^^^^^^^^^^^^^^^^^^ ----------- not a free function, impl method or static
-
-error: attribute should be applied to a free function, impl method or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:110:5
-   |
-LL |     #[export_name = "2200"] impl S { }
-   |     ^^^^^^^^^^^^^^^^^^^^^^^ ---------- not a free function, impl method or static
-
-error: attribute should be applied to a free function, impl method or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:115:9
-   |
-LL |         #[export_name = "2200"] fn foo();
-   |         ^^^^^^^^^^^^^^^^^^^^^^^ --------- not a free function, impl method or static
-
-error: attribute should be applied to a free function, impl method or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:119:9
-   |
-LL |         #[export_name = "2200"] fn bar() {}
-   |         ^^^^^^^^^^^^^^^^^^^^^^^ ----------- not a free function, impl method or static
-
 error[E0517]: attribute should be applied to a struct, enum, or union
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:129:25
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:111:25
    |
 LL |     mod inner { #![repr(C)] }
    |     --------------------^---- not a struct, enum, or union
 
 error[E0517]: attribute should be applied to a struct, enum, or union
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:133:12
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:115:12
    |
 LL |     #[repr(C)] fn f() { }
    |            ^   ---------- not a struct, enum, or union
 
 error[E0517]: attribute should be applied to a struct, enum, or union
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:139:12
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:121:12
    |
 LL |     #[repr(C)] type T = S;
    |            ^   ----------- not a struct, enum, or union
 
 error[E0517]: attribute should be applied to a struct, enum, or union
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:143:12
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:125:12
    |
 LL |     #[repr(C)] impl S { }
    |            ^   ---------- not a struct, enum, or union
 
 error[E0517]: attribute should be applied to a struct, enum, or union
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:153:25
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:135:25
    |
 LL |     mod inner { #![repr(Rust)] }
    |     --------------------^^^^---- not a struct, enum, or union
 
 error[E0517]: attribute should be applied to a struct, enum, or union
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:157:12
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:139:12
    |
 LL |     #[repr(Rust)] fn f() { }
    |            ^^^^   ---------- not a struct, enum, or union
 
 error[E0517]: attribute should be applied to a struct, enum, or union
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:163:12
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:145:12
    |
 LL |     #[repr(Rust)] type T = S;
    |            ^^^^   ----------- not a struct, enum, or union
 
 error[E0517]: attribute should be applied to a struct, enum, or union
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:167:12
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:149:12
    |
 LL |     #[repr(Rust)] impl S { }
    |            ^^^^   ---------- not a struct, enum, or union
 
 error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:46:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:40:5
    |
 LL |     #[inline = "2100"] fn f() { }
    |     ^^^^^^^^^^^^^^^^^^
@@ -314,13 +307,13 @@ LL |     #[inline = "2100"] fn f() { }
    = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571>
    = note: `#[deny(ill_formed_attribute_input)]` on by default
 
-error: aborting due to 38 previous errors
+error: aborting due to 37 previous errors
 
-Some errors have detailed explanations: E0517, E0518, E0658.
+Some errors have detailed explanations: E0517, E0658.
 For more information about an error, try `rustc --explain E0517`.
 Future incompatibility report: Future breakage diagnostic:
 error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:46:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:40:5
    |
 LL |     #[inline = "2100"] fn f() { }
    |     ^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs
index c91fd600068..8702d852a89 100644
--- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs
+++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs
@@ -1,7 +1,4 @@
-//~ NOTE not a function
-//~| NOTE not a foreign function or static
-//~| NOTE cannot be applied to crates
-//~| NOTE not an `extern` block
+//~ NOTE not an `extern` block
 // This test enumerates as many compiler-builtin ungated attributes as
 // possible (that is, all the mutually compatible ones), and checks
 // that we get "expected" (*) warnings for each in the various weird
@@ -50,25 +47,34 @@
 #![macro_use] // (allowed if no argument; see issue-43160-gating-of-macro_use.rs)
 // skipping testing of cfg
 // skipping testing of cfg_attr
-#![should_panic] //~ WARN `#[should_panic]` only has an effect
-#![ignore] //~ WARN `#[ignore]` only has an effect on functions
+#![should_panic] //~ WARN attribute cannot be used on
+//~| WARN previously accepted
+//~| HELP can only be applied to
+#![ignore] //~ WARN attribute cannot be used on
+//~| WARN previously accepted
+//~| HELP can only be applied to
 #![no_implicit_prelude]
 #![reexport_test_harness_main = "2900"]
 // see gated-link-args.rs
 // see issue-43106-gating-of-macro_escape.rs for crate-level; but non crate-level is below at "2700"
 // (cannot easily test gating of crate-level #[no_std]; but non crate-level is below at "2600")
-#![proc_macro_derive(Test)] //~ WARN `#[proc_macro_derive]` only has an effect
+#![proc_macro_derive(Test)] //~ WARN attribute cannot be used on
+//~| WARN previously accepted
+//~| HELP can only be applied to
 #![doc = "2400"]
-#![cold] //~ WARN attribute should be applied to a function
-//~^ WARN this was previously accepted
+#![cold] //~ WARN attribute cannot be used on
+//~| WARN previously accepted
+//~| HELP can only be applied to
 #![link()] //~ WARN attribute should be applied to an `extern` block
 //~^ WARN this was previously accepted
 #![link_name = "1900"]
-//~^ WARN attribute should be applied to a foreign function
-//~^^ WARN this was previously accepted by the compiler
+//~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+//~| HELP can be applied to
 #![link_section = "1800"]
-//~^ WARN attribute should be applied to a function or static
-//~^^ WARN this was previously accepted by the compiler
+//~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+//~| HELP can be applied to
 #![must_use]
 //~^ WARN `#[must_use]` has no effect
 //~| HELP remove the attribute
@@ -175,16 +181,24 @@ mod macro_use {
     mod inner { #![macro_use] }
 
     #[macro_use] fn f() { }
-    //~^ WARN `#[macro_use]` only has an effect
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can be applied to
 
     #[macro_use] struct S;
-    //~^ WARN `#[macro_use]` only has an effect
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can be applied to
 
     #[macro_use] type T = S;
-    //~^ WARN `#[macro_use]` only has an effect
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can be applied to
 
     #[macro_use] impl S { }
-    //~^ WARN `#[macro_use]` only has an effect
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can be applied to
 }
 
 #[macro_export]
@@ -243,116 +257,158 @@ mod path {
     mod inner { #![path="3800"] }
 
     #[path = "3800"] fn f() { }
-    //~^ WARN `#[path]` only has an effect
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can only be applied to
 
     #[path = "3800"]  struct S;
-    //~^ WARN `#[path]` only has an effect
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can only be applied to
 
     #[path = "3800"] type T = S;
-    //~^ WARN `#[path]` only has an effect
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can only be applied to
 
     #[path = "3800"] impl S { }
-    //~^ WARN `#[path]` only has an effect
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can only be applied to
 }
 
 #[automatically_derived]
-//~^ WARN `#[automatically_derived]` only has an effect
+//~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+//~| HELP can only be applied to
 mod automatically_derived {
     mod inner { #![automatically_derived] }
-    //~^ WARN `#[automatically_derived]
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can only be applied to
 
     #[automatically_derived] fn f() { }
-    //~^ WARN `#[automatically_derived]
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can only be applied to
 
     #[automatically_derived] struct S;
-    //~^ WARN `#[automatically_derived]
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can only be applied to
 
     #[automatically_derived] type T = S;
-    //~^ WARN `#[automatically_derived]
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can only be applied to
 
     #[automatically_derived] trait W { }
-    //~^ WARN `#[automatically_derived]
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can only be applied to
 
     #[automatically_derived] impl S { }
-    //~^ WARN `#[automatically_derived]
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can only be applied to
 
     #[automatically_derived] impl W for S { }
 }
 
 #[no_mangle]
-//~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes]
-//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+//~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+//~| HELP can be applied to
 mod no_mangle {
-    //~^ NOTE not a free function, impl method or static
     mod inner { #![no_mangle] }
-    //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes]
-    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-    //~| NOTE not a free function, impl method or static
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can be applied to
 
     #[no_mangle] fn f() { }
 
     #[no_mangle] struct S;
-    //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes]
-    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-    //~| NOTE not a free function, impl method or static
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can be applied to
 
     #[no_mangle] type T = S;
-    //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes]
-    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-    //~| NOTE not a free function, impl method or static
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can be applied to
 
     #[no_mangle] impl S { }
-    //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes]
-    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-    //~| NOTE not a free function, impl method or static
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can be applied to
 
     trait Tr {
         #[no_mangle] fn foo();
-        //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes]
-        //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-        //~| NOTE not a free function, impl method or static
+        //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+        //~| HELP can be applied to
 
         #[no_mangle] fn bar() {}
-        //~^ WARN attribute should be applied to a free function, impl method or static [unused_attributes]
-        //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-        //~| NOTE not a free function, impl method or static
+        //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+        //~| HELP can be applied to
     }
 }
 
 #[should_panic]
-//~^ WARN `#[should_panic]` only has an effect on
+//~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+//~| HELP can only be applied to
 mod should_panic {
     mod inner { #![should_panic] }
-    //~^ WARN `#[should_panic]` only has an effect on
+    //~^ WARN attribute cannot be used on
+    //~| WARN previously accepted
+    //~| HELP can only be applied to
 
     #[should_panic] fn f() { }
 
     #[should_panic] struct S;
-    //~^ WARN `#[should_panic]` only has an effect on
+    //~^ WARN attribute cannot be used on
+    //~| WARN previously accepted
+    //~| HELP can only be applied to
 
     #[should_panic] type T = S;
-    //~^ WARN `#[should_panic]` only has an effect on
+    //~^ WARN attribute cannot be used on
+    //~| WARN previously accepted
+    //~| HELP can only be applied to
 
     #[should_panic] impl S { }
-    //~^ WARN `#[should_panic]` only has an effect on
+    //~^ WARN attribute cannot be used on
+    //~| WARN previously accepted
+    //~| HELP can only be applied to
 }
 
 #[ignore]
-//~^ WARN `#[ignore]` only has an effect on functions
+//~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+//~| HELP can only be applied to
 mod ignore {
     mod inner { #![ignore] }
-    //~^ WARN `#[ignore]` only has an effect on functions
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can only be applied to
 
     #[ignore] fn f() { }
 
     #[ignore] struct S;
-    //~^ WARN `#[ignore]` only has an effect on functions
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can only be applied to
 
     #[ignore] type T = S;
-    //~^ WARN `#[ignore]` only has an effect on functions
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can only be applied to
 
     #[ignore] impl S { }
-    //~^ WARN `#[ignore]` only has an effect on functions
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can only be applied to
 }
 
 #[no_implicit_prelude]
@@ -360,16 +416,24 @@ mod no_implicit_prelude {
     mod inner { #![no_implicit_prelude] }
 
     #[no_implicit_prelude] fn f() { }
-    //~^ WARN `#[no_implicit_prelude]` only has an effect
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can be applied to
 
     #[no_implicit_prelude] struct S;
-    //~^ WARN `#[no_implicit_prelude]` only has an effect
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can be applied to
 
     #[no_implicit_prelude] type T = S;
-    //~^ WARN `#[no_implicit_prelude]` only has an effect
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can be applied to
 
     #[no_implicit_prelude] impl S { }
-    //~^ WARN `#[no_implicit_prelude]` only has an effect
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can be applied to
 }
 
 #[reexport_test_harness_main = "2900"]
@@ -400,16 +464,24 @@ mod macro_escape {
     //~| HELP try an outer attribute: `#[macro_use]`
 
     #[macro_escape] fn f() { }
-    //~^ WARN `#[macro_escape]` only has an effect
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can be applied to
 
     #[macro_escape] struct S;
-    //~^ WARN `#[macro_escape]` only has an effect
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can be applied to
 
     #[macro_escape] type T = S;
-    //~^ WARN `#[macro_escape]` only has an effect
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can be applied to
 
     #[macro_escape] impl S { }
-    //~^ WARN `#[macro_escape]` only has an effect
+    //~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+    //~| HELP can be applied to
 }
 
 #[no_std]
@@ -449,100 +521,97 @@ mod doc {
 }
 
 #[cold]
-//~^ WARN attribute should be applied to a function
-//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+//~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+//~| HELP can only be applied to
 mod cold {
-    //~^ NOTE not a function
 
     mod inner { #![cold] }
-    //~^ WARN attribute should be applied to a function
-    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-    //~| NOTE not a function
+    //~^ WARN attribute cannot be used on
+    //~| WARN previously accepted
+    //~| HELP can only be applied to
 
     #[cold] fn f() { }
 
     #[cold] struct S;
-    //~^ WARN attribute should be applied to a function
-    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-    //~| NOTE not a function
+    //~^ WARN attribute cannot be used on
+    //~| WARN previously accepted
+    //~| HELP can only be applied to
 
     #[cold] type T = S;
-    //~^ WARN attribute should be applied to a function
-    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-    //~| NOTE not a function
+    //~^ WARN attribute cannot be used on
+    //~| WARN previously accepted
+    //~| HELP can only be applied to
 
     #[cold] impl S { }
-    //~^ WARN attribute should be applied to a function
-    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-    //~| NOTE not a function
+    //~^ WARN attribute cannot be used on
+    //~| WARN previously accepted
+    //~| HELP can only be applied to
 }
 
 #[link_name = "1900"]
-//~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
-//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+//~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+//~| HELP can be applied to
 mod link_name {
-    //~^ NOTE not a foreign function or static
-
     #[link_name = "1900"]
-    //~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
-    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-    //~| HELP try `#[link(name = "1900")]` instead
+    //~^ WARN attribute cannot be used on
+    //~| WARN previously accepted
+    //~| HELP can be applied to
     extern "C" { }
-    //~^ NOTE not a foreign function or static
 
     mod inner { #![link_name="1900"] }
-    //~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
-    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-    //~| NOTE not a foreign function or static
+    //~^ WARN attribute cannot be used on
+    //~| WARN previously accepted
+    //~| HELP can be applied to
 
     #[link_name = "1900"] fn f() { }
-    //~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
-    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-    //~| NOTE not a foreign function or static
+    //~^ WARN attribute cannot be used on
+    //~| WARN previously accepted
+    //~| HELP can be applied to
 
     #[link_name = "1900"] struct S;
-    //~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
-    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-    //~| NOTE not a foreign function or static
+    //~^ WARN attribute cannot be used on
+    //~| WARN previously accepted
+    //~| HELP can be applied to
 
     #[link_name = "1900"] type T = S;
-    //~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
-    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-    //~| NOTE not a foreign function or static
+    //~^ WARN attribute cannot be used on
+    //~| WARN previously accepted
+    //~| HELP can be applied to
 
     #[link_name = "1900"] impl S { }
-    //~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
-    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-    //~| NOTE not a foreign function or static
+    //~^ WARN attribute cannot be used on
+    //~| WARN previously accepted
+    //~| HELP can be applied to
 }
 
 #[link_section = "1800"]
-//~^ WARN attribute should be applied to a function or static [unused_attributes]
-//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+//~^ WARN attribute cannot be used on
+//~| WARN previously accepted
+//~| HELP can be applied to
 mod link_section {
-    //~^ NOTE not a function or static
-
     mod inner { #![link_section="1800"] }
-    //~^ WARN attribute should be applied to a function or static [unused_attributes]
-    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-    //~| NOTE not a function or static
+    //~^ WARN attribute cannot be used on
+    //~| WARN previously accepted
+    //~| HELP can be applied to
 
     #[link_section = "1800"] fn f() { }
 
     #[link_section = "1800"] struct S;
-    //~^ WARN attribute should be applied to a function or static [unused_attributes]
-    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-    //~| NOTE not a function or static
+    //~^ WARN attribute cannot be used on
+    //~| WARN previously accepted
+    //~| HELP can be applied to
 
     #[link_section = "1800"] type T = S;
-    //~^ WARN attribute should be applied to a function or static [unused_attributes]
-    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-    //~| NOTE not a function or static
+    //~^ WARN attribute cannot be used on
+    //~| WARN previously accepted
+    //~| HELP can be applied to
 
     #[link_section = "1800"] impl S { }
-    //~^ WARN attribute should be applied to a function or static [unused_attributes]
-    //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-    //~| NOTE not a function or static
+    //~^ WARN attribute cannot be used on
+    //~| WARN previously accepted
+    //~| HELP can be applied to
 }
 
 
diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr
index e0ea5382faa..8e2bffb91ca 100644
--- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr
+++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr
@@ -1,5 +1,5 @@
 warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:398:17
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:462:17
    |
 LL |     mod inner { #![macro_escape] }
    |                 ^^^^^^^^^^^^^^^^
@@ -7,292 +7,211 @@ LL |     mod inner { #![macro_escape] }
    = help: try an outer attribute: `#[macro_use]`
 
 warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:395:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:459:1
    |
 LL | #[macro_escape]
    | ^^^^^^^^^^^^^^^
 
 warning: unknown lint: `x5400`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:46:9
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:43:9
    |
 LL | #![warn(x5400)]
    |         ^^^^^
    |
 note: the lint level is defined here
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:40:28
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:37:28
    |
 LL | #![warn(unused_attributes, unknown_lints)]
    |                            ^^^^^^^^^^^^^
 
 warning: unknown lint: `x5300`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:47:10
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:44:10
    |
 LL | #![allow(x5300)]
    |          ^^^^^
 
 warning: unknown lint: `x5200`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:48:11
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:45:11
    |
 LL | #![forbid(x5200)]
    |           ^^^^^
 
 warning: unknown lint: `x5100`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:49:9
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:46:9
    |
 LL | #![deny(x5100)]
    |         ^^^^^
 
 warning: unknown lint: `x5400`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:97:8
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:103:8
    |
 LL | #[warn(x5400)]
    |        ^^^^^
 
 warning: unknown lint: `x5400`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:100:25
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:106:25
    |
 LL |     mod inner { #![warn(x5400)] }
    |                         ^^^^^
 
 warning: unknown lint: `x5400`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:103:12
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:109:12
    |
 LL |     #[warn(x5400)] fn f() { }
    |            ^^^^^
 
 warning: unknown lint: `x5400`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:106:12
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:112:12
    |
 LL |     #[warn(x5400)] struct S;
    |            ^^^^^
 
 warning: unknown lint: `x5400`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:109:12
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:115:12
    |
 LL |     #[warn(x5400)] type T = S;
    |            ^^^^^
 
 warning: unknown lint: `x5400`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:112:12
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:118:12
    |
 LL |     #[warn(x5400)] impl S { }
    |            ^^^^^
 
 warning: unknown lint: `x5300`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:116:9
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:122:9
    |
 LL | #[allow(x5300)]
    |         ^^^^^
 
 warning: unknown lint: `x5300`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:119:26
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:125:26
    |
 LL |     mod inner { #![allow(x5300)] }
    |                          ^^^^^
 
 warning: unknown lint: `x5300`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:122:13
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:128:13
    |
 LL |     #[allow(x5300)] fn f() { }
    |             ^^^^^
 
 warning: unknown lint: `x5300`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:125:13
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:131:13
    |
 LL |     #[allow(x5300)] struct S;
    |             ^^^^^
 
 warning: unknown lint: `x5300`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:128:13
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:134:13
    |
 LL |     #[allow(x5300)] type T = S;
    |             ^^^^^
 
 warning: unknown lint: `x5300`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:131:13
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:137:13
    |
 LL |     #[allow(x5300)] impl S { }
    |             ^^^^^
 
 warning: unknown lint: `x5200`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:135:10
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:141:10
    |
 LL | #[forbid(x5200)]
    |          ^^^^^
 
 warning: unknown lint: `x5200`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:138:27
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:144:27
    |
 LL |     mod inner { #![forbid(x5200)] }
    |                           ^^^^^
 
 warning: unknown lint: `x5200`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:141:14
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:147:14
    |
 LL |     #[forbid(x5200)] fn f() { }
    |              ^^^^^
 
 warning: unknown lint: `x5200`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:144:14
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:150:14
    |
 LL |     #[forbid(x5200)] struct S;
    |              ^^^^^
 
 warning: unknown lint: `x5200`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:147:14
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:153:14
    |
 LL |     #[forbid(x5200)] type T = S;
    |              ^^^^^
 
 warning: unknown lint: `x5200`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:150:14
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:156:14
    |
 LL |     #[forbid(x5200)] impl S { }
    |              ^^^^^
 
 warning: unknown lint: `x5100`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:154:8
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:160:8
    |
 LL | #[deny(x5100)]
    |        ^^^^^
 
 warning: unknown lint: `x5100`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:157:25
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:163:25
    |
 LL |     mod inner { #![deny(x5100)] }
    |                         ^^^^^
 
 warning: unknown lint: `x5100`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:160:12
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:166:12
    |
 LL |     #[deny(x5100)] fn f() { }
    |            ^^^^^
 
 warning: unknown lint: `x5100`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:163:12
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:169:12
    |
 LL |     #[deny(x5100)] struct S;
    |            ^^^^^
 
 warning: unknown lint: `x5100`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:166:12
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:172:12
    |
 LL |     #[deny(x5100)] type T = S;
    |            ^^^^^
 
 warning: unknown lint: `x5100`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:169:12
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:175:12
    |
 LL |     #[deny(x5100)] impl S { }
    |            ^^^^^
 
 warning: `#[macro_export]` only has an effect on macro definitions
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:190:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:204:1
    |
 LL | #[macro_export]
    | ^^^^^^^^^^^^^^^
    |
 note: the lint level is defined here
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:40:9
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:37:9
    |
 LL | #![warn(unused_attributes, unknown_lints)]
    |         ^^^^^^^^^^^^^^^^^
 
-warning: `#[automatically_derived]` only has an effect on trait implementation blocks
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:258:1
-   |
-LL | #[automatically_derived]
-   | ^^^^^^^^^^^^^^^^^^^^^^^^
-
-warning: attribute should be applied to a free function, impl method or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:282:1
-   |
-LL |   #[no_mangle]
-   |   ^^^^^^^^^^^^
-...
-LL | / mod no_mangle {
-LL | |
-LL | |     mod inner { #![no_mangle] }
-...  |
-LL | | }
-   | |_- not a free function, impl method or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: `#[should_panic]` only has an effect on functions
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:322:1
-   |
-LL | #[should_panic]
-   | ^^^^^^^^^^^^^^^
-
-warning: `#[ignore]` only has an effect on functions
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:340:1
-   |
-LL | #[ignore]
-   | ^^^^^^^^^
-
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:375:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:439:1
    |
 LL | #[reexport_test_harness_main = "2900"]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:415:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:487:1
    |
 LL | #[no_std]
    | ^^^^^^^^^
 
-warning: attribute should be applied to a function definition
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:451:1
-   |
-LL |   #[cold]
-   |   ^^^^^^^
-...
-LL | / mod cold {
-LL | |
-LL | |
-LL | |     mod inner { #![cold] }
-...  |
-LL | | }
-   | |_- not a function definition
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a foreign function or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:480:1
-   |
-LL |   #[link_name = "1900"]
-   |   ^^^^^^^^^^^^^^^^^^^^^
-...
-LL | / mod link_name {
-LL | |
-LL | |
-LL | |     #[link_name = "1900"]
-...  |
-LL | | }
-   | |_- not a foreign function or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a function or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:519:1
-   |
-LL |   #[link_section = "1800"]
-   |   ^^^^^^^^^^^^^^^^^^^^^^^^
-...
-LL | / mod link_section {
-LL | |
-LL | |
-LL | |     mod inner { #![link_section="1800"] }
-...  |
-LL | | }
-   | |_- not a function or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
 warning: attribute should be applied to an `extern` block with non-Rust ABI
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:551:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:620:1
    |
 LL |   #[link()]
    |   ^^^^^^^^^
@@ -307,564 +226,174 @@ LL | | }
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
 
-warning: `#[must_use]` has no effect when applied to a module
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:602:1
+warning: `#[must_use]` has no effect when applied to modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:671:1
    |
 LL | #[must_use]
    | ^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:619:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:688:1
    |
 LL | #[windows_subsystem = "windows"]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:640:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:709:1
    |
 LL | #[crate_name = "0900"]
    | ^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:659:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:728:1
    |
 LL | #[crate_type = "0800"]
    | ^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:678:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:747:1
    |
 LL | #[feature(x0600)]
    | ^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:698:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:767:1
    |
 LL | #[no_main]
    | ^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:717:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:786:1
    |
 LL | #[no_builtins]
    | ^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:736:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:805:1
    |
 LL | #[recursion_limit="0200"]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:755:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:824:1
    |
 LL | #[type_length_limit="0100"]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: attribute should be applied to an `extern` block with non-Rust ABI
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:64:1
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:68:1
    |
 LL | #![link()]
    | ^^^^^^^^^^ not an `extern` block
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
 
-warning: `#[ignore]` only has an effect on functions
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:54:1
-   |
-LL | #![ignore]
-   | ^^^^^^^^^^
-
-warning: attribute should be applied to a foreign function or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:66:1
-   |
-LL | #![link_name = "1900"]
-   | ^^^^^^^^^^^^^^^^^^^^^^ not a foreign function or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a function or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:69:1
-   |
-LL | #![link_section = "1800"]
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^ not a function or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: `#[must_use]` has no effect when applied to a module
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:72:1
+warning: `#[must_use]` has no effect when applied to modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:78:1
    |
 LL | #![must_use]
    | ^^^^^^^^^^^^
 
-warning: `#[proc_macro_derive]` only has an effect on functions
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:60:1
-   |
-LL | #![proc_macro_derive(Test)]
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-warning: `#[should_panic]` only has an effect on functions
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:53:1
-   |
-LL | #![should_panic]
-   | ^^^^^^^^^^^^^^^^
-
-warning: attribute should be applied to a function definition
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:62:1
-   |
-LL | #![cold]
-   | ^^^^^^^^ cannot be applied to crates
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
 warning: the feature `rust1` has been stable since 1.0.0 and no longer requires an attribute to enable
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:86:12
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:92:12
    |
 LL | #![feature(rust1)]
    |            ^^^^^
    |
    = note: `#[warn(stable_features)]` on by default
 
-warning: `#[macro_use]` only has an effect on `extern crate` and modules
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:177:5
-   |
-LL |     #[macro_use] fn f() { }
-   |     ^^^^^^^^^^^^
-
-warning: `#[macro_use]` only has an effect on `extern crate` and modules
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:180:5
-   |
-LL |     #[macro_use] struct S;
-   |     ^^^^^^^^^^^^
-
-warning: `#[macro_use]` only has an effect on `extern crate` and modules
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:183:5
-   |
-LL |     #[macro_use] type T = S;
-   |     ^^^^^^^^^^^^
-
-warning: `#[macro_use]` only has an effect on `extern crate` and modules
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:186:5
-   |
-LL |     #[macro_use] impl S { }
-   |     ^^^^^^^^^^^^
-
 warning: `#[macro_export]` only has an effect on macro definitions
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:193:17
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:207:17
    |
 LL |     mod inner { #![macro_export] }
    |                 ^^^^^^^^^^^^^^^^
 
 warning: `#[macro_export]` only has an effect on macro definitions
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:196:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:210:5
    |
 LL |     #[macro_export] fn f() { }
    |     ^^^^^^^^^^^^^^^
 
 warning: `#[macro_export]` only has an effect on macro definitions
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:199:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:213:5
    |
 LL |     #[macro_export] struct S;
    |     ^^^^^^^^^^^^^^^
 
 warning: `#[macro_export]` only has an effect on macro definitions
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:202:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:216:5
    |
 LL |     #[macro_export] type T = S;
    |     ^^^^^^^^^^^^^^^
 
 warning: `#[macro_export]` only has an effect on macro definitions
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:205:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:219:5
    |
 LL |     #[macro_export] impl S { }
    |     ^^^^^^^^^^^^^^^
 
-warning: `#[path]` only has an effect on modules
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:245:5
-   |
-LL |     #[path = "3800"] fn f() { }
-   |     ^^^^^^^^^^^^^^^^
-
-warning: `#[path]` only has an effect on modules
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:248:5
-   |
-LL |     #[path = "3800"]  struct S;
-   |     ^^^^^^^^^^^^^^^^
-
-warning: `#[path]` only has an effect on modules
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:251:5
-   |
-LL |     #[path = "3800"] type T = S;
-   |     ^^^^^^^^^^^^^^^^
-
-warning: `#[path]` only has an effect on modules
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:254:5
-   |
-LL |     #[path = "3800"] impl S { }
-   |     ^^^^^^^^^^^^^^^^
-
-warning: `#[automatically_derived]` only has an effect on trait implementation blocks
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:261:17
-   |
-LL |     mod inner { #![automatically_derived] }
-   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^
-
-warning: `#[automatically_derived]` only has an effect on trait implementation blocks
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:264:5
-   |
-LL |     #[automatically_derived] fn f() { }
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^
-
-warning: `#[automatically_derived]` only has an effect on trait implementation blocks
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:267:5
-   |
-LL |     #[automatically_derived] struct S;
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^
-
-warning: `#[automatically_derived]` only has an effect on trait implementation blocks
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:270:5
-   |
-LL |     #[automatically_derived] type T = S;
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^
-
-warning: `#[automatically_derived]` only has an effect on trait implementation blocks
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:273:5
-   |
-LL |     #[automatically_derived] trait W { }
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^
-
-warning: `#[automatically_derived]` only has an effect on trait implementation blocks
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:276:5
-   |
-LL |     #[automatically_derived] impl S { }
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^
-
-warning: attribute should be applied to a free function, impl method or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:287:17
-   |
-LL |     mod inner { #![no_mangle] }
-   |     ------------^^^^^^^^^^^^^-- not a free function, impl method or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a free function, impl method or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:294:5
-   |
-LL |     #[no_mangle] struct S;
-   |     ^^^^^^^^^^^^ --------- not a free function, impl method or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a free function, impl method or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:299:5
-   |
-LL |     #[no_mangle] type T = S;
-   |     ^^^^^^^^^^^^ ----------- not a free function, impl method or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a free function, impl method or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:304:5
-   |
-LL |     #[no_mangle] impl S { }
-   |     ^^^^^^^^^^^^ ---------- not a free function, impl method or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a free function, impl method or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:310:9
-   |
-LL |         #[no_mangle] fn foo();
-   |         ^^^^^^^^^^^^ --------- not a free function, impl method or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a free function, impl method or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:315:9
-   |
-LL |         #[no_mangle] fn bar() {}
-   |         ^^^^^^^^^^^^ ----------- not a free function, impl method or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: `#[should_panic]` only has an effect on functions
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:325:17
-   |
-LL |     mod inner { #![should_panic] }
-   |                 ^^^^^^^^^^^^^^^^
-
-warning: `#[should_panic]` only has an effect on functions
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:330:5
-   |
-LL |     #[should_panic] struct S;
-   |     ^^^^^^^^^^^^^^^
-
-warning: `#[should_panic]` only has an effect on functions
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:333:5
-   |
-LL |     #[should_panic] type T = S;
-   |     ^^^^^^^^^^^^^^^
-
-warning: `#[should_panic]` only has an effect on functions
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:336:5
-   |
-LL |     #[should_panic] impl S { }
-   |     ^^^^^^^^^^^^^^^
-
-warning: `#[ignore]` only has an effect on functions
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:343:17
-   |
-LL |     mod inner { #![ignore] }
-   |                 ^^^^^^^^^^
-
-warning: `#[ignore]` only has an effect on functions
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:348:5
-   |
-LL |     #[ignore] struct S;
-   |     ^^^^^^^^^
-
-warning: `#[ignore]` only has an effect on functions
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:351:5
-   |
-LL |     #[ignore] type T = S;
-   |     ^^^^^^^^^
-
-warning: `#[ignore]` only has an effect on functions
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:354:5
-   |
-LL |     #[ignore] impl S { }
-   |     ^^^^^^^^^
-
-warning: `#[no_implicit_prelude]` only has an effect on modules
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:362:5
-   |
-LL |     #[no_implicit_prelude] fn f() { }
-   |     ^^^^^^^^^^^^^^^^^^^^^^
-
-warning: `#[no_implicit_prelude]` only has an effect on modules
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:365:5
-   |
-LL |     #[no_implicit_prelude] struct S;
-   |     ^^^^^^^^^^^^^^^^^^^^^^
-
-warning: `#[no_implicit_prelude]` only has an effect on modules
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:368:5
-   |
-LL |     #[no_implicit_prelude] type T = S;
-   |     ^^^^^^^^^^^^^^^^^^^^^^
-
-warning: `#[no_implicit_prelude]` only has an effect on modules
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:371:5
-   |
-LL |     #[no_implicit_prelude] impl S { }
-   |     ^^^^^^^^^^^^^^^^^^^^^^
-
 warning: crate-level attribute should be in the root module
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:378:17
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:442:17
    |
 LL |     mod inner { #![reexport_test_harness_main="2900"] }
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:381:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:445:5
    |
 LL |     #[reexport_test_harness_main = "2900"] fn f() { }
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:384:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:448:5
    |
 LL |     #[reexport_test_harness_main = "2900"] struct S;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:387:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:451:5
    |
 LL |     #[reexport_test_harness_main = "2900"] type T = S;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:390:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:454:5
    |
 LL |     #[reexport_test_harness_main = "2900"] impl S { }
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-warning: `#[macro_escape]` only has an effect on `extern crate` and modules
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:402:5
-   |
-LL |     #[macro_escape] fn f() { }
-   |     ^^^^^^^^^^^^^^^
-
-warning: `#[macro_escape]` only has an effect on `extern crate` and modules
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:405:5
-   |
-LL |     #[macro_escape] struct S;
-   |     ^^^^^^^^^^^^^^^
-
-warning: `#[macro_escape]` only has an effect on `extern crate` and modules
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:408:5
-   |
-LL |     #[macro_escape] type T = S;
-   |     ^^^^^^^^^^^^^^^
-
-warning: `#[macro_escape]` only has an effect on `extern crate` and modules
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:411:5
-   |
-LL |     #[macro_escape] impl S { }
-   |     ^^^^^^^^^^^^^^^
-
 warning: crate-level attribute should be in the root module
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:418:17
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:490:17
    |
 LL |     mod inner { #![no_std] }
    |                 ^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:421:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:493:5
    |
 LL |     #[no_std] fn f() { }
    |     ^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:424:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:496:5
    |
 LL |     #[no_std] struct S;
    |     ^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:427:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:499:5
    |
 LL |     #[no_std] type T = S;
    |     ^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:430:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:502:5
    |
 LL |     #[no_std] impl S { }
    |     ^^^^^^^^^
 
-warning: attribute should be applied to a function definition
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:457:17
-   |
-LL |     mod inner { #![cold] }
-   |     ------------^^^^^^^^-- not a function definition
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a function definition
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:464:5
-   |
-LL |     #[cold] struct S;
-   |     ^^^^^^^ --------- not a function definition
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a function definition
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:469:5
-   |
-LL |     #[cold] type T = S;
-   |     ^^^^^^^ ----------- not a function definition
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a function definition
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:474:5
-   |
-LL |     #[cold] impl S { }
-   |     ^^^^^^^ ---------- not a function definition
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a foreign function or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:486:5
-   |
-LL |     #[link_name = "1900"]
-   |     ^^^^^^^^^^^^^^^^^^^^^
-...
-LL |     extern "C" { }
-   |     -------------- not a foreign function or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-help: try `#[link(name = "1900")]` instead
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:486:5
-   |
-LL |     #[link_name = "1900"]
-   |     ^^^^^^^^^^^^^^^^^^^^^
-
-warning: attribute should be applied to a foreign function or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:493:17
-   |
-LL |     mod inner { #![link_name="1900"] }
-   |     ------------^^^^^^^^^^^^^^^^^^^^-- not a foreign function or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a foreign function or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:498:5
-   |
-LL |     #[link_name = "1900"] fn f() { }
-   |     ^^^^^^^^^^^^^^^^^^^^^ ---------- not a foreign function or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a foreign function or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:503:5
-   |
-LL |     #[link_name = "1900"] struct S;
-   |     ^^^^^^^^^^^^^^^^^^^^^ --------- not a foreign function or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a foreign function or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:508:5
-   |
-LL |     #[link_name = "1900"] type T = S;
-   |     ^^^^^^^^^^^^^^^^^^^^^ ----------- not a foreign function or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a foreign function or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:513:5
-   |
-LL |     #[link_name = "1900"] impl S { }
-   |     ^^^^^^^^^^^^^^^^^^^^^ ---------- not a foreign function or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a function or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:525:17
-   |
-LL |     mod inner { #![link_section="1800"] }
-   |     ------------^^^^^^^^^^^^^^^^^^^^^^^-- not a function or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a function or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:532:5
-   |
-LL |     #[link_section = "1800"] struct S;
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^ --------- not a function or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a function or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:537:5
-   |
-LL |     #[link_section = "1800"] type T = S;
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^ ----------- not a function or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-warning: attribute should be applied to a function or static
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:542:5
-   |
-LL |     #[link_section = "1800"] impl S { }
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^ ---------- not a function or static
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
 warning: attribute should be applied to an `extern` block with non-Rust ABI
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:557:17
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:626:17
    |
 LL |     mod inner { #![link()] }
    |     ------------^^^^^^^^^^-- not an `extern` block
@@ -872,7 +401,7 @@ LL |     mod inner { #![link()] }
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
 
 warning: attribute should be applied to an `extern` block with non-Rust ABI
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:562:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:631:5
    |
 LL |     #[link()] fn f() { }
    |     ^^^^^^^^^ ---------- not an `extern` block
@@ -880,7 +409,7 @@ LL |     #[link()] fn f() { }
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
 
 warning: attribute should be applied to an `extern` block with non-Rust ABI
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:567:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:636:5
    |
 LL |     #[link()] struct S;
    |     ^^^^^^^^^ --------- not an `extern` block
@@ -888,7 +417,7 @@ LL |     #[link()] struct S;
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
 
 warning: attribute should be applied to an `extern` block with non-Rust ABI
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:572:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:641:5
    |
 LL |     #[link()] type T = S;
    |     ^^^^^^^^^ ----------- not an `extern` block
@@ -896,7 +425,7 @@ LL |     #[link()] type T = S;
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
 
 warning: attribute should be applied to an `extern` block with non-Rust ABI
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:577:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:646:5
    |
 LL |     #[link()] impl S { }
    |     ^^^^^^^^^ ---------- not an `extern` block
@@ -904,270 +433,837 @@ LL |     #[link()] impl S { }
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
 
 warning: attribute should be applied to an `extern` block with non-Rust ABI
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:582:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:651:5
    |
 LL |     #[link()] extern "Rust" {}
    |     ^^^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
 
-warning: `#[must_use]` has no effect when applied to a module
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:605:17
+warning: `#[must_use]` has no effect when applied to modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:674:17
    |
 LL |     mod inner { #![must_use] }
    |                 ^^^^^^^^^^^^
 
-warning: `#[must_use]` has no effect when applied to a type alias
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:612:5
+warning: `#[must_use]` has no effect when applied to type aliases
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:681:5
    |
 LL |     #[must_use] type T = S;
    |     ^^^^^^^^^^^
 
-warning: `#[must_use]` has no effect when applied to an inherent implementation block
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:615:5
+warning: `#[must_use]` has no effect when applied to inherent impl blocks
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:684:5
    |
 LL |     #[must_use] impl S { }
    |     ^^^^^^^^^^^
 
 warning: crate-level attribute should be in the root module
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:622:17
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:691:17
    |
 LL |     mod inner { #![windows_subsystem="windows"] }
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:625:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:694:5
    |
 LL |     #[windows_subsystem = "windows"] fn f() { }
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:628:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:697:5
    |
 LL |     #[windows_subsystem = "windows"] struct S;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:631:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:700:5
    |
 LL |     #[windows_subsystem = "windows"] type T = S;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:634:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:703:5
    |
 LL |     #[windows_subsystem = "windows"] impl S { }
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be in the root module
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:643:17
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:712:17
    |
 LL |     mod inner { #![crate_name="0900"] }
    |                 ^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:646:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:715:5
    |
 LL |     #[crate_name = "0900"] fn f() { }
    |     ^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:649:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:718:5
    |
 LL |     #[crate_name = "0900"] struct S;
    |     ^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:652:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:721:5
    |
 LL |     #[crate_name = "0900"] type T = S;
    |     ^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:655:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:724:5
    |
 LL |     #[crate_name = "0900"] impl S { }
    |     ^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be in the root module
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:662:17
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:731:17
    |
 LL |     mod inner { #![crate_type="0800"] }
    |                 ^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:665:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:734:5
    |
 LL |     #[crate_type = "0800"] fn f() { }
    |     ^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:668:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:737:5
    |
 LL |     #[crate_type = "0800"] struct S;
    |     ^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:671:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:740:5
    |
 LL |     #[crate_type = "0800"] type T = S;
    |     ^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:674:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:743:5
    |
 LL |     #[crate_type = "0800"] impl S { }
    |     ^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be in the root module
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:681:17
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:750:17
    |
 LL |     mod inner { #![feature(x0600)] }
    |                 ^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:684:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:753:5
    |
 LL |     #[feature(x0600)] fn f() { }
    |     ^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:687:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:756:5
    |
 LL |     #[feature(x0600)] struct S;
    |     ^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:690:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:759:5
    |
 LL |     #[feature(x0600)] type T = S;
    |     ^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:693:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:762:5
    |
 LL |     #[feature(x0600)] impl S { }
    |     ^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be in the root module
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:701:17
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:770:17
    |
 LL |     mod inner { #![no_main] }
    |                 ^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:704:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:773:5
    |
 LL |     #[no_main] fn f() { }
    |     ^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:707:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:776:5
    |
 LL |     #[no_main] struct S;
    |     ^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:710:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:779:5
    |
 LL |     #[no_main] type T = S;
    |     ^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:713:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:782:5
    |
 LL |     #[no_main] impl S { }
    |     ^^^^^^^^^^
 
 warning: crate-level attribute should be in the root module
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:720:17
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:789:17
    |
 LL |     mod inner { #![no_builtins] }
    |                 ^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:723:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:792:5
    |
 LL |     #[no_builtins] fn f() { }
    |     ^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:726:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:795:5
    |
 LL |     #[no_builtins] struct S;
    |     ^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:729:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:798:5
    |
 LL |     #[no_builtins] type T = S;
    |     ^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:732:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:801:5
    |
 LL |     #[no_builtins] impl S { }
    |     ^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be in the root module
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:739:17
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:808:17
    |
 LL |     mod inner { #![recursion_limit="0200"] }
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:742:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:811:5
    |
 LL |     #[recursion_limit="0200"] fn f() { }
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:745:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:814:5
    |
 LL |     #[recursion_limit="0200"] struct S;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:748:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:817:5
    |
 LL |     #[recursion_limit="0200"] type T = S;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:751:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:820:5
    |
 LL |     #[recursion_limit="0200"] impl S { }
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be in the root module
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:758:17
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:827:17
    |
 LL |     mod inner { #![type_length_limit="0100"] }
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:761:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:830:5
    |
 LL |     #[type_length_limit="0100"] fn f() { }
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:764:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:833:5
    |
 LL |     #[type_length_limit="0100"] struct S;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:767:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:836:5
    |
 LL |     #[type_length_limit="0100"] type T = S;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:770:5
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:839:5
    |
 LL |     #[type_length_limit="0100"] impl S { }
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+warning: `#[macro_use]` attribute cannot be used on functions
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:183:5
+   |
+LL |     #[macro_use] fn f() { }
+   |     ^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[macro_use]` can be applied to modules, extern crates, crates
+
+warning: `#[macro_use]` attribute cannot be used on structs
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:188:5
+   |
+LL |     #[macro_use] struct S;
+   |     ^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[macro_use]` can be applied to modules, extern crates, crates
+
+warning: `#[macro_use]` attribute cannot be used on type aliases
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:193:5
+   |
+LL |     #[macro_use] type T = S;
+   |     ^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[macro_use]` can be applied to modules, extern crates, crates
+
+warning: `#[macro_use]` attribute cannot be used on inherent impl blocks
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:198:5
+   |
+LL |     #[macro_use] impl S { }
+   |     ^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[macro_use]` can be applied to modules, extern crates, crates
+
+warning: `#[path]` attribute cannot be used on functions
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:259:5
+   |
+LL |     #[path = "3800"] fn f() { }
+   |     ^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[path]` can only be applied to modules
+
+warning: `#[path]` attribute cannot be used on structs
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:264:5
+   |
+LL |     #[path = "3800"]  struct S;
+   |     ^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[path]` can only be applied to modules
+
+warning: `#[path]` attribute cannot be used on type aliases
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:269:5
+   |
+LL |     #[path = "3800"] type T = S;
+   |     ^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[path]` can only be applied to modules
+
+warning: `#[path]` attribute cannot be used on inherent impl blocks
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:274:5
+   |
+LL |     #[path = "3800"] impl S { }
+   |     ^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[path]` can only be applied to modules
+
+warning: `#[automatically_derived]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:280:1
+   |
+LL | #[automatically_derived]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[automatically_derived]` can only be applied to trait impl blocks
+
+warning: `#[automatically_derived]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:285:17
+   |
+LL |     mod inner { #![automatically_derived] }
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[automatically_derived]` can only be applied to trait impl blocks
+
+warning: `#[automatically_derived]` attribute cannot be used on functions
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:290:5
+   |
+LL |     #[automatically_derived] fn f() { }
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[automatically_derived]` can only be applied to trait impl blocks
+
+warning: `#[automatically_derived]` attribute cannot be used on structs
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:295:5
+   |
+LL |     #[automatically_derived] struct S;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[automatically_derived]` can only be applied to trait impl blocks
+
+warning: `#[automatically_derived]` attribute cannot be used on type aliases
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:300:5
+   |
+LL |     #[automatically_derived] type T = S;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[automatically_derived]` can only be applied to trait impl blocks
+
+warning: `#[automatically_derived]` attribute cannot be used on traits
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:305:5
+   |
+LL |     #[automatically_derived] trait W { }
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[automatically_derived]` can only be applied to trait impl blocks
+
+warning: `#[automatically_derived]` attribute cannot be used on inherent impl blocks
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:310:5
+   |
+LL |     #[automatically_derived] impl S { }
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[automatically_derived]` can only be applied to trait impl blocks
+
+warning: `#[no_mangle]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:318:1
+   |
+LL | #[no_mangle]
+   | ^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[no_mangle]` can be applied to functions, statics
+
+warning: `#[no_mangle]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:323:17
+   |
+LL |     mod inner { #![no_mangle] }
+   |                 ^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[no_mangle]` can be applied to functions, statics
+
+warning: `#[no_mangle]` attribute cannot be used on structs
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:330:5
+   |
+LL |     #[no_mangle] struct S;
+   |     ^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[no_mangle]` can be applied to functions, statics
+
+warning: `#[no_mangle]` attribute cannot be used on type aliases
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:335:5
+   |
+LL |     #[no_mangle] type T = S;
+   |     ^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[no_mangle]` can be applied to functions, statics
+
+warning: `#[no_mangle]` attribute cannot be used on inherent impl blocks
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:340:5
+   |
+LL |     #[no_mangle] impl S { }
+   |     ^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[no_mangle]` can be applied to functions, statics
+
+warning: `#[no_mangle]` attribute cannot be used on required trait methods
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:346:9
+   |
+LL |         #[no_mangle] fn foo();
+   |         ^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[no_mangle]` can be applied to functions, statics, inherent methods, trait methods in impl blocks
+
+warning: `#[no_mangle]` attribute cannot be used on provided trait methods
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:351:9
+   |
+LL |         #[no_mangle] fn bar() {}
+   |         ^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[no_mangle]` can be applied to functions, statics, inherent methods, trait methods in impl blocks
+
+warning: `#[should_panic]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:358:1
+   |
+LL | #[should_panic]
+   | ^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[should_panic]` can only be applied to functions
+
+warning: `#[should_panic]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:363:17
+   |
+LL |     mod inner { #![should_panic] }
+   |                 ^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[should_panic]` can only be applied to functions
+
+warning: `#[should_panic]` attribute cannot be used on structs
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:370:5
+   |
+LL |     #[should_panic] struct S;
+   |     ^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[should_panic]` can only be applied to functions
+
+warning: `#[should_panic]` attribute cannot be used on type aliases
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:375:5
+   |
+LL |     #[should_panic] type T = S;
+   |     ^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[should_panic]` can only be applied to functions
+
+warning: `#[should_panic]` attribute cannot be used on inherent impl blocks
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:380:5
+   |
+LL |     #[should_panic] impl S { }
+   |     ^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[should_panic]` can only be applied to functions
+
+warning: `#[ignore]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:386:1
+   |
+LL | #[ignore]
+   | ^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[ignore]` can only be applied to functions
+
+warning: `#[ignore]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:391:17
+   |
+LL |     mod inner { #![ignore] }
+   |                 ^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[ignore]` can only be applied to functions
+
+warning: `#[ignore]` attribute cannot be used on structs
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:398:5
+   |
+LL |     #[ignore] struct S;
+   |     ^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[ignore]` can only be applied to functions
+
+warning: `#[ignore]` attribute cannot be used on type aliases
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:403:5
+   |
+LL |     #[ignore] type T = S;
+   |     ^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[ignore]` can only be applied to functions
+
+warning: `#[ignore]` attribute cannot be used on inherent impl blocks
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:408:5
+   |
+LL |     #[ignore] impl S { }
+   |     ^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[ignore]` can only be applied to functions
+
+warning: `#[no_implicit_prelude]` attribute cannot be used on functions
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:418:5
+   |
+LL |     #[no_implicit_prelude] fn f() { }
+   |     ^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[no_implicit_prelude]` can be applied to modules, crates
+
+warning: `#[no_implicit_prelude]` attribute cannot be used on structs
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:423:5
+   |
+LL |     #[no_implicit_prelude] struct S;
+   |     ^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[no_implicit_prelude]` can be applied to modules, crates
+
+warning: `#[no_implicit_prelude]` attribute cannot be used on type aliases
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:428:5
+   |
+LL |     #[no_implicit_prelude] type T = S;
+   |     ^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[no_implicit_prelude]` can be applied to modules, crates
+
+warning: `#[no_implicit_prelude]` attribute cannot be used on inherent impl blocks
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:433:5
+   |
+LL |     #[no_implicit_prelude] impl S { }
+   |     ^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[no_implicit_prelude]` can be applied to modules, crates
+
+warning: `#[macro_escape]` attribute cannot be used on functions
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:466:5
+   |
+LL |     #[macro_escape] fn f() { }
+   |     ^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[macro_escape]` can be applied to modules, extern crates, crates
+
+warning: `#[macro_escape]` attribute cannot be used on structs
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:471:5
+   |
+LL |     #[macro_escape] struct S;
+   |     ^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[macro_escape]` can be applied to modules, extern crates, crates
+
+warning: `#[macro_escape]` attribute cannot be used on type aliases
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:476:5
+   |
+LL |     #[macro_escape] type T = S;
+   |     ^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[macro_escape]` can be applied to modules, extern crates, crates
+
+warning: `#[macro_escape]` attribute cannot be used on inherent impl blocks
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:481:5
+   |
+LL |     #[macro_escape] impl S { }
+   |     ^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[macro_escape]` can be applied to modules, extern crates, crates
+
+warning: `#[cold]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:523:1
+   |
+LL | #[cold]
+   | ^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[cold]` can only be applied to functions
+
+warning: `#[cold]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:529:17
+   |
+LL |     mod inner { #![cold] }
+   |                 ^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[cold]` can only be applied to functions
+
+warning: `#[cold]` attribute cannot be used on structs
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:536:5
+   |
+LL |     #[cold] struct S;
+   |     ^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[cold]` can only be applied to functions
+
+warning: `#[cold]` attribute cannot be used on type aliases
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:541:5
+   |
+LL |     #[cold] type T = S;
+   |     ^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[cold]` can only be applied to functions
+
+warning: `#[cold]` attribute cannot be used on inherent impl blocks
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:546:5
+   |
+LL |     #[cold] impl S { }
+   |     ^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[cold]` can only be applied to functions
+
+warning: `#[link_name]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:552:1
+   |
+LL | #[link_name = "1900"]
+   | ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[link_name]` can be applied to foreign functions, foreign statics
+
+warning: `#[link_name]` attribute cannot be used on foreign modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:557:5
+   |
+LL |     #[link_name = "1900"]
+   |     ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[link_name]` can be applied to foreign functions, foreign statics
+
+warning: `#[link_name]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:563:17
+   |
+LL |     mod inner { #![link_name="1900"] }
+   |                 ^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[link_name]` can be applied to foreign functions, foreign statics
+
+warning: `#[link_name]` attribute cannot be used on functions
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:568:5
+   |
+LL |     #[link_name = "1900"] fn f() { }
+   |     ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[link_name]` can be applied to foreign functions, foreign statics
+
+warning: `#[link_name]` attribute cannot be used on structs
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:573:5
+   |
+LL |     #[link_name = "1900"] struct S;
+   |     ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[link_name]` can be applied to foreign functions, foreign statics
+
+warning: `#[link_name]` attribute cannot be used on type aliases
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:578:5
+   |
+LL |     #[link_name = "1900"] type T = S;
+   |     ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[link_name]` can be applied to foreign functions, foreign statics
+
+warning: `#[link_name]` attribute cannot be used on inherent impl blocks
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:583:5
+   |
+LL |     #[link_name = "1900"] impl S { }
+   |     ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[link_name]` can be applied to foreign functions, foreign statics
+
+warning: `#[link_section]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:589:1
+   |
+LL | #[link_section = "1800"]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[link_section]` can be applied to statics, functions
+
+warning: `#[link_section]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:594:17
+   |
+LL |     mod inner { #![link_section="1800"] }
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[link_section]` can be applied to statics, functions
+
+warning: `#[link_section]` attribute cannot be used on structs
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:601:5
+   |
+LL |     #[link_section = "1800"] struct S;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[link_section]` can be applied to statics, functions
+
+warning: `#[link_section]` attribute cannot be used on type aliases
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:606:5
+   |
+LL |     #[link_section = "1800"] type T = S;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[link_section]` can be applied to statics, functions
+
+warning: `#[link_section]` attribute cannot be used on inherent impl blocks
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:611:5
+   |
+LL |     #[link_section = "1800"] impl S { }
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[link_section]` can be applied to statics, functions
+
+warning: `#[should_panic]` attribute cannot be used on crates
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:50:1
+   |
+LL | #![should_panic]
+   | ^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[should_panic]` can only be applied to functions
+
+warning: `#[ignore]` attribute cannot be used on crates
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:53:1
+   |
+LL | #![ignore]
+   | ^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[ignore]` can only be applied to functions
+
+warning: `#[proc_macro_derive]` attribute cannot be used on crates
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:61:1
+   |
+LL | #![proc_macro_derive(Test)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[proc_macro_derive]` can only be applied to functions
+
+warning: `#[cold]` attribute cannot be used on crates
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:65:1
+   |
+LL | #![cold]
+   | ^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[cold]` can only be applied to functions
+
+warning: `#[link_name]` attribute cannot be used on crates
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:70:1
+   |
+LL | #![link_name = "1900"]
+   | ^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[link_name]` can be applied to foreign functions, foreign statics
+
+warning: `#[link_section]` attribute cannot be used on crates
+  --> $DIR/issue-43106-gating-of-builtin-attrs.rs:74:1
+   |
+LL | #![link_section = "1800"]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[link_section]` can be applied to statics, functions
+
 warning: 173 warnings emitted
 
diff --git a/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.rs b/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.rs
index 392880e1b3b..35392b4eff6 100644
--- a/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.rs
+++ b/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.rs
@@ -1,34 +1,29 @@
-// At time of authorship, #[proc_macro_derive = "2500"] will emit an
-// error when it occurs on a mod (apart from crate-level), but will
-// not descend further into the mod for other occurrences of the same
-// error.
-//
-// This file sits on its own because the "weird" occurrences here
+// This file sits on its own because the occurrences here
 // signal errors, making it incompatible with the "warnings only"
 // nature of issue-43106-gating-of-builtin-attrs.rs
 
 #[proc_macro_derive(Test)]
-//~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
+//~^ ERROR attribute cannot be used on
 mod proc_macro_derive1 {
     mod inner { #![proc_macro_derive(Test)] }
-    // (no error issued here if there was one on outer module)
+    //~^ ERROR attribute cannot be used on
 }
 
 mod proc_macro_derive2 {
     mod inner { #![proc_macro_derive(Test)] }
-    //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
+    //~^ ERROR attribute cannot be used on
 
     #[proc_macro_derive(Test)] fn f() { }
     //~^ ERROR the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro`
 
     #[proc_macro_derive(Test)] struct S;
-    //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
+    //~^ ERROR attribute cannot be used on
 
     #[proc_macro_derive(Test)] type T = S;
-    //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
+    //~^ ERROR attribute cannot be used on
 
     #[proc_macro_derive(Test)] impl S { }
-    //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions
+    //~^ ERROR attribute cannot be used on
 }
 
 fn main() {}
diff --git a/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.stderr b/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.stderr
index 537032d777f..753e3e2f21d 100644
--- a/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.stderr
+++ b/tests/ui/feature-gates/issue-43106-gating-of-proc_macro_derive.stderr
@@ -1,38 +1,56 @@
-error: the `#[proc_macro_derive]` attribute may only be used on bare functions
-  --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:10:1
+error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type
+  --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:16:5
+   |
+LL |     #[proc_macro_derive(Test)] fn f() { }
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: `#[proc_macro_derive]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:5:1
    |
 LL | #[proc_macro_derive(Test)]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[proc_macro_derive]` can only be applied to functions
 
-error: the `#[proc_macro_derive]` attribute may only be used on bare functions
-  --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:18:17
+error: `#[proc_macro_derive]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:8:17
    |
 LL |     mod inner { #![proc_macro_derive(Test)] }
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[proc_macro_derive]` can only be applied to functions
 
-error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type
-  --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:21:5
+error: `#[proc_macro_derive]` attribute cannot be used on modules
+  --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:13:17
    |
-LL |     #[proc_macro_derive(Test)] fn f() { }
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |     mod inner { #![proc_macro_derive(Test)] }
+   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[proc_macro_derive]` can only be applied to functions
 
-error: the `#[proc_macro_derive]` attribute may only be used on bare functions
-  --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:24:5
+error: `#[proc_macro_derive]` attribute cannot be used on structs
+  --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:19:5
    |
 LL |     #[proc_macro_derive(Test)] struct S;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[proc_macro_derive]` can only be applied to functions
 
-error: the `#[proc_macro_derive]` attribute may only be used on bare functions
-  --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:27:5
+error: `#[proc_macro_derive]` attribute cannot be used on type aliases
+  --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:22:5
    |
 LL |     #[proc_macro_derive(Test)] type T = S;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[proc_macro_derive]` can only be applied to functions
 
-error: the `#[proc_macro_derive]` attribute may only be used on bare functions
-  --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:30:5
+error: `#[proc_macro_derive]` attribute cannot be used on inherent impl blocks
+  --> $DIR/issue-43106-gating-of-proc_macro_derive.rs:25:5
    |
 LL |     #[proc_macro_derive(Test)] impl S { }
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[proc_macro_derive]` can only be applied to functions
 
-error: aborting due to 6 previous errors
+error: aborting due to 7 previous errors
 
diff --git a/tests/ui/ffi-attrs/ffi_const.rs b/tests/ui/ffi-attrs/ffi_const.rs
index dddc862b0fa..caeaf8a25a9 100644
--- a/tests/ui/ffi-attrs/ffi_const.rs
+++ b/tests/ui/ffi-attrs/ffi_const.rs
@@ -1,16 +1,16 @@
 #![feature(ffi_const)]
 #![crate_type = "lib"]
 
-#[unsafe(ffi_const)] //~ ERROR `#[ffi_const]` may only be used on foreign functions
+#[unsafe(ffi_const)] //~ ERROR attribute cannot be used on
 pub fn foo() {}
 
-#[unsafe(ffi_const)] //~ ERROR `#[ffi_const]` may only be used on foreign functions
+#[unsafe(ffi_const)] //~ ERROR attribute cannot be used on
 macro_rules! bar {
     () => {};
 }
 
 extern "C" {
-    #[unsafe(ffi_const)] //~ ERROR `#[ffi_const]` may only be used on foreign functions
+    #[unsafe(ffi_const)] //~ ERROR attribute cannot be used on
     static INT: i32;
 
     #[ffi_const] //~ ERROR unsafe attribute used without unsafe
diff --git a/tests/ui/ffi-attrs/ffi_const.stderr b/tests/ui/ffi-attrs/ffi_const.stderr
index 7f31237539d..f3be9254318 100644
--- a/tests/ui/ffi-attrs/ffi_const.stderr
+++ b/tests/ui/ffi-attrs/ffi_const.stderr
@@ -9,24 +9,29 @@ help: wrap the attribute in `unsafe(...)`
 LL |     #[unsafe(ffi_const)]
    |       +++++++         +
 
-error[E0756]: `#[ffi_const]` may only be used on foreign functions
+error: `#[ffi_const]` attribute cannot be used on functions
   --> $DIR/ffi_const.rs:4:1
    |
 LL | #[unsafe(ffi_const)]
    | ^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[ffi_const]` can only be applied to foreign functions
 
-error[E0756]: `#[ffi_const]` may only be used on foreign functions
+error: `#[ffi_const]` attribute cannot be used on macro defs
   --> $DIR/ffi_const.rs:7:1
    |
 LL | #[unsafe(ffi_const)]
    | ^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[ffi_const]` can only be applied to foreign functions
 
-error[E0756]: `#[ffi_const]` may only be used on foreign functions
+error: `#[ffi_const]` attribute cannot be used on foreign statics
   --> $DIR/ffi_const.rs:13:5
    |
 LL |     #[unsafe(ffi_const)]
    |     ^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[ffi_const]` can only be applied to foreign functions
 
 error: aborting due to 4 previous errors
 
-For more information about this error, try `rustc --explain E0756`.
diff --git a/tests/ui/ffi-attrs/ffi_pure.rs b/tests/ui/ffi-attrs/ffi_pure.rs
index 1f4812f55cf..c56be793919 100644
--- a/tests/ui/ffi-attrs/ffi_pure.rs
+++ b/tests/ui/ffi-attrs/ffi_pure.rs
@@ -1,16 +1,16 @@
 #![feature(ffi_pure)]
 #![crate_type = "lib"]
 
-#[unsafe(ffi_pure)] //~ ERROR `#[ffi_pure]` may only be used on foreign functions
+#[unsafe(ffi_pure)] //~ ERROR attribute cannot be used on
 pub fn foo() {}
 
-#[unsafe(ffi_pure)] //~ ERROR `#[ffi_pure]` may only be used on foreign functions
+#[unsafe(ffi_pure)] //~ ERROR attribute cannot be used on
 macro_rules! bar {
     () => {};
 }
 
 extern "C" {
-    #[unsafe(ffi_pure)] //~ ERROR `#[ffi_pure]` may only be used on foreign functions
+    #[unsafe(ffi_pure)] //~ ERROR attribute cannot be used on
     static INT: i32;
 
     #[ffi_pure] //~ ERROR unsafe attribute used without unsafe
diff --git a/tests/ui/ffi-attrs/ffi_pure.stderr b/tests/ui/ffi-attrs/ffi_pure.stderr
index bd1177c01e2..da1eae975ac 100644
--- a/tests/ui/ffi-attrs/ffi_pure.stderr
+++ b/tests/ui/ffi-attrs/ffi_pure.stderr
@@ -9,24 +9,29 @@ help: wrap the attribute in `unsafe(...)`
 LL |     #[unsafe(ffi_pure)]
    |       +++++++        +
 
-error[E0755]: `#[ffi_pure]` may only be used on foreign functions
+error: `#[ffi_pure]` attribute cannot be used on functions
   --> $DIR/ffi_pure.rs:4:1
    |
 LL | #[unsafe(ffi_pure)]
    | ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[ffi_pure]` can only be applied to foreign functions
 
-error[E0755]: `#[ffi_pure]` may only be used on foreign functions
+error: `#[ffi_pure]` attribute cannot be used on macro defs
   --> $DIR/ffi_pure.rs:7:1
    |
 LL | #[unsafe(ffi_pure)]
    | ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[ffi_pure]` can only be applied to foreign functions
 
-error[E0755]: `#[ffi_pure]` may only be used on foreign functions
+error: `#[ffi_pure]` attribute cannot be used on foreign statics
   --> $DIR/ffi_pure.rs:13:5
    |
 LL |     #[unsafe(ffi_pure)]
    |     ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[ffi_pure]` can only be applied to foreign functions
 
 error: aborting due to 4 previous errors
 
-For more information about this error, try `rustc --explain E0755`.
diff --git a/tests/ui/force-inlining/invalid.rs b/tests/ui/force-inlining/invalid.rs
index e9f5712413e..6047739992f 100644
--- a/tests/ui/force-inlining/invalid.rs
+++ b/tests/ui/force-inlining/invalid.rs
@@ -28,110 +28,110 @@ pub fn forced4() {
 }
 
 #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 extern crate std as other_std;
 
 #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 use std::collections::HashMap;
 
 #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 static _FOO: &'static str = "FOO";
 
 #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 const _BAR: u32 = 3;
 
 #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 mod foo { }
 
 #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 unsafe extern "C" {
     #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
     static X: &'static u32;
 
     #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
     type Y;
 
     #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
     fn foo();
 }
 
 #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 type Foo = u32;
 
 #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 enum Bar<#[rustc_force_inline] T> {
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
     #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
     Baz(std::marker::PhantomData<T>),
 }
 
 #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 struct Qux {
     #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
     field: u32,
 }
 
 #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 union FooBar {
     x: u32,
     y: u32,
 }
 
 #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 trait FooBaz {
     #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
     type Foo;
     #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
     const Bar: i32;
 
     #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
     fn foo() {}
 }
 
 #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 trait FooQux = FooBaz;
 
 #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 impl<T> Bar<T> {
     #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
     fn foo() {}
 }
 
 #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 impl<T> FooBaz for Bar<T> {
     type Foo = u32;
     const Bar: i32 = 3;
 }
 
 #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 macro_rules! barqux { ($foo:tt) => { $foo }; }
 
 fn barqux(#[rustc_force_inline] _x: u32) {}
 //~^ ERROR allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters
-//~^^ ERROR attribute should be applied to a function
+//~^^ ERROR attribute cannot be used on
 
 #[rustc_force_inline]
 //~^ ERROR attribute cannot be applied to a `async`, `gen` or `async gen` function
@@ -147,16 +147,16 @@ async gen fn async_gen_foo() {}
 
 fn main() {
     let _x = #[rustc_force_inline] || { };
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
     let _y = #[rustc_force_inline] 3 + 4;
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
     #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
     let _z = 3;
 
     match _z {
         #[rustc_force_inline]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
         1 => (),
         _ => (),
     }
diff --git a/tests/ui/force-inlining/invalid.stderr b/tests/ui/force-inlining/invalid.stderr
index 3b3da00ae88..299a3ed4a46 100644
--- a/tests/ui/force-inlining/invalid.stderr
+++ b/tests/ui/force-inlining/invalid.stderr
@@ -64,322 +64,272 @@ LL - #[rustc_force_inline = 2]
 LL + #[rustc_force_inline]
    |
 
-error: attribute should be applied to a function
+error: `#[rustc_force_inline]` attribute cannot be used on extern crates
   --> $DIR/invalid.rs:30:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | extern crate std as other_std;
-   | ------------------------------ not a function definition
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute should be applied to a function
+error: `#[rustc_force_inline]` attribute cannot be used on use statements
   --> $DIR/invalid.rs:34:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | use std::collections::HashMap;
-   | ------------------------------ not a function definition
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute should be applied to a function
+error: `#[rustc_force_inline]` attribute cannot be used on statics
   --> $DIR/invalid.rs:38:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | static _FOO: &'static str = "FOO";
-   | ---------------------------------- not a function definition
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute should be applied to a function
+error: `#[rustc_force_inline]` attribute cannot be used on constants
   --> $DIR/invalid.rs:42:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | const _BAR: u32 = 3;
-   | -------------------- not a function definition
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute should be applied to a function
+error: `#[rustc_force_inline]` attribute cannot be used on modules
   --> $DIR/invalid.rs:46:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | mod foo { }
-   | ----------- not a function definition
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute should be applied to a function
+error: `#[rustc_force_inline]` attribute cannot be used on foreign modules
   --> $DIR/invalid.rs:50:1
    |
-LL |   #[rustc_force_inline]
-   |   ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | / unsafe extern "C" {
-LL | |     #[rustc_force_inline]
-LL | |
-LL | |     static X: &'static u32;
-...  |
-LL | |     fn foo();
-LL | | }
-   | |_- not a function definition
-
-error: attribute should be applied to a function
+LL | #[rustc_force_inline]
+   | ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
+
+error: `#[rustc_force_inline]` attribute cannot be used on foreign statics
+  --> $DIR/invalid.rs:53:5
+   |
+LL |     #[rustc_force_inline]
+   |     ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
+
+error: `#[rustc_force_inline]` attribute cannot be used on foreign types
+  --> $DIR/invalid.rs:57:5
+   |
+LL |     #[rustc_force_inline]
+   |     ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
+
+error: `#[rustc_force_inline]` attribute cannot be used on foreign functions
+  --> $DIR/invalid.rs:61:5
+   |
+LL |     #[rustc_force_inline]
+   |     ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
+
+error: `#[rustc_force_inline]` attribute cannot be used on type aliases
   --> $DIR/invalid.rs:66:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | type Foo = u32;
-   | --------------- not a function definition
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute should be applied to a function
+error: `#[rustc_force_inline]` attribute cannot be used on enums
   --> $DIR/invalid.rs:70:1
    |
-LL |   #[rustc_force_inline]
-   |   ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | / enum Bar<#[rustc_force_inline] T> {
-LL | |
-LL | |     #[rustc_force_inline]
-...  |
-LL | | }
-   | |_- not a function definition
-
-error: attribute should be applied to a function
+LL | #[rustc_force_inline]
+   | ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
+
+error: `#[rustc_force_inline]` attribute cannot be used on function params
   --> $DIR/invalid.rs:72:10
    |
 LL | enum Bar<#[rustc_force_inline] T> {
-   |          ^^^^^^^^^^^^^^^^^^^^^ - not a function definition
+   |          ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute should be applied to a function
+error: `#[rustc_force_inline]` attribute cannot be used on enum variants
   --> $DIR/invalid.rs:74:5
    |
 LL |     #[rustc_force_inline]
    |     ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL |     Baz(std::marker::PhantomData<T>),
-   |     -------------------------------- not a function definition
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute should be applied to a function
+error: `#[rustc_force_inline]` attribute cannot be used on structs
   --> $DIR/invalid.rs:79:1
    |
-LL |   #[rustc_force_inline]
-   |   ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | / struct Qux {
-LL | |     #[rustc_force_inline]
-LL | |
-LL | |     field: u32,
-LL | | }
-   | |_- not a function definition
-
-error: attribute should be applied to a function
+LL | #[rustc_force_inline]
+   | ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
+
+error: `#[rustc_force_inline]` attribute cannot be used on struct fields
   --> $DIR/invalid.rs:82:5
    |
 LL |     #[rustc_force_inline]
    |     ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL |     field: u32,
-   |     ---------- not a function definition
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute should be applied to a function
+error: `#[rustc_force_inline]` attribute cannot be used on unions
   --> $DIR/invalid.rs:87:1
    |
-LL |   #[rustc_force_inline]
-   |   ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | / union FooBar {
-LL | |     x: u32,
-LL | |     y: u32,
-LL | | }
-   | |_- not a function definition
+LL | #[rustc_force_inline]
+   | ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute should be applied to a function
+error: `#[rustc_force_inline]` attribute cannot be used on traits
   --> $DIR/invalid.rs:94:1
    |
-LL |   #[rustc_force_inline]
-   |   ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | / trait FooBaz {
-LL | |     #[rustc_force_inline]
-LL | |
-LL | |     type Foo;
-...  |
-LL | |     fn foo() {}
-LL | | }
-   | |_- not a function definition
-
-error: attribute should be applied to a function
-  --> $DIR/invalid.rs:109:1
-   |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | trait FooQux = FooBaz;
-   | ---------------------- not a function definition
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute should be applied to a function
-  --> $DIR/invalid.rs:113:1
+error: `#[rustc_force_inline]` attribute cannot be used on associated types
+  --> $DIR/invalid.rs:97:5
    |
-LL |   #[rustc_force_inline]
-   |   ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | / impl<T> Bar<T> {
-LL | |     #[rustc_force_inline]
-LL | |
-LL | |     fn foo() {}
-LL | | }
-   | |_- not a function definition
-
-error: attribute should be applied to a function
-  --> $DIR/invalid.rs:121:1
+LL |     #[rustc_force_inline]
+   |     ^^^^^^^^^^^^^^^^^^^^^
    |
-LL |   #[rustc_force_inline]
-   |   ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | / impl<T> FooBaz for Bar<T> {
-LL | |     type Foo = u32;
-LL | |     const Bar: i32 = 3;
-LL | | }
-   | |_- not a function definition
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute should be applied to a function
-  --> $DIR/invalid.rs:128:1
+error: `#[rustc_force_inline]` attribute cannot be used on associated consts
+  --> $DIR/invalid.rs:100:5
+   |
+LL |     #[rustc_force_inline]
+   |     ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
+
+error: `#[rustc_force_inline]` attribute cannot be used on provided trait methods
+  --> $DIR/invalid.rs:104:5
+   |
+LL |     #[rustc_force_inline]
+   |     ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
+
+error: `#[rustc_force_inline]` attribute cannot be used on trait aliases
+  --> $DIR/invalid.rs:109:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | macro_rules! barqux { ($foo:tt) => { $foo }; }
-   | ---------------------------------------------- not a function definition
-
-error: attribute should be applied to a function
-  --> $DIR/invalid.rs:132:11
    |
-LL | fn barqux(#[rustc_force_inline] _x: u32) {}
-   |           ^^^^^^^^^^^^^^^^^^^^^--------
-   |           |
-   |           not a function definition
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute cannot be applied to a `async`, `gen` or `async gen` function
-  --> $DIR/invalid.rs:136:1
+error: `#[rustc_force_inline]` attribute cannot be used on inherent impl blocks
+  --> $DIR/invalid.rs:113:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | async fn async_foo() {}
-   | -------------------- `async`, `gen` or `async gen` function
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute cannot be applied to a `async`, `gen` or `async gen` function
-  --> $DIR/invalid.rs:140:1
+error: `#[rustc_force_inline]` attribute cannot be used on inherent methods
+  --> $DIR/invalid.rs:116:5
+   |
+LL |     #[rustc_force_inline]
+   |     ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
+
+error: `#[rustc_force_inline]` attribute cannot be used on trait impl blocks
+  --> $DIR/invalid.rs:121:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | gen fn gen_foo() {}
-   | ---------------- `async`, `gen` or `async gen` function
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute cannot be applied to a `async`, `gen` or `async gen` function
-  --> $DIR/invalid.rs:144:1
+error: `#[rustc_force_inline]` attribute cannot be used on macro defs
+  --> $DIR/invalid.rs:128:1
    |
 LL | #[rustc_force_inline]
    | ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | async gen fn async_gen_foo() {}
-   | ---------------------------- `async`, `gen` or `async gen` function
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute should be applied to a function
+error: `#[rustc_force_inline]` attribute cannot be used on function params
+  --> $DIR/invalid.rs:132:11
+   |
+LL | fn barqux(#[rustc_force_inline] _x: u32) {}
+   |           ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
+
+error: `#[rustc_force_inline]` attribute cannot be used on closures
   --> $DIR/invalid.rs:149:14
    |
 LL |     let _x = #[rustc_force_inline] || { };
-   |              ^^^^^^^^^^^^^^^^^^^^^ ------ not a function definition
+   |              ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute should be applied to a function
+error: `#[rustc_force_inline]` attribute cannot be used on expressions
   --> $DIR/invalid.rs:151:14
    |
 LL |     let _y = #[rustc_force_inline] 3 + 4;
-   |              ^^^^^^^^^^^^^^^^^^^^^ - not a function definition
+   |              ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute should be applied to a function
+error: `#[rustc_force_inline]` attribute cannot be used on statements
   --> $DIR/invalid.rs:153:5
    |
 LL |     #[rustc_force_inline]
    |     ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL |     let _z = 3;
-   |     ----------- not a function definition
+   |
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute should be applied to a function
+error: `#[rustc_force_inline]` attribute cannot be used on match arms
   --> $DIR/invalid.rs:158:9
    |
 LL |         #[rustc_force_inline]
    |         ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL |         1 => (),
-   |         ------- not a function definition
-
-error: attribute should be applied to a function
-  --> $DIR/invalid.rs:97:5
-   |
-LL |     #[rustc_force_inline]
-   |     ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL |     type Foo;
-   |     --------- not a function definition
-
-error: attribute should be applied to a function
-  --> $DIR/invalid.rs:100:5
-   |
-LL |     #[rustc_force_inline]
-   |     ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL |     const Bar: i32;
-   |     --------------- not a function definition
-
-error: attribute should be applied to a function
-  --> $DIR/invalid.rs:104:5
-   |
-LL |     #[rustc_force_inline]
-   |     ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL |     fn foo() {}
-   |     ----------- not a function definition
-
-error: attribute should be applied to a function
-  --> $DIR/invalid.rs:116:5
    |
-LL |     #[rustc_force_inline]
-   |     ^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL |     fn foo() {}
-   |     ----------- not a function definition
+   = help: `#[rustc_force_inline]` can only be applied to functions
 
-error: attribute should be applied to a function
-  --> $DIR/invalid.rs:53:5
+error: attribute cannot be applied to a `async`, `gen` or `async gen` function
+  --> $DIR/invalid.rs:136:1
    |
-LL |     #[rustc_force_inline]
-   |     ^^^^^^^^^^^^^^^^^^^^^
+LL | #[rustc_force_inline]
+   | ^^^^^^^^^^^^^^^^^^^^^
 LL |
-LL |     static X: &'static u32;
-   |     ----------------------- not a function definition
+LL | async fn async_foo() {}
+   | -------------------- `async`, `gen` or `async gen` function
 
-error: attribute should be applied to a function
-  --> $DIR/invalid.rs:57:5
+error: attribute cannot be applied to a `async`, `gen` or `async gen` function
+  --> $DIR/invalid.rs:140:1
    |
-LL |     #[rustc_force_inline]
-   |     ^^^^^^^^^^^^^^^^^^^^^
+LL | #[rustc_force_inline]
+   | ^^^^^^^^^^^^^^^^^^^^^
 LL |
-LL |     type Y;
-   |     ------- not a function definition
+LL | gen fn gen_foo() {}
+   | ---------------- `async`, `gen` or `async gen` function
 
-error: attribute should be applied to a function
-  --> $DIR/invalid.rs:61:5
+error: attribute cannot be applied to a `async`, `gen` or `async gen` function
+  --> $DIR/invalid.rs:144:1
    |
-LL |     #[rustc_force_inline]
-   |     ^^^^^^^^^^^^^^^^^^^^^
+LL | #[rustc_force_inline]
+   | ^^^^^^^^^^^^^^^^^^^^^
 LL |
-LL |     fn foo();
-   |     --------- not a function definition
+LL | async gen fn async_gen_foo() {}
+   | ---------------------------- `async`, `gen` or `async gen` function
 
 error: aborting due to 37 previous errors
 
diff --git a/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr b/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr
index 8b9ad78db37..6d5a22e4ced 100644
--- a/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr
+++ b/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr
@@ -25,6 +25,14 @@ LL | #[rustc_layout_scalar_valid_range_end(a = "a")]
    | |                                     expected an integer literal here
    | help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]`
 
+error: `#[rustc_layout_scalar_valid_range_end]` attribute cannot be used on enums
+  --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:12:1
+   |
+LL | #[rustc_layout_scalar_valid_range_end(1)]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[rustc_layout_scalar_valid_range_end]` can only be applied to structs
+
 error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input
   --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:18:1
    |
@@ -34,17 +42,6 @@ LL | #[rustc_layout_scalar_valid_range_start(rustc_layout_scalar_valid_range_sta
    | |                                       expected an integer literal here
    | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]`
 
-error: attribute should be applied to a struct
-  --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:12:1
-   |
-LL |   #[rustc_layout_scalar_valid_range_end(1)]
-   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL | / enum E {
-LL | |     X = 1,
-LL | |     Y = 14,
-LL | | }
-   | |_- not a struct
-
 error: aborting due to 5 previous errors
 
 Some errors have detailed explanations: E0539, E0805.
diff --git a/tests/ui/issues/issue-31769.rs b/tests/ui/issues/issue-31769.rs
index f56c6ea5656..354c1be9ed5 100644
--- a/tests/ui/issues/issue-31769.rs
+++ b/tests/ui/issues/issue-31769.rs
@@ -1,4 +1,4 @@
 fn main() {
-    #[inline] struct Foo;  //~ ERROR attribute should be applied to function or closure
+    #[inline] struct Foo;  //~ ERROR attribute cannot be used on
     #[repr(C)] fn foo() {} //~ ERROR attribute should be applied to a struct, enum, or union
 }
diff --git a/tests/ui/issues/issue-31769.stderr b/tests/ui/issues/issue-31769.stderr
index 03e2f931c84..0f75e84f2a7 100644
--- a/tests/ui/issues/issue-31769.stderr
+++ b/tests/ui/issues/issue-31769.stderr
@@ -1,8 +1,10 @@
-error[E0518]: attribute should be applied to function or closure
+error: `#[inline]` attribute cannot be used on structs
   --> $DIR/issue-31769.rs:2:5
    |
 LL |     #[inline] struct Foo;
-   |     ^^^^^^^^^ ----------- not a function or closure
+   |     ^^^^^^^^^
+   |
+   = help: `#[inline]` can only be applied to functions
 
 error[E0517]: attribute should be applied to a struct, enum, or union
   --> $DIR/issue-31769.rs:3:12
@@ -12,5 +14,4 @@ LL |     #[repr(C)] fn foo() {}
 
 error: aborting due to 2 previous errors
 
-Some errors have detailed explanations: E0517, E0518.
-For more information about an error, try `rustc --explain E0517`.
+For more information about this error, try `rustc --explain E0517`.
diff --git a/tests/ui/issues/issue-43988.rs b/tests/ui/issues/issue-43988.rs
index 5fea5576b7f..bd23e0e2457 100644
--- a/tests/ui/issues/issue-43988.rs
+++ b/tests/ui/issues/issue-43988.rs
@@ -4,12 +4,13 @@ fn main() {
 
     #[inline]
     let _a = 4;
-    //~^^ ERROR attribute should be applied to function or closure
+    //~^^ ERROR attribute cannot be used on
 
 
     #[inline(XYZ)]
     let _b = 4;
     //~^^ ERROR malformed `inline` attribute
+    //~| ERROR attribute cannot be used on
 
     #[repr(nothing)]
     let _x = 0;
@@ -30,6 +31,7 @@ fn main() {
     #[inline(ABC)]
     foo();
     //~^^ ERROR malformed `inline` attribute
+    //~| ERROR attribute cannot be used on
 
     let _z = #[repr] 1;
     //~^ ERROR malformed `repr` attribute
diff --git a/tests/ui/issues/issue-43988.stderr b/tests/ui/issues/issue-43988.stderr
index b50d691e685..0219eeb693e 100644
--- a/tests/ui/issues/issue-43988.stderr
+++ b/tests/ui/issues/issue-43988.stderr
@@ -1,3 +1,11 @@
+error: `#[inline]` attribute cannot be used on statements
+  --> $DIR/issue-43988.rs:5:5
+   |
+LL |     #[inline]
+   |     ^^^^^^^^^
+   |
+   = help: `#[inline]` can only be applied to functions
+
 error[E0539]: malformed `inline` attribute input
   --> $DIR/issue-43988.rs:10:5
    |
@@ -19,8 +27,16 @@ LL -     #[inline(XYZ)]
 LL +     #[inline]
    |
 
+error: `#[inline]` attribute cannot be used on statements
+  --> $DIR/issue-43988.rs:10:5
+   |
+LL |     #[inline(XYZ)]
+   |     ^^^^^^^^^^^^^^
+   |
+   = help: `#[inline]` can only be applied to functions
+
 error[E0552]: unrecognized representation hint
-  --> $DIR/issue-43988.rs:14:12
+  --> $DIR/issue-43988.rs:15:12
    |
 LL |     #[repr(nothing)]
    |            ^^^^^^^
@@ -29,7 +45,7 @@ LL |     #[repr(nothing)]
    = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html?highlight=repr#representations>
 
 error[E0552]: unrecognized representation hint
-  --> $DIR/issue-43988.rs:18:12
+  --> $DIR/issue-43988.rs:19:12
    |
 LL |     #[repr(something_not_real)]
    |            ^^^^^^^^^^^^^^^^^^
@@ -38,7 +54,7 @@ LL |     #[repr(something_not_real)]
    = note: for more information, visit <https://doc.rust-lang.org/reference/type-layout.html?highlight=repr#representations>
 
 error[E0539]: malformed `repr` attribute input
-  --> $DIR/issue-43988.rs:24:5
+  --> $DIR/issue-43988.rs:25:5
    |
 LL |     #[repr]
    |     ^^^^^^^ expected this to be a list
@@ -57,7 +73,7 @@ LL |     #[repr(align(...))]
    = and 2 other candidates
 
 error[E0539]: malformed `inline` attribute input
-  --> $DIR/issue-43988.rs:30:5
+  --> $DIR/issue-43988.rs:31:5
    |
 LL |     #[inline(ABC)]
    |     ^^^^^^^^^---^^
@@ -77,8 +93,16 @@ LL -     #[inline(ABC)]
 LL +     #[inline]
    |
 
+error: `#[inline]` attribute cannot be used on expressions
+  --> $DIR/issue-43988.rs:31:5
+   |
+LL |     #[inline(ABC)]
+   |     ^^^^^^^^^^^^^^
+   |
+   = help: `#[inline]` can only be applied to functions
+
 error[E0539]: malformed `repr` attribute input
-  --> $DIR/issue-43988.rs:34:14
+  --> $DIR/issue-43988.rs:36:14
    |
 LL |     let _z = #[repr] 1;
    |              ^^^^^^^ expected this to be a list
@@ -96,15 +120,7 @@ LL |     let _z = #[repr(align(...))] 1;
    |                    ++++++++++++
    = and 2 other candidates
 
-error[E0518]: attribute should be applied to function or closure
-  --> $DIR/issue-43988.rs:5:5
-   |
-LL |     #[inline]
-   |     ^^^^^^^^^
-LL |     let _a = 4;
-   |     ----------- not a function or closure
-
-error: aborting due to 7 previous errors
+error: aborting due to 9 previous errors
 
-Some errors have detailed explanations: E0518, E0539, E0552.
-For more information about an error, try `rustc --explain E0518`.
+Some errors have detailed explanations: E0539, E0552.
+For more information about an error, try `rustc --explain E0539`.
diff --git a/tests/ui/issues/issue-78957.rs b/tests/ui/issues/issue-78957.rs
index 567c59fd560..2ff92612e18 100644
--- a/tests/ui/issues/issue-78957.rs
+++ b/tests/ui/issues/issue-78957.rs
@@ -3,26 +3,26 @@
 use std::marker::PhantomData;
 
 pub struct Foo<#[inline] const N: usize>;
-//~^ ERROR attribute should be applied to function or closure
+//~^ ERROR attribute cannot be used on
 pub struct Bar<#[cold] const N: usize>;
-//~^ ERROR attribute should be applied to a function
-//~| WARN this was previously accepted
+//~^ ERROR attribute cannot be used on
+//~| WARN previously accepted
 pub struct Baz<#[repr(C)] const N: usize>;
 //~^ ERROR attribute should be applied to a struct, enum, or union
 //
 pub struct Foo2<#[inline] 'a>(PhantomData<&'a ()>);
-//~^ ERROR attribute should be applied to function or closure
+//~^ ERROR attribute cannot be used on
 pub struct Bar2<#[cold] 'a>(PhantomData<&'a ()>);
-//~^ ERROR attribute should be applied to a function
-//~| WARN this was previously accepted
+//~^ ERROR attribute cannot be used on
+//~| WARN previously accepted
 pub struct Baz2<#[repr(C)] 'a>(PhantomData<&'a ()>);
 //~^ ERROR attribute should be applied to a struct, enum, or union
 //
 pub struct Foo3<#[inline] T>(PhantomData<T>);
-//~^ ERROR attribute should be applied to function or closure
+//~^ ERROR attribute cannot be used on
 pub struct Bar3<#[cold] T>(PhantomData<T>);
-//~^ ERROR attribute should be applied to a function
-//~| WARN this was previously accepted
+//~^ ERROR attribute cannot be used on
+//~| WARN previously accepted
 pub struct Baz3<#[repr(C)] T>(PhantomData<T>);
 //~^ ERROR attribute should be applied to a struct, enum, or union
 
diff --git a/tests/ui/issues/issue-78957.stderr b/tests/ui/issues/issue-78957.stderr
index 6de22d6bf79..d271b1840fb 100644
--- a/tests/ui/issues/issue-78957.stderr
+++ b/tests/ui/issues/issue-78957.stderr
@@ -1,21 +1,26 @@
-error[E0518]: attribute should be applied to function or closure
+error: `#[inline]` attribute cannot be used on function params
   --> $DIR/issue-78957.rs:5:16
    |
 LL | pub struct Foo<#[inline] const N: usize>;
-   |                ^^^^^^^^^ -------------- not a function or closure
+   |                ^^^^^^^^^
+   |
+   = help: `#[inline]` can only be applied to functions
 
-error: attribute should be applied to a function definition
-  --> $DIR/issue-78957.rs:7:16
+error: `#[inline]` attribute cannot be used on function params
+  --> $DIR/issue-78957.rs:13:17
    |
-LL | pub struct Bar<#[cold] const N: usize>;
-   |                ^^^^^^^ -------------- not a function definition
+LL | pub struct Foo2<#[inline] 'a>(PhantomData<&'a ()>);
+   |                 ^^^^^^^^^
    |
-   = 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/issue-78957.rs:1:9
+   = help: `#[inline]` can only be applied to functions
+
+error: `#[inline]` attribute cannot be used on function params
+  --> $DIR/issue-78957.rs:21:17
    |
-LL | #![deny(unused_attributes)]
-   |         ^^^^^^^^^^^^^^^^^
+LL | pub struct Foo3<#[inline] T>(PhantomData<T>);
+   |                 ^^^^^^^^^
+   |
+   = help: `#[inline]` can only be applied to functions
 
 error[E0517]: attribute should be applied to a struct, enum, or union
   --> $DIR/issue-78957.rs:10:23
@@ -23,47 +28,50 @@ error[E0517]: attribute should be applied to a struct, enum, or union
 LL | pub struct Baz<#[repr(C)] const N: usize>;
    |                       ^   -------------- not a struct, enum, or union
 
-error[E0518]: attribute should be applied to function or closure
-  --> $DIR/issue-78957.rs:13:17
+error[E0517]: attribute should be applied to a struct, enum, or union
+  --> $DIR/issue-78957.rs:18:24
    |
-LL | pub struct Foo2<#[inline] 'a>(PhantomData<&'a ()>);
-   |                 ^^^^^^^^^ -- not a function or closure
+LL | pub struct Baz2<#[repr(C)] 'a>(PhantomData<&'a ()>);
+   |                        ^   -- not a struct, enum, or union
 
-error: attribute should be applied to a function definition
-  --> $DIR/issue-78957.rs:15:17
+error[E0517]: attribute should be applied to a struct, enum, or union
+  --> $DIR/issue-78957.rs:26:24
    |
-LL | pub struct Bar2<#[cold] 'a>(PhantomData<&'a ()>);
-   |                 ^^^^^^^ -- not a function definition
+LL | pub struct Baz3<#[repr(C)] T>(PhantomData<T>);
+   |                        ^   - not a struct, enum, or union
+
+error: `#[cold]` attribute cannot be used on function params
+  --> $DIR/issue-78957.rs:7:16
+   |
+LL | pub struct Bar<#[cold] const N: usize>;
+   |                ^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-error[E0517]: attribute should be applied to a struct, enum, or union
-  --> $DIR/issue-78957.rs:18:24
+   = help: `#[cold]` can only be applied to functions
+note: the lint level is defined here
+  --> $DIR/issue-78957.rs:1:9
    |
-LL | pub struct Baz2<#[repr(C)] 'a>(PhantomData<&'a ()>);
-   |                        ^   -- not a struct, enum, or union
+LL | #![deny(unused_attributes)]
+   |         ^^^^^^^^^^^^^^^^^
 
-error[E0518]: attribute should be applied to function or closure
-  --> $DIR/issue-78957.rs:21:17
+error: `#[cold]` attribute cannot be used on function params
+  --> $DIR/issue-78957.rs:15:17
    |
-LL | pub struct Foo3<#[inline] T>(PhantomData<T>);
-   |                 ^^^^^^^^^ - not a function or closure
+LL | pub struct Bar2<#[cold] 'a>(PhantomData<&'a ()>);
+   |                 ^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[cold]` can only be applied to functions
 
-error: attribute should be applied to a function definition
+error: `#[cold]` attribute cannot be used on function params
   --> $DIR/issue-78957.rs:23:17
    |
 LL | pub struct Bar3<#[cold] T>(PhantomData<T>);
-   |                 ^^^^^^^ - not a function definition
+   |                 ^^^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-
-error[E0517]: attribute should be applied to a struct, enum, or union
-  --> $DIR/issue-78957.rs:26:24
-   |
-LL | pub struct Baz3<#[repr(C)] T>(PhantomData<T>);
-   |                        ^   - not a struct, enum, or union
+   = help: `#[cold]` can only be applied to functions
 
 error: aborting due to 9 previous errors
 
-Some errors have detailed explanations: E0517, E0518.
-For more information about an error, try `rustc --explain E0517`.
+For more information about this error, try `rustc --explain E0517`.
diff --git a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.rs b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.rs
index 5982c771033..301e690be38 100644
--- a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.rs
+++ b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.rs
@@ -1,13 +1,13 @@
 #[link_ordinal(123)]
-//~^ ERROR attribute should be applied to a foreign function or static
+//~^ ERROR attribute cannot be used on
 struct Foo {}
 
 #[link_ordinal(123)]
-//~^ ERROR attribute should be applied to a foreign function or static
+//~^ ERROR attribute cannot be used on
 fn test() {}
 
 #[link_ordinal(42)]
-//~^ ERROR attribute should be applied to a foreign function or static
+//~^ ERROR attribute cannot be used on
 static mut imported_val: i32 = 123;
 
 #[link(name = "exporter", kind = "raw-dylib")]
diff --git a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.stderr b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.stderr
index 8f279508720..c561373db77 100644
--- a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.stderr
+++ b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.stderr
@@ -1,20 +1,26 @@
-error: attribute should be applied to a foreign function or static
+error: `#[link_ordinal]` attribute cannot be used on structs
   --> $DIR/link-ordinal-not-foreign-fn.rs:1:1
    |
 LL | #[link_ordinal(123)]
    | ^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[link_ordinal]` can be applied to foreign functions, foreign statics
 
-error: attribute should be applied to a foreign function or static
+error: `#[link_ordinal]` attribute cannot be used on functions
   --> $DIR/link-ordinal-not-foreign-fn.rs:5:1
    |
 LL | #[link_ordinal(123)]
    | ^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[link_ordinal]` can be applied to foreign functions, foreign statics
 
-error: attribute should be applied to a foreign function or static
+error: `#[link_ordinal]` attribute cannot be used on statics
   --> $DIR/link-ordinal-not-foreign-fn.rs:9:1
    |
 LL | #[link_ordinal(42)]
    | ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[link_ordinal]` can be applied to foreign functions, foreign statics
 
 error: aborting due to 3 previous errors
 
diff --git a/tests/ui/lint/inline-trait-and-foreign-items.rs b/tests/ui/lint/inline-trait-and-foreign-items.rs
index 39bc01f71b5..d41a09dee96 100644
--- a/tests/ui/lint/inline-trait-and-foreign-items.rs
+++ b/tests/ui/lint/inline-trait-and-foreign-items.rs
@@ -4,33 +4,33 @@
 #![warn(unused_attributes)]
 
 trait Trait {
-    #[inline] //~ WARN `#[inline]` is ignored on constants
-    //~^ WARN this was previously accepted
+    #[inline] //~ WARN attribute cannot be used on
+//~| WARN previously accepted
     const X: u32;
 
-    #[inline] //~ ERROR attribute should be applied to function or closure
+    #[inline] //~ ERROR attribute cannot be used on
     type T;
 
     type U;
 }
 
 impl Trait for () {
-    #[inline] //~ WARN `#[inline]` is ignored on constants
-    //~^ WARN this was previously accepted
+    #[inline] //~ WARN attribute cannot be used on
+//~| WARN previously accepted
     const X: u32 = 0;
 
-    #[inline] //~ ERROR attribute should be applied to function or closure
+    #[inline] //~ ERROR attribute cannot be used on
     type T = Self;
 
-    #[inline] //~ ERROR attribute should be applied to function or closure
+    #[inline] //~ ERROR attribute cannot be used on
     type U = impl Trait; //~ ERROR unconstrained opaque type
 }
 
 extern "C" {
-    #[inline] //~ ERROR attribute should be applied to function or closure
+    #[inline] //~ ERROR attribute cannot be used on
     static X: u32;
 
-    #[inline] //~ ERROR attribute should be applied to function or closure
+    #[inline] //~ ERROR attribute cannot be used on
     type T;
 }
 
diff --git a/tests/ui/lint/inline-trait-and-foreign-items.stderr b/tests/ui/lint/inline-trait-and-foreign-items.stderr
index 2f1fb4c46c0..4bde4bc590a 100644
--- a/tests/ui/lint/inline-trait-and-foreign-items.stderr
+++ b/tests/ui/lint/inline-trait-and-foreign-items.stderr
@@ -1,65 +1,42 @@
-warning: `#[inline]` is ignored on constants
-  --> $DIR/inline-trait-and-foreign-items.rs:7: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!
-   = note: see issue #65833 <https://github.com/rust-lang/rust/issues/65833> for more information
-note: the lint level is defined here
-  --> $DIR/inline-trait-and-foreign-items.rs:4:9
-   |
-LL | #![warn(unused_attributes)]
-   |         ^^^^^^^^^^^^^^^^^
-
-error[E0518]: attribute should be applied to function or closure
+error: `#[inline]` attribute cannot be used on associated types
   --> $DIR/inline-trait-and-foreign-items.rs:11:5
    |
 LL |     #[inline]
    |     ^^^^^^^^^
-LL |     type T;
-   |     ------- not a function or closure
-
-warning: `#[inline]` is ignored on constants
-  --> $DIR/inline-trait-and-foreign-items.rs:18: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!
-   = note: see issue #65833 <https://github.com/rust-lang/rust/issues/65833> for more information
+   = help: `#[inline]` can only be applied to functions
 
-error[E0518]: attribute should be applied to function or closure
+error: `#[inline]` attribute cannot be used on associated types
   --> $DIR/inline-trait-and-foreign-items.rs:22:5
    |
 LL |     #[inline]
    |     ^^^^^^^^^
-LL |     type T = Self;
-   |     -------------- not a function or closure
+   |
+   = help: `#[inline]` can only be applied to functions
 
-error[E0518]: attribute should be applied to function or closure
+error: `#[inline]` attribute cannot be used on associated types
   --> $DIR/inline-trait-and-foreign-items.rs:25:5
    |
 LL |     #[inline]
    |     ^^^^^^^^^
-LL |     type U = impl Trait;
-   |     -------------------- not a function or closure
+   |
+   = help: `#[inline]` can only be applied to functions
 
-error[E0518]: attribute should be applied to function or closure
+error: `#[inline]` attribute cannot be used on foreign statics
   --> $DIR/inline-trait-and-foreign-items.rs:30:5
    |
 LL |     #[inline]
    |     ^^^^^^^^^
-LL |     static X: u32;
-   |     -------------- not a function or closure
+   |
+   = help: `#[inline]` can only be applied to functions
 
-error[E0518]: attribute should be applied to function or closure
+error: `#[inline]` attribute cannot be used on foreign types
   --> $DIR/inline-trait-and-foreign-items.rs:33:5
    |
 LL |     #[inline]
    |     ^^^^^^^^^
-LL |     type T;
-   |     ------- not a function or closure
+   |
+   = help: `#[inline]` can only be applied to functions
 
 error: unconstrained opaque type
   --> $DIR/inline-trait-and-foreign-items.rs:26:14
@@ -69,6 +46,28 @@ LL |     type U = impl Trait;
    |
    = note: `U` must be used in combination with a concrete type within the same impl
 
+warning: `#[inline]` attribute cannot be used on associated consts
+  --> $DIR/inline-trait-and-foreign-items.rs:7: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: the lint level is defined here
+  --> $DIR/inline-trait-and-foreign-items.rs:4:9
+   |
+LL | #![warn(unused_attributes)]
+   |         ^^^^^^^^^^^^^^^^^
+
+warning: `#[inline]` attribute cannot be used on associated consts
+  --> $DIR/inline-trait-and-foreign-items.rs:18: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
+
 error: aborting due to 6 previous errors; 2 warnings emitted
 
-For more information about this error, try `rustc --explain E0518`.
diff --git a/tests/ui/lint/unused/unused-attr-macro-rules.rs b/tests/ui/lint/unused/unused-attr-macro-rules.rs
index 7a8a1bb1ae5..96f2834a296 100644
--- a/tests/ui/lint/unused/unused-attr-macro-rules.rs
+++ b/tests/ui/lint/unused/unused-attr-macro-rules.rs
@@ -4,8 +4,10 @@
 
 // A sample of various built-in attributes.
 #[macro_export]
-#[macro_use] //~ ERROR `#[macro_use]` only has an effect
-#[path="foo"] //~ ERROR #[path]` only has an effect
+#[macro_use] //~ ERROR attribute cannot be used on
+//~| WARN previously accepted
+#[path="foo"] //~ ERROR attribute cannot be used on
+//~| WARN previously accepted
 #[recursion_limit="1"] //~ ERROR crate-level attribute should be an inner attribute
 macro_rules! foo {
     () => {};
diff --git a/tests/ui/lint/unused/unused-attr-macro-rules.stderr b/tests/ui/lint/unused/unused-attr-macro-rules.stderr
index 1e1211af5e2..0c55ae678e9 100644
--- a/tests/ui/lint/unused/unused-attr-macro-rules.stderr
+++ b/tests/ui/lint/unused/unused-attr-macro-rules.stderr
@@ -1,5 +1,5 @@
 error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]`
-  --> $DIR/unused-attr-macro-rules.rs:9:1
+  --> $DIR/unused-attr-macro-rules.rs:11:1
    |
 LL | #[recursion_limit="1"]
    | ^^^^^^^^^^^^^^^^^^^^^^
@@ -10,17 +10,23 @@ note: the lint level is defined here
 LL | #![deny(unused_attributes)]
    |         ^^^^^^^^^^^^^^^^^
 
-error: `#[macro_use]` only has an effect on `extern crate` and modules
+error: `#[macro_use]` attribute cannot be used on macro defs
   --> $DIR/unused-attr-macro-rules.rs:7:1
    |
 LL | #[macro_use]
    | ^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[macro_use]` can be applied to modules, extern crates, crates
 
-error: `#[path]` only has an effect on modules
-  --> $DIR/unused-attr-macro-rules.rs:8:1
+error: `#[path]` attribute cannot be used on macro defs
+  --> $DIR/unused-attr-macro-rules.rs:9:1
    |
 LL | #[path="foo"]
    | ^^^^^^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = help: `#[path]` can only be applied to modules
 
 error: aborting due to 3 previous errors
 
diff --git a/tests/ui/lint/unused/unused_attributes-must_use.stderr b/tests/ui/lint/unused/unused_attributes-must_use.stderr
index 27927cf37e9..9e37f6504cc 100644
--- a/tests/ui/lint/unused/unused_attributes-must_use.stderr
+++ b/tests/ui/lint/unused/unused_attributes-must_use.stderr
@@ -15,127 +15,127 @@ note: the lint level is defined here
 LL | #![deny(unused_attributes, unused_must_use)]
    |         ^^^^^^^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to an extern crate
+error: `#[must_use]` has no effect when applied to extern crates
   --> $DIR/unused_attributes-must_use.rs:7:1
    |
 LL | #[must_use]
    | ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to a module
+error: `#[must_use]` has no effect when applied to modules
   --> $DIR/unused_attributes-must_use.rs:10:1
    |
 LL | #[must_use]
    | ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to a use
+error: `#[must_use]` has no effect when applied to use statements
   --> $DIR/unused_attributes-must_use.rs:13:1
    |
 LL | #[must_use]
    | ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to a constant item
+error: `#[must_use]` has no effect when applied to constants
   --> $DIR/unused_attributes-must_use.rs:16:1
    |
 LL | #[must_use]
    | ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to a static item
+error: `#[must_use]` has no effect when applied to statics
   --> $DIR/unused_attributes-must_use.rs:18:1
    |
 LL | #[must_use]
    | ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to an inherent implementation block
+error: `#[must_use]` has no effect when applied to inherent impl blocks
   --> $DIR/unused_attributes-must_use.rs:35:1
    |
 LL | #[must_use]
    | ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to a foreign module
+error: `#[must_use]` has no effect when applied to foreign modules
   --> $DIR/unused_attributes-must_use.rs:49:1
    |
 LL | #[must_use]
    | ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to a type alias
+error: `#[must_use]` has no effect when applied to type aliases
   --> $DIR/unused_attributes-must_use.rs:63:1
    |
 LL | #[must_use]
    | ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to a type parameter
+error: `#[must_use]` has no effect when applied to type parameters
   --> $DIR/unused_attributes-must_use.rs:66:8
    |
 LL | fn qux<#[must_use] T>(_: T) {}
    |        ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to an trait implementation block
+error: `#[must_use]` has no effect when applied to trait impl blocks
   --> $DIR/unused_attributes-must_use.rs:81:1
    |
 LL | #[must_use]
    | ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to a trait alias
+error: `#[must_use]` has no effect when applied to trait aliases
   --> $DIR/unused_attributes-must_use.rs:91:1
    |
 LL | #[must_use]
    | ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to a macro def
+error: `#[must_use]` has no effect when applied to macro defs
   --> $DIR/unused_attributes-must_use.rs:94:1
    |
 LL | #[must_use]
    | ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to a statement
+error: `#[must_use]` has no effect when applied to statements
   --> $DIR/unused_attributes-must_use.rs:102:5
    |
 LL |     #[must_use]
    |     ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to a closure
+error: `#[must_use]` has no effect when applied to closures
   --> $DIR/unused_attributes-must_use.rs:106:13
    |
 LL |     let x = #[must_use]
    |             ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to an match arm
+error: `#[must_use]` has no effect when applied to match arms
   --> $DIR/unused_attributes-must_use.rs:128:9
    |
 LL |         #[must_use]
    |         ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to a struct field
+error: `#[must_use]` has no effect when applied to struct fields
   --> $DIR/unused_attributes-must_use.rs:136:28
    |
 LL |     let s = PatternField { #[must_use]  foo: 123 };
    |                            ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to a pattern field
+error: `#[must_use]` has no effect when applied to pattern fields
   --> $DIR/unused_attributes-must_use.rs:137:24
    |
 LL |     let PatternField { #[must_use] foo } = s;
    |                        ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to an associated const
+error: `#[must_use]` has no effect when applied to associated consts
   --> $DIR/unused_attributes-must_use.rs:70:5
    |
 LL |     #[must_use]
    |     ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to an associated type
+error: `#[must_use]` has no effect when applied to associated types
   --> $DIR/unused_attributes-must_use.rs:72:5
    |
 LL |     #[must_use]
    |     ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to a provided trait method
+error: `#[must_use]` has no effect when applied to provided trait methods
   --> $DIR/unused_attributes-must_use.rs:85:5
    |
 LL |     #[must_use]
    |     ^^^^^^^^^^^
 
-error: `#[must_use]` has no effect when applied to a foreign static item
+error: `#[must_use]` has no effect when applied to foreign statics
   --> $DIR/unused_attributes-must_use.rs:52:5
    |
 LL |     #[must_use]
diff --git a/tests/ui/lint/warn-unused-inline-on-fn-prototypes.rs b/tests/ui/lint/warn-unused-inline-on-fn-prototypes.rs
index 4684fe14577..bef607a4ec5 100644
--- a/tests/ui/lint/warn-unused-inline-on-fn-prototypes.rs
+++ b/tests/ui/lint/warn-unused-inline-on-fn-prototypes.rs
@@ -1,12 +1,14 @@
 #![deny(unused_attributes)]
 
 trait Trait {
-    #[inline] //~ ERROR `#[inline]` is ignored on function prototypes
+    #[inline] //~ ERROR attribute cannot be used on
+    //~^ WARN previously accepted
     fn foo();
 }
 
 extern "C" {
-    #[inline] //~ ERROR `#[inline]` is ignored on function prototypes
+    #[inline] //~ ERROR attribute cannot be used on
+    //~^ WARN previously accepted
     fn foo();
 }
 
diff --git a/tests/ui/lint/warn-unused-inline-on-fn-prototypes.stderr b/tests/ui/lint/warn-unused-inline-on-fn-prototypes.stderr
index ab19d80e732..336366042f9 100644
--- a/tests/ui/lint/warn-unused-inline-on-fn-prototypes.stderr
+++ b/tests/ui/lint/warn-unused-inline-on-fn-prototypes.stderr
@@ -1,20 +1,25 @@
-error: `#[inline]` is ignored on function prototypes
+error: `#[inline]` attribute cannot be used on required trait methods
   --> $DIR/warn-unused-inline-on-fn-prototypes.rs:4: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 be applied to functions, inherent methods, provided trait methods, trait methods in impl blocks, closures
 note: the lint level is defined here
   --> $DIR/warn-unused-inline-on-fn-prototypes.rs:1:9
    |
 LL | #![deny(unused_attributes)]
    |         ^^^^^^^^^^^^^^^^^
 
-error: `#[inline]` is ignored on function prototypes
-  --> $DIR/warn-unused-inline-on-fn-prototypes.rs:9:5
+error: `#[inline]` attribute cannot be used on foreign functions
+  --> $DIR/warn-unused-inline-on-fn-prototypes.rs:10: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 be applied to methods, functions, closures
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/loop-match/invalid-attribute.rs b/tests/ui/loop-match/invalid-attribute.rs
index d8d2f605eb4..a5d7daac583 100644
--- a/tests/ui/loop-match/invalid-attribute.rs
+++ b/tests/ui/loop-match/invalid-attribute.rs
@@ -3,17 +3,17 @@
 
 #![allow(incomplete_features)]
 #![feature(loop_match)]
-#![loop_match] //~ ERROR should be applied to a loop
-#![const_continue] //~ ERROR should be applied to a break expression
+#![loop_match] //~ ERROR attribute cannot be used on
+#![const_continue] //~ ERROR attribute cannot be used on
 
 extern "C" {
-    #[loop_match] //~ ERROR should be applied to a loop
-    #[const_continue] //~ ERROR should be applied to a break expression
+    #[loop_match] //~ ERROR attribute cannot be used on
+    #[const_continue] //~ ERROR attribute cannot be used on
     fn f();
 }
 
-#[loop_match] //~ ERROR should be applied to a loop
-#[const_continue] //~ ERROR should be applied to a break expression
+#[loop_match] //~ ERROR attribute cannot be used on
+#[const_continue] //~ ERROR attribute cannot be used on
 #[repr(C)]
 struct S {
     a: u32,
@@ -21,18 +21,18 @@ struct S {
 }
 
 trait Invoke {
-    #[loop_match] //~ ERROR should be applied to a loop
-    #[const_continue] //~ ERROR should be applied to a break expression
+    #[loop_match] //~ ERROR attribute cannot be used on
+    #[const_continue] //~ ERROR attribute cannot be used on
     extern "C" fn invoke(&self);
 }
 
-#[loop_match] //~ ERROR should be applied to a loop
-#[const_continue] //~ ERROR should be applied to a break expression
+#[loop_match] //~ ERROR attribute cannot be used on
+#[const_continue] //~ ERROR attribute cannot be used on
 extern "C" fn ok() {}
 
 fn main() {
-    #[loop_match] //~ ERROR should be applied to a loop
-    #[const_continue] //~ ERROR should be applied to a break expression
+    #[loop_match] //~ ERROR attribute cannot be used on
+    #[const_continue] //~ ERROR attribute cannot be used on
     || {};
 
     {
diff --git a/tests/ui/loop-match/invalid-attribute.stderr b/tests/ui/loop-match/invalid-attribute.stderr
index 07015311f9c..ddb68aea31b 100644
--- a/tests/ui/loop-match/invalid-attribute.stderr
+++ b/tests/ui/loop-match/invalid-attribute.stderr
@@ -1,54 +1,98 @@
-error: `#[const_continue]` should be applied to a break expression
-  --> $DIR/invalid-attribute.rs:16:1
+error: `#[loop_match]` attribute cannot be used on crates
+  --> $DIR/invalid-attribute.rs:6:1
    |
-LL | #[const_continue]
-   | ^^^^^^^^^^^^^^^^^
-LL | #[repr(C)]
-LL | struct S {
-   | -------- not a break expression
+LL | #![loop_match]
+   | ^^^^^^^^^^^^^^
+   |
+   = help: `#[loop_match]` can be applied to 
 
-error: `#[loop_match]` should be applied to a loop
+error: `#[const_continue]` attribute cannot be used on crates
+  --> $DIR/invalid-attribute.rs:7:1
+   |
+LL | #![const_continue]
+   | ^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[const_continue]` can be applied to 
+
+error: `#[loop_match]` attribute cannot be used on foreign functions
+  --> $DIR/invalid-attribute.rs:10:5
+   |
+LL |     #[loop_match]
+   |     ^^^^^^^^^^^^^
+   |
+   = help: `#[loop_match]` can be applied to 
+
+error: `#[const_continue]` attribute cannot be used on foreign functions
+  --> $DIR/invalid-attribute.rs:11:5
+   |
+LL |     #[const_continue]
+   |     ^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[const_continue]` can be applied to 
+
+error: `#[loop_match]` attribute cannot be used on structs
   --> $DIR/invalid-attribute.rs:15:1
    |
 LL | #[loop_match]
    | ^^^^^^^^^^^^^
-...
-LL | struct S {
-   | -------- not a loop
+   |
+   = help: `#[loop_match]` can be applied to 
 
-error: `#[const_continue]` should be applied to a break expression
-  --> $DIR/invalid-attribute.rs:30:1
+error: `#[const_continue]` attribute cannot be used on structs
+  --> $DIR/invalid-attribute.rs:16:1
    |
 LL | #[const_continue]
    | ^^^^^^^^^^^^^^^^^
-LL | extern "C" fn ok() {}
-   | ------------------ not a break expression
+   |
+   = help: `#[const_continue]` can be applied to 
 
-error: `#[loop_match]` should be applied to a loop
+error: `#[loop_match]` attribute cannot be used on required trait methods
+  --> $DIR/invalid-attribute.rs:24:5
+   |
+LL |     #[loop_match]
+   |     ^^^^^^^^^^^^^
+   |
+   = help: `#[loop_match]` can be applied to 
+
+error: `#[const_continue]` attribute cannot be used on required trait methods
+  --> $DIR/invalid-attribute.rs:25:5
+   |
+LL |     #[const_continue]
+   |     ^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[const_continue]` can be applied to 
+
+error: `#[loop_match]` attribute cannot be used on functions
   --> $DIR/invalid-attribute.rs:29:1
    |
 LL | #[loop_match]
    | ^^^^^^^^^^^^^
-LL | #[const_continue]
-LL | extern "C" fn ok() {}
-   | ------------------ not a loop
+   |
+   = help: `#[loop_match]` can be applied to 
 
-error: `#[const_continue]` should be applied to a break expression
-  --> $DIR/invalid-attribute.rs:35:5
+error: `#[const_continue]` attribute cannot be used on functions
+  --> $DIR/invalid-attribute.rs:30:1
    |
-LL |     #[const_continue]
-   |     ^^^^^^^^^^^^^^^^^
-LL |     || {};
-   |     -- not a break expression
+LL | #[const_continue]
+   | ^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[const_continue]` can be applied to 
 
-error: `#[loop_match]` should be applied to a loop
+error: `#[loop_match]` attribute cannot be used on closures
   --> $DIR/invalid-attribute.rs:34:5
    |
 LL |     #[loop_match]
    |     ^^^^^^^^^^^^^
+   |
+   = help: `#[loop_match]` can be applied to 
+
+error: `#[const_continue]` attribute cannot be used on closures
+  --> $DIR/invalid-attribute.rs:35:5
+   |
 LL |     #[const_continue]
-LL |     || {};
-   |     -- not a loop
+   |     ^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[const_continue]` can be applied to 
 
 error: `#[const_continue]` should be applied to a break expression
   --> $DIR/invalid-attribute.rs:40:9
@@ -67,65 +111,5 @@ LL |         #[const_continue]
 LL |         5
    |         - not a loop
 
-error: `#[const_continue]` should be applied to a break expression
-  --> $DIR/invalid-attribute.rs:25:5
-   |
-LL |     #[const_continue]
-   |     ^^^^^^^^^^^^^^^^^
-LL |     extern "C" fn invoke(&self);
-   |     ---------------------------- not a break expression
-
-error: `#[loop_match]` should be applied to a loop
-  --> $DIR/invalid-attribute.rs:24:5
-   |
-LL |     #[loop_match]
-   |     ^^^^^^^^^^^^^
-LL |     #[const_continue]
-LL |     extern "C" fn invoke(&self);
-   |     ---------------------------- not a loop
-
-error: `#[const_continue]` should be applied to a break expression
-  --> $DIR/invalid-attribute.rs:11:5
-   |
-LL |     #[const_continue]
-   |     ^^^^^^^^^^^^^^^^^
-LL |     fn f();
-   |     ------- not a break expression
-
-error: `#[loop_match]` should be applied to a loop
-  --> $DIR/invalid-attribute.rs:10:5
-   |
-LL |     #[loop_match]
-   |     ^^^^^^^^^^^^^
-LL |     #[const_continue]
-LL |     fn f();
-   |     ------- not a loop
-
-error: `#[const_continue]` should be applied to a break expression
-  --> $DIR/invalid-attribute.rs:7:1
-   |
-LL | / #![allow(incomplete_features)]
-LL | | #![feature(loop_match)]
-LL | | #![loop_match]
-LL | | #![const_continue]
-   | | ^^^^^^^^^^^^^^^^^^
-...  |
-LL | |     };
-LL | | }
-   | |_- not a break expression
-
-error: `#[loop_match]` should be applied to a loop
-  --> $DIR/invalid-attribute.rs:6:1
-   |
-LL | / #![allow(incomplete_features)]
-LL | | #![feature(loop_match)]
-LL | | #![loop_match]
-   | | ^^^^^^^^^^^^^^
-LL | | #![const_continue]
-...  |
-LL | |     };
-LL | | }
-   | |_- not a loop
-
 error: aborting due to 14 previous errors
 
diff --git a/tests/ui/macros/issue-68060.rs b/tests/ui/macros/issue-68060.rs
index 4eddb96848c..2edf9861743 100644
--- a/tests/ui/macros/issue-68060.rs
+++ b/tests/ui/macros/issue-68060.rs
@@ -2,13 +2,12 @@ fn main() {
     (0..)
         .map(
             #[target_feature(enable = "")]
-            //~^ ERROR: attribute should be applied to a function
+            //~^ ERROR: attribute cannot be used on
             #[track_caller]
             //~^ ERROR: `#[track_caller]` on closures is currently unstable
             //~| NOTE: see issue #87417
             //~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
             |_| (),
-            //~^ NOTE: not a function
         )
         .next();
 }
diff --git a/tests/ui/macros/issue-68060.stderr b/tests/ui/macros/issue-68060.stderr
index ef2246d5bd6..c701e50f054 100644
--- a/tests/ui/macros/issue-68060.stderr
+++ b/tests/ui/macros/issue-68060.stderr
@@ -1,11 +1,10 @@
-error: attribute should be applied to a function definition
+error: `#[target_feature]` attribute cannot be used on closures
   --> $DIR/issue-68060.rs:4:13
    |
 LL |             #[target_feature(enable = "")]
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-...
-LL |             |_| (),
-   |             ------ not a function definition
+   |
+   = help: `#[target_feature]` can be applied to methods, functions
 
 error[E0658]: `#[track_caller]` on closures is currently unstable
   --> $DIR/issue-68060.rs:6:13
diff --git a/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.rs b/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.rs
index 0bf620934ec..1fb206d628f 100644
--- a/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.rs
+++ b/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.rs
@@ -1,23 +1,23 @@
 #![feature(marker_trait_attr)]
 
-#[marker] //~ ERROR attribute should be applied to a trait
+#[marker] //~ ERROR attribute cannot be used on
 struct Struct {}
 
-#[marker] //~ ERROR attribute should be applied to a trait
+#[marker] //~ ERROR attribute cannot be used on
 impl Struct {}
 
-#[marker] //~ ERROR attribute should be applied to a trait
+#[marker] //~ ERROR attribute cannot be used on
 union Union {
     x: i32,
 }
 
-#[marker] //~ ERROR attribute should be applied to a trait
+#[marker] //~ ERROR attribute cannot be used on
 const CONST: usize = 10;
 
-#[marker] //~ ERROR attribute should be applied to a trait
+#[marker] //~ ERROR attribute cannot be used on
 fn function() {}
 
-#[marker] //~ ERROR attribute should be applied to a trait
+#[marker] //~ ERROR attribute cannot be used on
 type Type = ();
 
 fn main() {}
diff --git a/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.stderr b/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.stderr
index 19a5290dd7e..71abe7f39df 100644
--- a/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.stderr
+++ b/tests/ui/marker_trait_attr/marker-attribute-on-non-trait.stderr
@@ -1,52 +1,50 @@
-error: attribute should be applied to a trait
+error: `#[marker]` attribute cannot be used on structs
   --> $DIR/marker-attribute-on-non-trait.rs:3:1
    |
 LL | #[marker]
    | ^^^^^^^^^
-LL | struct Struct {}
-   | ---------------- not a trait
+   |
+   = help: `#[marker]` can only be applied to traits
 
-error: attribute should be applied to a trait
+error: `#[marker]` attribute cannot be used on inherent impl blocks
   --> $DIR/marker-attribute-on-non-trait.rs:6:1
    |
 LL | #[marker]
    | ^^^^^^^^^
-LL | impl Struct {}
-   | -------------- not a trait
+   |
+   = help: `#[marker]` can only be applied to traits
 
-error: attribute should be applied to a trait
+error: `#[marker]` attribute cannot be used on unions
   --> $DIR/marker-attribute-on-non-trait.rs:9:1
    |
-LL |   #[marker]
-   |   ^^^^^^^^^
-LL | / union Union {
-LL | |     x: i32,
-LL | | }
-   | |_- not a trait
+LL | #[marker]
+   | ^^^^^^^^^
+   |
+   = help: `#[marker]` can only be applied to traits
 
-error: attribute should be applied to a trait
+error: `#[marker]` attribute cannot be used on constants
   --> $DIR/marker-attribute-on-non-trait.rs:14:1
    |
 LL | #[marker]
    | ^^^^^^^^^
-LL | const CONST: usize = 10;
-   | ------------------------ not a trait
+   |
+   = help: `#[marker]` can only be applied to traits
 
-error: attribute should be applied to a trait
+error: `#[marker]` attribute cannot be used on functions
   --> $DIR/marker-attribute-on-non-trait.rs:17:1
    |
 LL | #[marker]
    | ^^^^^^^^^
-LL | fn function() {}
-   | ---------------- not a trait
+   |
+   = help: `#[marker]` can only be applied to traits
 
-error: attribute should be applied to a trait
+error: `#[marker]` attribute cannot be used on type aliases
   --> $DIR/marker-attribute-on-non-trait.rs:20:1
    |
 LL | #[marker]
    | ^^^^^^^^^
-LL | type Type = ();
-   | --------------- not a trait
+   |
+   = help: `#[marker]` can only be applied to traits
 
 error: aborting due to 6 previous errors
 
diff --git a/tests/ui/panic-handler/panic-handler-wrong-location.stderr b/tests/ui/panic-handler/panic-handler-wrong-location.stderr
index 66ee91aa4c1..9b361bf8d60 100644
--- a/tests/ui/panic-handler/panic-handler-wrong-location.stderr
+++ b/tests/ui/panic-handler/panic-handler-wrong-location.stderr
@@ -2,7 +2,7 @@ error[E0718]: `panic_impl` lang item must be applied to a function
   --> $DIR/panic-handler-wrong-location.rs:6:1
    |
 LL | #[panic_handler]
-   | ^^^^^^^^^^^^^^^^ attribute should be applied to a function, not a static item
+   | ^^^^^^^^^^^^^^^^ attribute should be applied to a function, not a static
 
 error: `#[panic_handler]` function required, but not found
 
diff --git a/tests/ui/proc-macro/illegal-proc-macro-derive-use.rs b/tests/ui/proc-macro/illegal-proc-macro-derive-use.rs
index 4efd9e952fc..19473fb2caf 100644
--- a/tests/ui/proc-macro/illegal-proc-macro-derive-use.rs
+++ b/tests/ui/proc-macro/illegal-proc-macro-derive-use.rs
@@ -8,7 +8,7 @@ pub fn foo(a: proc_macro::TokenStream) -> proc_macro::TokenStream {
 
 // Issue #37590
 #[proc_macro_derive(Foo)]
-//~^ ERROR: the `#[proc_macro_derive]` attribute may only be used on bare functions
+//~^ ERROR: attribute cannot be used on
 pub struct Foo {
 }
 
diff --git a/tests/ui/proc-macro/illegal-proc-macro-derive-use.stderr b/tests/ui/proc-macro/illegal-proc-macro-derive-use.stderr
index c0930ab7102..f01619b9195 100644
--- a/tests/ui/proc-macro/illegal-proc-macro-derive-use.stderr
+++ b/tests/ui/proc-macro/illegal-proc-macro-derive-use.stderr
@@ -4,11 +4,13 @@ error: the `#[proc_macro_derive]` attribute is only usable with crates of the `p
 LL | #[proc_macro_derive(Foo)]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^
 
-error: the `#[proc_macro_derive]` attribute may only be used on bare functions
+error: `#[proc_macro_derive]` attribute cannot be used on structs
   --> $DIR/illegal-proc-macro-derive-use.rs:10:1
    |
 LL | #[proc_macro_derive(Foo)]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[proc_macro_derive]` can only be applied to functions
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.rs b/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.rs
index 143f9a3009b..b538a97280d 100644
--- a/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.rs
+++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.rs
@@ -3,11 +3,11 @@
 struct Foo;
 
 #[non_exhaustive]
-//~^ ERROR attribute should be applied to a struct or enum [E0701]
+//~^ ERROR attribute cannot be used on
 trait Bar { }
 
 #[non_exhaustive]
-//~^ ERROR attribute should be applied to a struct or enum [E0701]
+//~^ ERROR attribute cannot be used on
 union Baz {
     f1: u16,
     f2: u16
diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr
index 1ac017aa08b..3522c459977 100644
--- a/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr
+++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr
@@ -7,28 +7,22 @@ LL | #[non_exhaustive(anything)]
    | |               didn't expect any arguments here
    | help: must be of the form: `#[non_exhaustive]`
 
-error[E0701]: attribute should be applied to a struct or enum
+error: `#[non_exhaustive]` attribute cannot be used on traits
   --> $DIR/invalid-attribute.rs:5:1
    |
 LL | #[non_exhaustive]
    | ^^^^^^^^^^^^^^^^^
-LL |
-LL | trait Bar { }
-   | ------------- not a struct or enum
+   |
+   = help: `#[non_exhaustive]` can be applied to data types, enum variants
 
-error[E0701]: attribute should be applied to a struct or enum
+error: `#[non_exhaustive]` attribute cannot be used on unions
   --> $DIR/invalid-attribute.rs:9:1
    |
-LL |   #[non_exhaustive]
-   |   ^^^^^^^^^^^^^^^^^
-LL |
-LL | / union Baz {
-LL | |     f1: u16,
-LL | |     f2: u16
-LL | | }
-   | |_- not a struct or enum
+LL | #[non_exhaustive]
+   | ^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[non_exhaustive]` can be applied to data types, enum variants
 
 error: aborting due to 3 previous errors
 
-Some errors have detailed explanations: E0565, E0701.
-For more information about an error, try `rustc --explain E0565`.
+For more information about this error, try `rustc --explain E0565`.
diff --git a/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.rs b/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.rs
index 2d2b01b6f94..53a856e0df3 100644
--- a/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.rs
+++ b/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.rs
@@ -1,5 +1,5 @@
 #[track_caller]
 struct S;
-//~^^ ERROR attribute should be applied to a function definition
+//~^^ ERROR attribute cannot be used on
 
 fn main() {}
diff --git a/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.stderr b/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.stderr
index f976b7f5210..6ff66be4e5c 100644
--- a/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.stderr
+++ b/tests/ui/rfcs/rfc-2091-track-caller/only-for-fns.stderr
@@ -1,11 +1,10 @@
-error[E0739]: attribute should be applied to a function definition
+error: `#[track_caller]` attribute cannot be used on structs
   --> $DIR/only-for-fns.rs:1:1
    |
 LL | #[track_caller]
    | ^^^^^^^^^^^^^^^
-LL | struct S;
-   | --------- not a function definition
+   |
+   = help: `#[track_caller]` can only be applied to functions
 
 error: aborting due to 1 previous error
 
-For more information about this error, try `rustc --explain E0739`.
diff --git a/tests/ui/rustdoc/check-doc-alias-attr-location.stderr b/tests/ui/rustdoc/check-doc-alias-attr-location.stderr
index 4244c11eb3e..23c93a4ed8b 100644
--- a/tests/ui/rustdoc/check-doc-alias-attr-location.stderr
+++ b/tests/ui/rustdoc/check-doc-alias-attr-location.stderr
@@ -10,13 +10,13 @@ error: `#[doc(alias = "...")]` isn't allowed on foreign module
 LL | #[doc(alias = "foo")]
    |       ^^^^^^^^^^^^^
 
-error: `#[doc(alias = "...")]` isn't allowed on inherent implementation block
+error: `#[doc(alias = "...")]` isn't allowed on implementation block
   --> $DIR/check-doc-alias-attr-location.rs:12:7
    |
 LL | #[doc(alias = "bar")]
    |       ^^^^^^^^^^^^^
 
-error: `#[doc(alias = "...")]` isn't allowed on trait implementation block
+error: `#[doc(alias = "...")]` isn't allowed on implementation block
   --> $DIR/check-doc-alias-attr-location.rs:18:7
    |
 LL | #[doc(alias = "foobar")]
diff --git a/tests/ui/target-feature/invalid-attribute.rs b/tests/ui/target-feature/invalid-attribute.rs
index d13098c3a6a..b34a48aba26 100644
--- a/tests/ui/target-feature/invalid-attribute.rs
+++ b/tests/ui/target-feature/invalid-attribute.rs
@@ -3,19 +3,16 @@
 #![warn(unused_attributes)]
 
 #[target_feature(enable = "sse2")]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 extern crate alloc;
-//~^ NOTE not a function
 
 #[target_feature(enable = "sse2")]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 use alloc::alloc::alloc;
-//~^ NOTE not a function
 
 #[target_feature(enable = "sse2")]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 extern "Rust" {}
-//~^ NOTE not a function
 
 #[target_feature = "+sse2"]
 //~^ ERROR malformed `target_feature` attribute
@@ -32,42 +29,35 @@ extern "Rust" {}
 unsafe fn foo() {}
 
 #[target_feature(enable = "sse2")]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 mod another {}
-//~^ NOTE not a function
 
 #[target_feature(enable = "sse2")]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 const FOO: usize = 7;
-//~^ NOTE not a function
 
 #[target_feature(enable = "sse2")]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 struct Foo;
-//~^ NOTE not a function
 
 #[target_feature(enable = "sse2")]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 enum Bar {}
-//~^ NOTE not a function
 
 #[target_feature(enable = "sse2")]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 union Qux {
-    //~^ NOTE not a function
-    f1: u16,
+        f1: u16,
     f2: u16,
 }
 
 #[target_feature(enable = "sse2")]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 type Uwu = ();
-//~^ NOTE not a function
 
 #[target_feature(enable = "sse2")]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 trait Baz {}
-//~^ NOTE not a function
 
 #[inline(always)]
 //~^ ERROR: cannot use `#[inline(always)]`
@@ -75,21 +65,18 @@ trait Baz {}
 unsafe fn test() {}
 
 #[target_feature(enable = "sse2")]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 static A: () = ();
-//~^ NOTE not a function
 
 #[target_feature(enable = "sse2")]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 impl Quux for u8 {}
-//~^ NOTE not a function
-//~| NOTE missing `foo` in implementation
+//~^ NOTE missing `foo` in implementation
 //~| ERROR missing: `foo`
 
 #[target_feature(enable = "sse2")]
-//~^ ERROR attribute should be applied to a function
+//~^ ERROR attribute cannot be used on
 impl Foo {}
-//~^ NOTE not a function
 
 trait Quux {
     fn foo(); //~ NOTE `foo` from trait
@@ -109,17 +96,15 @@ impl Quux for Foo {
 
 fn main() {
     #[target_feature(enable = "sse2")]
-    //~^ ERROR attribute should be applied to a function
+    //~^ ERROR attribute cannot be used on
     unsafe {
         foo();
     }
-    //~^^^ NOTE not a function
 
     #[target_feature(enable = "sse2")]
-    //~^ ERROR attribute should be applied to a function
+    //~^ ERROR attribute cannot be used on
     || {};
-    //~^ NOTE not a function
-}
+    }
 
 #[target_feature(enable = "+sse2")]
 //~^ ERROR `+sse2` is not valid for this target
diff --git a/tests/ui/target-feature/invalid-attribute.stderr b/tests/ui/target-feature/invalid-attribute.stderr
index 113c0c3695a..a0117649a57 100644
--- a/tests/ui/target-feature/invalid-attribute.stderr
+++ b/tests/ui/target-feature/invalid-attribute.stderr
@@ -1,5 +1,29 @@
+error: `#[target_feature]` attribute cannot be used on extern crates
+  --> $DIR/invalid-attribute.rs:5:1
+   |
+LL | #[target_feature(enable = "sse2")]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[target_feature]` can only be applied to functions
+
+error: `#[target_feature]` attribute cannot be used on use statements
+  --> $DIR/invalid-attribute.rs:9:1
+   |
+LL | #[target_feature(enable = "sse2")]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[target_feature]` can only be applied to functions
+
+error: `#[target_feature]` attribute cannot be used on foreign modules
+  --> $DIR/invalid-attribute.rs:13:1
+   |
+LL | #[target_feature(enable = "sse2")]
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[target_feature]` can only be applied to functions
+
 error[E0539]: malformed `target_feature` attribute input
-  --> $DIR/invalid-attribute.rs:20:1
+  --> $DIR/invalid-attribute.rs:17:1
    |
 LL | #[target_feature = "+sse2"]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -8,7 +32,7 @@ LL | #[target_feature = "+sse2"]
    | help: must be of the form: `#[target_feature(enable = "feat1, feat2")]`
 
 error[E0539]: malformed `target_feature` attribute input
-  --> $DIR/invalid-attribute.rs:26:1
+  --> $DIR/invalid-attribute.rs:23:1
    |
 LL | #[target_feature(bar)]
    | ^^^^^^^^^^^^^^^^^---^^
@@ -17,7 +41,7 @@ LL | #[target_feature(bar)]
    | help: must be of the form: `#[target_feature(enable = "feat1, feat2")]`
 
 error[E0539]: malformed `target_feature` attribute input
-  --> $DIR/invalid-attribute.rs:29:1
+  --> $DIR/invalid-attribute.rs:26:1
    |
 LL | #[target_feature(disable = "baz")]
    | ^^^^^^^^^^^^^^^^^-------^^^^^^^^^^
@@ -25,161 +49,116 @@ LL | #[target_feature(disable = "baz")]
    | |                expected this to be of the form `enable = "..."`
    | help: must be of the form: `#[target_feature(enable = "feat1, feat2")]`
 
-error: attribute should be applied to a function definition
-  --> $DIR/invalid-attribute.rs:5:1
+error: `#[target_feature]` attribute cannot be used on modules
+  --> $DIR/invalid-attribute.rs:31:1
    |
 LL | #[target_feature(enable = "sse2")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | extern crate alloc;
-   | ------------------- not a function definition
-
-error: attribute should be applied to a function definition
-  --> $DIR/invalid-attribute.rs:10:1
    |
-LL | #[target_feature(enable = "sse2")]
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | use alloc::alloc::alloc;
-   | ------------------------ not a function definition
+   = help: `#[target_feature]` can only be applied to functions
 
-error: attribute should be applied to a function definition
-  --> $DIR/invalid-attribute.rs:15:1
+error: `#[target_feature]` attribute cannot be used on constants
+  --> $DIR/invalid-attribute.rs:35:1
    |
 LL | #[target_feature(enable = "sse2")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | extern "Rust" {}
-   | ---------------- not a function definition
-
-error: attribute should be applied to a function definition
-  --> $DIR/invalid-attribute.rs:34:1
    |
-LL | #[target_feature(enable = "sse2")]
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | mod another {}
-   | -------------- not a function definition
+   = help: `#[target_feature]` can only be applied to functions
 
-error: attribute should be applied to a function definition
+error: `#[target_feature]` attribute cannot be used on structs
   --> $DIR/invalid-attribute.rs:39:1
    |
 LL | #[target_feature(enable = "sse2")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | const FOO: usize = 7;
-   | --------------------- not a function definition
+   |
+   = help: `#[target_feature]` can only be applied to functions
 
-error: attribute should be applied to a function definition
-  --> $DIR/invalid-attribute.rs:44:1
+error: `#[target_feature]` attribute cannot be used on enums
+  --> $DIR/invalid-attribute.rs:43:1
    |
 LL | #[target_feature(enable = "sse2")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | struct Foo;
-   | ----------- not a function definition
+   |
+   = help: `#[target_feature]` can only be applied to functions
 
-error: attribute should be applied to a function definition
-  --> $DIR/invalid-attribute.rs:49:1
+error: `#[target_feature]` attribute cannot be used on unions
+  --> $DIR/invalid-attribute.rs:47:1
    |
 LL | #[target_feature(enable = "sse2")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | enum Bar {}
-   | ----------- not a function definition
+   |
+   = help: `#[target_feature]` can only be applied to functions
 
-error: attribute should be applied to a function definition
+error: `#[target_feature]` attribute cannot be used on type aliases
   --> $DIR/invalid-attribute.rs:54:1
    |
-LL |   #[target_feature(enable = "sse2")]
-   |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | / union Qux {
-LL | |
-LL | |     f1: u16,
-LL | |     f2: u16,
-LL | | }
-   | |_- not a function definition
-
-error: attribute should be applied to a function definition
-  --> $DIR/invalid-attribute.rs:62:1
-   |
 LL | #[target_feature(enable = "sse2")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | type Uwu = ();
-   | -------------- not a function definition
+   |
+   = help: `#[target_feature]` can only be applied to functions
 
-error: attribute should be applied to a function definition
-  --> $DIR/invalid-attribute.rs:67:1
+error: `#[target_feature]` attribute cannot be used on traits
+  --> $DIR/invalid-attribute.rs:58:1
    |
 LL | #[target_feature(enable = "sse2")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | trait Baz {}
-   | ------------ not a function definition
-
-error: cannot use `#[inline(always)]` with `#[target_feature]`
-  --> $DIR/invalid-attribute.rs:72:1
    |
-LL | #[inline(always)]
-   | ^^^^^^^^^^^^^^^^^
+   = help: `#[target_feature]` can only be applied to functions
 
-error: attribute should be applied to a function definition
-  --> $DIR/invalid-attribute.rs:77:1
+error: `#[target_feature]` attribute cannot be used on statics
+  --> $DIR/invalid-attribute.rs:67:1
    |
 LL | #[target_feature(enable = "sse2")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | static A: () = ();
-   | ------------------ not a function definition
+   |
+   = help: `#[target_feature]` can only be applied to functions
 
-error: attribute should be applied to a function definition
-  --> $DIR/invalid-attribute.rs:82:1
+error: `#[target_feature]` attribute cannot be used on trait impl blocks
+  --> $DIR/invalid-attribute.rs:71:1
    |
 LL | #[target_feature(enable = "sse2")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | impl Quux for u8 {}
-   | ------------------- not a function definition
+   |
+   = help: `#[target_feature]` can only be applied to functions
 
-error: attribute should be applied to a function definition
-  --> $DIR/invalid-attribute.rs:89:1
+error: `#[target_feature]` attribute cannot be used on inherent impl blocks
+  --> $DIR/invalid-attribute.rs:77:1
    |
 LL | #[target_feature(enable = "sse2")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | impl Foo {}
-   | ----------- not a function definition
+   |
+   = help: `#[target_feature]` can only be applied to functions
 
-error: attribute should be applied to a function definition
-  --> $DIR/invalid-attribute.rs:111:5
+error: `#[target_feature]` attribute cannot be used on expressions
+  --> $DIR/invalid-attribute.rs:98:5
    |
-LL |       #[target_feature(enable = "sse2")]
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL | /     unsafe {
-LL | |         foo();
-LL | |     }
-   | |_____- not a function definition
+LL |     #[target_feature(enable = "sse2")]
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[target_feature]` can only be applied to functions
 
-error: attribute should be applied to a function definition
-  --> $DIR/invalid-attribute.rs:118:5
+error: `#[target_feature]` attribute cannot be used on closures
+  --> $DIR/invalid-attribute.rs:104:5
    |
 LL |     #[target_feature(enable = "sse2")]
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL |     || {};
-   |     ----- not a function definition
+   |
+   = help: `#[target_feature]` can be applied to methods, functions
+
+error: cannot use `#[inline(always)]` with `#[target_feature]`
+  --> $DIR/invalid-attribute.rs:62:1
+   |
+LL | #[inline(always)]
+   | ^^^^^^^^^^^^^^^^^
 
 error: the feature named `foo` is not valid for this target
-  --> $DIR/invalid-attribute.rs:23:18
+  --> $DIR/invalid-attribute.rs:20:18
    |
 LL | #[target_feature(enable = "foo")]
    |                  ^^^^^^^^^^^^^^ `foo` is not valid for this target
 
 error[E0046]: not all trait items implemented, missing: `foo`
-  --> $DIR/invalid-attribute.rs:84:1
+  --> $DIR/invalid-attribute.rs:73:1
    |
 LL | impl Quux for u8 {}
    | ^^^^^^^^^^^^^^^^ missing `foo` in implementation
@@ -188,7 +167,7 @@ LL |     fn foo();
    |     --------- `foo` from trait
 
 error: `#[target_feature(..)]` cannot be applied to safe trait method
-  --> $DIR/invalid-attribute.rs:100:5
+  --> $DIR/invalid-attribute.rs:87:5
    |
 LL |     #[target_feature(enable = "sse2")]
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be applied to safe trait method
@@ -197,13 +176,13 @@ LL |     fn foo() {}
    |     -------- not an `unsafe` function
 
 error[E0053]: method `foo` has an incompatible type for trait
-  --> $DIR/invalid-attribute.rs:103:5
+  --> $DIR/invalid-attribute.rs:90:5
    |
 LL |     fn foo() {}
    |     ^^^^^^^^ expected safe fn, found unsafe fn
    |
 note: type in trait
-  --> $DIR/invalid-attribute.rs:95:5
+  --> $DIR/invalid-attribute.rs:82:5
    |
 LL |     fn foo();
    |     ^^^^^^^^^
@@ -211,7 +190,7 @@ LL |     fn foo();
               found signature `#[target_features] fn()`
 
 error: the feature named `+sse2` is not valid for this target
-  --> $DIR/invalid-attribute.rs:124:18
+  --> $DIR/invalid-attribute.rs:109:18
    |
 LL | #[target_feature(enable = "+sse2")]
    |                  ^^^^^^^^^^^^^^^^ `+sse2` is not valid for this target
diff --git a/tests/ui/traits/alias/not-a-marker.rs b/tests/ui/traits/alias/not-a-marker.rs
index b004b9ff9ae..633cc60554d 100644
--- a/tests/ui/traits/alias/not-a-marker.rs
+++ b/tests/ui/traits/alias/not-a-marker.rs
@@ -1,7 +1,7 @@
 #![feature(trait_alias, marker_trait_attr)]
 
 #[marker]
-//~^ ERROR attribute should be applied to a trait
+//~^ ERROR attribute cannot be used on
 trait Foo = Send;
 
 fn main() {}
diff --git a/tests/ui/traits/alias/not-a-marker.stderr b/tests/ui/traits/alias/not-a-marker.stderr
index 2f3f6fea30f..8b0eba65b95 100644
--- a/tests/ui/traits/alias/not-a-marker.stderr
+++ b/tests/ui/traits/alias/not-a-marker.stderr
@@ -1,11 +1,10 @@
-error: attribute should be applied to a trait
+error: `#[marker]` attribute cannot be used on trait aliases
   --> $DIR/not-a-marker.rs:3:1
    |
 LL | #[marker]
    | ^^^^^^^^^
-LL |
-LL | trait Foo = Send;
-   | ----------------- not a trait
+   |
+   = help: `#[marker]` can only be applied to traits
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/traits/const-traits/attr-misuse.rs b/tests/ui/traits/const-traits/attr-misuse.rs
index 01ac74feff7..70dfcbf47d2 100644
--- a/tests/ui/traits/const-traits/attr-misuse.rs
+++ b/tests/ui/traits/const-traits/attr-misuse.rs
@@ -2,9 +2,9 @@
 
 #[const_trait]
 trait A {
-    #[const_trait] //~ ERROR attribute should be applied
+    #[const_trait] //~ ERROR attribute cannot be used on
     fn foo(self);
 }
 
-#[const_trait] //~ ERROR attribute should be applied
+#[const_trait] //~ ERROR attribute cannot be used on
 fn main() {}
diff --git a/tests/ui/traits/const-traits/attr-misuse.stderr b/tests/ui/traits/const-traits/attr-misuse.stderr
index 998958cedf7..2f86efac4c9 100644
--- a/tests/ui/traits/const-traits/attr-misuse.stderr
+++ b/tests/ui/traits/const-traits/attr-misuse.stderr
@@ -1,18 +1,18 @@
-error: attribute should be applied to a trait
+error: `#[const_trait]` attribute cannot be used on required trait methods
+  --> $DIR/attr-misuse.rs:5:5
+   |
+LL |     #[const_trait]
+   |     ^^^^^^^^^^^^^^
+   |
+   = help: `#[const_trait]` can only be applied to traits
+
+error: `#[const_trait]` attribute cannot be used on functions
   --> $DIR/attr-misuse.rs:9:1
    |
 LL | #[const_trait]
    | ^^^^^^^^^^^^^^
-LL | fn main() {}
-   | ------------ not a trait
-
-error: attribute should be applied to a trait
-  --> $DIR/attr-misuse.rs:5:5
    |
-LL |     #[const_trait]
-   |     ^^^^^^^^^^^^^^
-LL |     fn foo(self);
-   |     ------------- not a trait
+   = help: `#[const_trait]` can only be applied to traits
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/unstable-feature-bound/unstable_inherent_method.rs b/tests/ui/unstable-feature-bound/unstable_inherent_method.rs
index 0d6e4ebb408..cdd4178fc87 100644
--- a/tests/ui/unstable-feature-bound/unstable_inherent_method.rs
+++ b/tests/ui/unstable-feature-bound/unstable_inherent_method.rs
@@ -9,14 +9,14 @@
 pub trait Trait {
     #[unstable(feature = "feat", issue = "none" )]
     #[unstable_feature_bound(foo)]
-    //~^ ERROR: attribute should be applied to `impl`, trait or free function
+    //~^ ERROR: attribute cannot be used on
     fn foo();
 }
 
 #[stable(feature = "a", since = "1.1.1" )]
 impl Trait for u8 {
     #[unstable_feature_bound(foo)]
-    //~^ ERROR: attribute should be applied to `impl`, trait or free function
+    //~^ ERROR: attribute cannot be used on
     fn foo() {}
 }
 
diff --git a/tests/ui/unstable-feature-bound/unstable_inherent_method.stderr b/tests/ui/unstable-feature-bound/unstable_inherent_method.stderr
index 90cbb32df7c..2a1ae936cfe 100644
--- a/tests/ui/unstable-feature-bound/unstable_inherent_method.stderr
+++ b/tests/ui/unstable-feature-bound/unstable_inherent_method.stderr
@@ -1,20 +1,18 @@
-error: attribute should be applied to `impl`, trait or free function
+error: `#[unstable_feature_bound]` attribute cannot be used on required trait methods
   --> $DIR/unstable_inherent_method.rs:11:5
    |
 LL |     #[unstable_feature_bound(foo)]
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL |     fn foo();
-   |     --------- not an `impl`, trait or free function
+   |
+   = help: `#[unstable_feature_bound]` can be applied to functions, trait impl blocks, traits
 
-error: attribute should be applied to `impl`, trait or free function
+error: `#[unstable_feature_bound]` attribute cannot be used on trait methods in impl blocks
   --> $DIR/unstable_inherent_method.rs:18:5
    |
 LL |     #[unstable_feature_bound(foo)]
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL |
-LL |     fn foo() {}
-   |     ----------- not an `impl`, trait or free function
+   |
+   = help: `#[unstable_feature_bound]` can be applied to functions, trait impl blocks, traits
 
 error: aborting due to 2 previous errors
 
diff --git a/tests/ui/where-clauses/unsupported_attribute.rs b/tests/ui/where-clauses/unsupported_attribute.rs
index 33128b383b9..75213e17661 100644
--- a/tests/ui/where-clauses/unsupported_attribute.rs
+++ b/tests/ui/where-clauses/unsupported_attribute.rs
@@ -13,18 +13,18 @@ fn foo<'a, T>()
 where
     #[doc = "doc"] T: Trait, //~ ERROR most attributes are not supported in `where` clauses
     #[doc = "doc"] 'a: 'static, //~ ERROR most attributes are not supported in `where` clauses
-    #[ignore] T: Trait, //~ ERROR most attributes are not supported in `where` clauses
-    #[ignore] 'a: 'static, //~ ERROR most attributes are not supported in `where` clauses
-    #[should_panic] T: Trait, //~ ERROR most attributes are not supported in `where` clauses
-    #[should_panic] 'a: 'static, //~ ERROR most attributes are not supported in `where` clauses
-    #[macro_use] T: Trait, //~ ERROR most attributes are not supported in `where` clauses
-    #[macro_use] 'a: 'static, //~ ERROR most attributes are not supported in `where` clauses
+    #[ignore] T: Trait, //~ ERROR attribute cannot be used on
+    #[ignore] 'a: 'static, //~ ERROR attribute cannot be used on
+    #[should_panic] T: Trait, //~ ERROR attribute cannot be used on
+    #[should_panic] 'a: 'static, //~ ERROR attribute cannot be used on
+    #[macro_use] T: Trait, //~ ERROR attribute cannot be used on
+    #[macro_use] 'a: 'static, //~ ERROR attribute cannot be used on
     #[allow(unused)] T: Trait, //~ ERROR most attributes are not supported in `where` clauses
     #[allow(unused)] 'a: 'static, //~ ERROR most attributes are not supported in `where` clauses
-    #[deprecated] T: Trait, //~ ERROR most attributes are not supported in `where` clauses
-    #[deprecated] 'a: 'static, //~ ERROR most attributes are not supported in `where` clauses
-    #[automatically_derived] T: Trait, //~ ERROR most attributes are not supported in `where` clauses
-    #[automatically_derived] 'a: 'static, //~ ERROR most attributes are not supported in `where` clauses
+    #[deprecated] T: Trait, //~ ERROR attribute cannot be used on
+    #[deprecated] 'a: 'static, //~ ERROR attribute cannot be used on
+    #[automatically_derived] T: Trait, //~ ERROR attribute cannot be used on
+    #[automatically_derived] 'a: 'static, //~ ERROR attribute cannot be used on
     #[derive(Clone)] T: Trait,
     //~^ ERROR most attributes are not supported in `where` clauses
     //~| ERROR expected non-macro attribute, found attribute macro `derive`
diff --git a/tests/ui/where-clauses/unsupported_attribute.stderr b/tests/ui/where-clauses/unsupported_attribute.stderr
index ecb28039f88..411c895ed87 100644
--- a/tests/ui/where-clauses/unsupported_attribute.stderr
+++ b/tests/ui/where-clauses/unsupported_attribute.stderr
@@ -10,115 +10,115 @@ error: expected non-macro attribute, found attribute macro `derive`
 LL |     #[derive(Clone)] 'a: 'static,
    |       ^^^^^^ not a non-macro attribute
 
-error: most attributes are not supported in `where` clauses
-  --> $DIR/unsupported_attribute.rs:14:5
-   |
-LL |     #[doc = "doc"] T: Trait,
-   |     ^^^^^^^^^^^^^^
-   |
-   = help: only `#[cfg]` and `#[cfg_attr]` are supported
-
-error: most attributes are not supported in `where` clauses
-  --> $DIR/unsupported_attribute.rs:15:5
-   |
-LL |     #[doc = "doc"] 'a: 'static,
-   |     ^^^^^^^^^^^^^^
-   |
-   = help: only `#[cfg]` and `#[cfg_attr]` are supported
-
-error: most attributes are not supported in `where` clauses
+error: `#[ignore]` attribute cannot be used on where predicates
   --> $DIR/unsupported_attribute.rs:16:5
    |
 LL |     #[ignore] T: Trait,
    |     ^^^^^^^^^
    |
-   = help: only `#[cfg]` and `#[cfg_attr]` are supported
+   = help: `#[ignore]` can only be applied to functions
 
-error: most attributes are not supported in `where` clauses
+error: `#[ignore]` attribute cannot be used on where predicates
   --> $DIR/unsupported_attribute.rs:17:5
    |
 LL |     #[ignore] 'a: 'static,
    |     ^^^^^^^^^
    |
-   = help: only `#[cfg]` and `#[cfg_attr]` are supported
+   = help: `#[ignore]` can only be applied to functions
 
-error: most attributes are not supported in `where` clauses
+error: `#[should_panic]` attribute cannot be used on where predicates
   --> $DIR/unsupported_attribute.rs:18:5
    |
 LL |     #[should_panic] T: Trait,
    |     ^^^^^^^^^^^^^^^
    |
-   = help: only `#[cfg]` and `#[cfg_attr]` are supported
+   = help: `#[should_panic]` can only be applied to functions
 
-error: most attributes are not supported in `where` clauses
+error: `#[should_panic]` attribute cannot be used on where predicates
   --> $DIR/unsupported_attribute.rs:19:5
    |
 LL |     #[should_panic] 'a: 'static,
    |     ^^^^^^^^^^^^^^^
    |
-   = help: only `#[cfg]` and `#[cfg_attr]` are supported
+   = help: `#[should_panic]` can only be applied to functions
 
-error: most attributes are not supported in `where` clauses
+error: `#[macro_use]` attribute cannot be used on where predicates
   --> $DIR/unsupported_attribute.rs:20:5
    |
 LL |     #[macro_use] T: Trait,
    |     ^^^^^^^^^^^^
    |
-   = help: only `#[cfg]` and `#[cfg_attr]` are supported
+   = help: `#[macro_use]` can be applied to modules, extern crates, crates
 
-error: most attributes are not supported in `where` clauses
+error: `#[macro_use]` attribute cannot be used on where predicates
   --> $DIR/unsupported_attribute.rs:21:5
    |
 LL |     #[macro_use] 'a: 'static,
    |     ^^^^^^^^^^^^
    |
-   = help: only `#[cfg]` and `#[cfg_attr]` are supported
+   = help: `#[macro_use]` can be applied to modules, extern crates, crates
 
-error: most attributes are not supported in `where` clauses
-  --> $DIR/unsupported_attribute.rs:22:5
+error: `#[deprecated]` attribute cannot be used on where predicates
+  --> $DIR/unsupported_attribute.rs:24:5
    |
-LL |     #[allow(unused)] T: Trait,
-   |     ^^^^^^^^^^^^^^^^
+LL |     #[deprecated] T: Trait,
+   |     ^^^^^^^^^^^^^
    |
-   = help: only `#[cfg]` and `#[cfg_attr]` are supported
+   = help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, crates
 
-error: most attributes are not supported in `where` clauses
-  --> $DIR/unsupported_attribute.rs:23:5
+error: `#[deprecated]` attribute cannot be used on where predicates
+  --> $DIR/unsupported_attribute.rs:25:5
    |
-LL |     #[allow(unused)] 'a: 'static,
-   |     ^^^^^^^^^^^^^^^^
+LL |     #[deprecated] 'a: 'static,
+   |     ^^^^^^^^^^^^^
    |
-   = help: only `#[cfg]` and `#[cfg_attr]` are supported
+   = help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, crates
+
+error: `#[automatically_derived]` attribute cannot be used on where predicates
+  --> $DIR/unsupported_attribute.rs:26:5
+   |
+LL |     #[automatically_derived] T: Trait,
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[automatically_derived]` can only be applied to trait impl blocks
+
+error: `#[automatically_derived]` attribute cannot be used on where predicates
+  --> $DIR/unsupported_attribute.rs:27:5
+   |
+LL |     #[automatically_derived] 'a: 'static,
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: `#[automatically_derived]` can only be applied to trait impl blocks
 
 error: most attributes are not supported in `where` clauses
-  --> $DIR/unsupported_attribute.rs:24:5
+  --> $DIR/unsupported_attribute.rs:14:5
    |
-LL |     #[deprecated] T: Trait,
-   |     ^^^^^^^^^^^^^
+LL |     #[doc = "doc"] T: Trait,
+   |     ^^^^^^^^^^^^^^
    |
    = help: only `#[cfg]` and `#[cfg_attr]` are supported
 
 error: most attributes are not supported in `where` clauses
-  --> $DIR/unsupported_attribute.rs:25:5
+  --> $DIR/unsupported_attribute.rs:15:5
    |
-LL |     #[deprecated] 'a: 'static,
-   |     ^^^^^^^^^^^^^
+LL |     #[doc = "doc"] 'a: 'static,
+   |     ^^^^^^^^^^^^^^
    |
    = help: only `#[cfg]` and `#[cfg_attr]` are supported
 
 error: most attributes are not supported in `where` clauses
-  --> $DIR/unsupported_attribute.rs:26:5
+  --> $DIR/unsupported_attribute.rs:22:5
    |
-LL |     #[automatically_derived] T: Trait,
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+LL |     #[allow(unused)] T: Trait,
+   |     ^^^^^^^^^^^^^^^^
    |
    = help: only `#[cfg]` and `#[cfg_attr]` are supported
 
 error: most attributes are not supported in `where` clauses
-  --> $DIR/unsupported_attribute.rs:27:5
+  --> $DIR/unsupported_attribute.rs:23:5
    |
-LL |     #[automatically_derived] 'a: 'static,
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+LL |     #[allow(unused)] 'a: 'static,
+   |     ^^^^^^^^^^^^^^^^
    |
    = help: only `#[cfg]` and `#[cfg_attr]` are supported