File tree Expand file tree Collapse file tree 1 file changed +30
-11
lines changed Expand file tree Collapse file tree 1 file changed +30
-11
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ use proc_macro::TokenStream;
44use  proc_macro2:: TokenStream  as  TokenStream2 ; 
55use  quote:: { ToTokens ,  quote} ; 
66use  syn:: { 
7+     Attribute , 
78    Meta , 
89    ReturnType , 
910    Token , 
@@ -75,24 +76,42 @@ pub fn run(
7576        ctxt. error_spanned_by ( & f. sig ,  "main function must have 1 argument: the spawner." ) ; 
7677    } 
7778
79+     let  fattrs = f. attrs ; 
80+     let  lint_attrs:  Vec < Attribute >  = fattrs
81+         . clone ( ) 
82+         . into_iter ( ) 
83+         . filter ( |item| { 
84+             item. path ( ) . is_ident ( "deny" ) 
85+                 || item. path ( ) . is_ident ( "allow" ) 
86+                 || item. path ( ) . is_ident ( "warn" ) 
87+         } ) 
88+         . collect ( ) ; 
89+ 
7890    ctxt. check ( ) ?; 
7991
8092    let  f_body = f. block ; 
8193    let  out = & f. sig . output ; 
8294
8395    let  result = quote !  { 
84-         #[ doc( hidden) ] 
85-         #[ :: embassy_executor:: task( ) ] 
86-         async  fn  __embassy_main( #fargs)  #out { 
87-             #f_body
96+         #( #lint_attrs) * 
97+         pub ( crate )  mod  __main { 
98+             use  super :: * ; 
99+ 
100+             #[ doc( hidden) ] 
101+             #( #fattrs) * 
102+             #[ :: embassy_executor:: task( ) ] 
103+             async  fn  __embassy_main( #fargs)  #out { 
104+                 #f_body
105+             } 
106+ 
107+             #[ doc( hidden) ] 
108+             unsafe  fn  __make_static<T >( t:  & mut  T )  -> & ' static  mut  T  { 
109+                 :: core:: mem:: transmute( t) 
110+             } 
111+ 
112+             #( #fattrs) * 
113+             #main
88114        } 
89- 
90-         #[ doc( hidden) ] 
91-         unsafe  fn  __make_static<T >( t:  & mut  T )  -> & ' static  mut  T  { 
92-             :: core:: mem:: transmute( t) 
93-         } 
94- 
95-         #main
96115    } ; 
97116
98117    Ok ( result) 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments