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> {
105105 match item. node {
106106 ast:: ItemKind :: Fn ( ..) => { }
107107 _ => {
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+ }
108119 self . check_not_pub_in_root ( & item. vis , item. span ) ;
109120 return visit:: walk_item ( self , item)
110121 }
Original file line number Diff line number Diff line change @@ -18,4 +18,10 @@ pub fn foo(a: proc_macro::TokenStream) -> proc_macro::TokenStream {
1818 a
1919}
2020
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+
2127fn main ( ) { }
You can’t perform that action at this time.
0 commit comments