File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
test/compile-fail-fulldeps/proc-macro Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,17 @@ impl<'a> Visitor for CollectCustomDerives<'a> {
105
105
match item. node {
106
106
ast:: ItemKind :: Fn ( ..) => { }
107
107
_ => {
108
+ // Check for invalid use of proc_macro_derive
109
+ let attr = item. attrs . iter ( )
110
+ . filter ( |a| a. check_name ( "proc_macro_derive" ) )
111
+ . next ( ) ;
112
+ if let Some ( attr) = attr {
113
+ self . handler . span_err ( attr. span ( ) ,
114
+ "the `#[proc_macro_derive]` \
115
+ attribute may only be used \
116
+ on bare functions") ;
117
+ return ;
118
+ }
108
119
self . check_not_pub_in_root ( & item. vis , item. span ) ;
109
120
return visit:: walk_item ( self , item)
110
121
}
Original file line number Diff line number Diff line change @@ -18,4 +18,10 @@ pub fn foo(a: proc_macro::TokenStream) -> proc_macro::TokenStream {
18
18
a
19
19
}
20
20
21
+ // Issue #37590
22
+ #[ proc_macro_derive( Foo ) ]
23
+ //~^ ERROR: the `#[proc_macro_derive]` attribute may only be used on bare functions
24
+ pub struct Foo {
25
+ }
26
+
21
27
fn main ( ) { }
You can’t perform that action at this time.
0 commit comments