diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2025-08-11 17:02:32 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2025-08-11 17:02:32 +0000 |
| commit | 32ee26c625e8fbb7a3aa56788cbb352f04491964 (patch) | |
| tree | 7aa1e7f03f7f47ce16b3405859d41e35f32bd945 /tests/ui/proc-macro | |
| parent | 413ca5d9f0868f5d91a8b773ce60d70d5205c3f3 (diff) | |
| download | rust-32ee26c625e8fbb7a3aa56788cbb352f04491964.tar.gz rust-32ee26c625e8fbb7a3aa56788cbb352f04491964.zip | |
Add more docs to templates for attrs with incorrect arguments
Diffstat (limited to 'tests/ui/proc-macro')
| -rw-r--r-- | tests/ui/proc-macro/attribute.rs | 16 | ||||
| -rw-r--r-- | tests/ui/proc-macro/attribute.stderr | 46 |
2 files changed, 47 insertions, 15 deletions
diff --git a/tests/ui/proc-macro/attribute.rs b/tests/ui/proc-macro/attribute.rs index 988cdcd0403..dfb26738377 100644 --- a/tests/ui/proc-macro/attribute.rs +++ b/tests/ui/proc-macro/attribute.rs @@ -9,46 +9,55 @@ use proc_macro::*; #[proc_macro_derive] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected this to be a list +//~| NOTE for more information, visit pub fn foo1(input: TokenStream) -> TokenStream { input } #[proc_macro_derive = ""] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected this to be a list +//~| NOTE for more information, visit pub fn foo2(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d3, a, b)] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE the only valid argument here is `attributes` +//~| NOTE for more information, visit pub fn foo3(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d4, attributes(a), b)] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE didn't expect any arguments here +//~| NOTE for more information, visit pub fn foo4(input: TokenStream) -> TokenStream { input } #[proc_macro_derive("a")] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE didn't expect a literal here +//~| NOTE for more information, visit pub fn foo5(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d6 = "")] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE didn't expect any arguments here +//~| NOTE for more information, visit pub fn foo6(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(m::d7)] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected a valid identifier here +//~| NOTE for more information, visit pub fn foo7(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d8(a))] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE didn't expect any arguments here +//~| NOTE for more information, visit pub fn foo8(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(self)] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected a valid identifier here +//~| NOTE for more information, visit pub fn foo9(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(PartialEq)] // OK @@ -57,34 +66,41 @@ pub fn foo10(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d11, a)] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE the only valid argument here is `attributes` +//~| NOTE for more information, visit pub fn foo11(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d12, attributes)] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected this to be a list +//~| NOTE for more information, visit pub fn foo12(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d13, attributes("a"))] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected a valid identifier here +//~| NOTE for more information, visit pub fn foo13(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d14, attributes(a = ""))] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE didn't expect any arguments here +//~| NOTE for more information, visit pub fn foo14(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d15, attributes(m::a))] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected a valid identifier here +//~| NOTE for more information, visit pub fn foo15(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d16, attributes(a(b)))] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE didn't expect any arguments here +//~| NOTE for more information, visit pub fn foo16(input: TokenStream) -> TokenStream { input } #[proc_macro_derive(d17, attributes(self))] //~^ ERROR malformed `proc_macro_derive` attribute //~| NOTE expected a valid identifier here +//~| NOTE for more information, visit pub fn foo17(input: TokenStream) -> TokenStream { input } diff --git a/tests/ui/proc-macro/attribute.stderr b/tests/ui/proc-macro/attribute.stderr index ea92e93e93f..e7127c8ef1d 100644 --- a/tests/ui/proc-macro/attribute.stderr +++ b/tests/ui/proc-macro/attribute.stderr @@ -4,6 +4,7 @@ error[E0539]: malformed `proc_macro_derive` attribute input LL | #[proc_macro_derive] | ^^^^^^^^^^^^^^^^^^^^ expected this to be a list | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> help: try changing it to one of the following valid forms of the attribute | LL | #[proc_macro_derive(TraitName)] @@ -12,11 +13,12 @@ LL | #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] | ++++++++++++++++++++++++++++++++++++++++++ error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:14:1 + --> $DIR/attribute.rs:15:1 | LL | #[proc_macro_derive = ""] | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected this to be a list | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> help: try changing it to one of the following valid forms of the attribute | LL - #[proc_macro_derive = ""] @@ -27,13 +29,14 @@ LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:19:1 + --> $DIR/attribute.rs:21:1 | LL | #[proc_macro_derive(d3, a, b)] | ^^^^^^^^^^^^^^^^^^^^^^^^-^^^^^ | | | the only valid argument here is `attributes` | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> help: try changing it to one of the following valid forms of the attribute | LL - #[proc_macro_derive(d3, a, b)] @@ -44,13 +47,14 @@ LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] | error[E0565]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:24:1 + --> $DIR/attribute.rs:27:1 | LL | #[proc_macro_derive(d4, attributes(a), b)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-^^ | | | didn't expect any arguments here | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> help: try changing it to one of the following valid forms of the attribute | LL - #[proc_macro_derive(d4, attributes(a), b)] @@ -61,13 +65,14 @@ LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] | error[E0565]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:29:1 + --> $DIR/attribute.rs:33:1 | LL | #[proc_macro_derive("a")] | ^^^^^^^^^^^^^^^^^^^^---^^ | | | didn't expect a literal here | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> help: try changing it to one of the following valid forms of the attribute | LL - #[proc_macro_derive("a")] @@ -78,13 +83,14 @@ LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] | error[E0565]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:34:1 + --> $DIR/attribute.rs:39:1 | LL | #[proc_macro_derive(d6 = "")] | ^^^^^^^^^^^^^^^^^^^^^^^----^^ | | | didn't expect any arguments here | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> help: try changing it to one of the following valid forms of the attribute | LL - #[proc_macro_derive(d6 = "")] @@ -95,13 +101,14 @@ LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:39:1 + --> $DIR/attribute.rs:45:1 | LL | #[proc_macro_derive(m::d7)] | ^^^^^^^^^^^^^^^^^^^^-----^^ | | | expected a valid identifier here | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> help: try changing it to one of the following valid forms of the attribute | LL - #[proc_macro_derive(m::d7)] @@ -112,13 +119,14 @@ LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] | error[E0565]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:44:1 + --> $DIR/attribute.rs:51:1 | LL | #[proc_macro_derive(d8(a))] | ^^^^^^^^^^^^^^^^^^^^^^---^^ | | | didn't expect any arguments here | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> help: try changing it to one of the following valid forms of the attribute | LL - #[proc_macro_derive(d8(a))] @@ -129,13 +137,14 @@ LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:49:1 + --> $DIR/attribute.rs:57:1 | LL | #[proc_macro_derive(self)] | ^^^^^^^^^^^^^^^^^^^^----^^ | | | expected a valid identifier here | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> help: try changing it to one of the following valid forms of the attribute | LL - #[proc_macro_derive(self)] @@ -146,13 +155,14 @@ LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:57:1 + --> $DIR/attribute.rs:66:1 | LL | #[proc_macro_derive(d11, a)] | ^^^^^^^^^^^^^^^^^^^^^^^^^-^^ | | | the only valid argument here is `attributes` | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> help: try changing it to one of the following valid forms of the attribute | LL - #[proc_macro_derive(d11, a)] @@ -163,13 +173,14 @@ LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:62:1 + --> $DIR/attribute.rs:72:1 | LL | #[proc_macro_derive(d12, attributes)] | ^^^^^^^^^^^^^^^^^^^^^^^^^----------^^ | | | expected this to be a list | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> help: try changing it to one of the following valid forms of the attribute | LL - #[proc_macro_derive(d12, attributes)] @@ -180,13 +191,14 @@ LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:67:1 + --> $DIR/attribute.rs:78:1 | LL | #[proc_macro_derive(d13, attributes("a"))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---^^^ | | | expected a valid identifier here | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> help: try changing it to one of the following valid forms of the attribute | LL - #[proc_macro_derive(d13, attributes("a"))] @@ -197,13 +209,14 @@ LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] | error[E0565]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:72:1 + --> $DIR/attribute.rs:84:1 | LL | #[proc_macro_derive(d14, attributes(a = ""))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----^^^ | | | didn't expect any arguments here | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> help: try changing it to one of the following valid forms of the attribute | LL - #[proc_macro_derive(d14, attributes(a = ""))] @@ -214,13 +227,14 @@ LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:77:1 + --> $DIR/attribute.rs:90:1 | LL | #[proc_macro_derive(d15, attributes(m::a))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----^^^ | | | expected a valid identifier here | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> help: try changing it to one of the following valid forms of the attribute | LL - #[proc_macro_derive(d15, attributes(m::a))] @@ -231,13 +245,14 @@ LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] | error[E0565]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:82:1 + --> $DIR/attribute.rs:96:1 | LL | #[proc_macro_derive(d16, attributes(a(b)))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---^^^ | | | didn't expect any arguments here | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> help: try changing it to one of the following valid forms of the attribute | LL - #[proc_macro_derive(d16, attributes(a(b)))] @@ -248,13 +263,14 @@ LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/attribute.rs:87:1 + --> $DIR/attribute.rs:102:1 | LL | #[proc_macro_derive(d17, attributes(self))] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----^^^ | | | expected a valid identifier here | + = note: for more information, visit <https://doc.rust-lang.org/reference/procedural-macros.html#derive-macros> help: try changing it to one of the following valid forms of the attribute | LL - #[proc_macro_derive(d17, attributes(self))] |
