syntax_ext: Validate #[proc_macro_derive] input better

Tweak some error wording
This commit is contained in:
Vadim Petrochenkov 2019-03-03 19:04:58 +03:00
parent 8371caf5ee
commit 5cb5083909
4 changed files with 33 additions and 11 deletions

View file

@ -39,11 +39,11 @@ pub fn foo7(input: TokenStream) -> TokenStream { input }
pub fn foo8(input: TokenStream) -> TokenStream { input }
#[proc_macro_derive(self)]
//FIXME ERROR: `self` cannot be a name of derive macro
//~^ ERROR: `self` cannot be a name of derive macro
pub fn foo9(input: TokenStream) -> TokenStream { input }
#[proc_macro_derive(PartialEq)]
//~^ ERROR: cannot override a built-in #[derive] mode
//~^ ERROR: cannot override a built-in derive macro
pub fn foo10(input: TokenStream) -> TokenStream { input }
#[proc_macro_derive(d11, a)]
@ -72,5 +72,5 @@ pub fn foo15(input: TokenStream) -> TokenStream { input }
pub fn foo16(input: TokenStream) -> TokenStream { input }
#[proc_macro_derive(d17, attributes(self))]
//FIXME ERROR: `self` cannot be a name of derive helper attribute
//~^ ERROR: `self` cannot be a name of derive helper attribute
pub fn foo17(input: TokenStream) -> TokenStream { input }

View file

@ -34,7 +34,13 @@ error: must only be one word
LL | #[proc_macro_derive(d8(a))]
| ^^^^^
error: cannot override a built-in #[derive] mode
error: `self` cannot be a name of derive macro
--> $DIR/attribute.rs:41:21
|
LL | #[proc_macro_derive(self)]
| ^^^^
error: cannot override a built-in derive macro
--> $DIR/attribute.rs:45:21
|
LL | #[proc_macro_derive(PartialEq)]
@ -82,6 +88,12 @@ error: must only be one word
LL | #[proc_macro_derive(d16, attributes(a(b)))]
| ^^^^
error: `self` cannot be a name of derive helper attribute
--> $DIR/attribute.rs:74:37
|
LL | #[proc_macro_derive(d17, attributes(self))]
| ^^^^
error: attribute must be of the form `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]`
--> $DIR/attribute.rs:9:1
|
@ -94,5 +106,5 @@ error: attribute must be of the form `#[proc_macro_derive(TraitName, /*opt*/ att
LL | #[proc_macro_derive = ""]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 16 previous errors
error: aborting due to 18 previous errors