about summary refs log tree commit diff
path: root/tests/ui/attributes
diff options
context:
space:
mode:
authorJonathan Brouwer <jonathantbrouwer@gmail.com>2025-08-09 20:41:01 +0200
committerJonathan Brouwer <jonathantbrouwer@gmail.com>2025-08-14 18:18:42 +0200
commit4bb7bf64e07fee97439ee6e647aa2b58cbaac54d (patch)
treec90dba79f6e421a1d7d1fd428100ef32b47c0b9b /tests/ui/attributes
parent5245c399720cf4f2414c2a4d9b4a5007ad942956 (diff)
downloadrust-4bb7bf64e07fee97439ee6e647aa2b58cbaac54d.tar.gz
rust-4bb7bf64e07fee97439ee6e647aa2b58cbaac54d.zip
Update uitests
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
Diffstat (limited to 'tests/ui/attributes')
-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
30 files changed, 289 insertions, 245 deletions
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