@@ -17,7 +17,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};
17
17
use std:: time:: { SystemTime , UNIX_EPOCH } ;
18
18
use syn:: {
19
19
parse, spanned:: Spanned , AttrStyle , Attribute , FnArg , Ident , Item , ItemFn , ItemStatic ,
20
- PathArguments , ReturnType , Stmt , Type , Visibility ,
20
+ ReturnType , Stmt , Type , Visibility ,
21
21
} ;
22
22
23
23
static CALL_COUNT : AtomicUsize = AtomicUsize :: new ( 0 ) ;
@@ -86,14 +86,14 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
86
86
let f = parse_macro_input ! ( input as ItemFn ) ;
87
87
88
88
// check the function signature
89
- let valid_signature = f. constness . is_none ( )
89
+ let valid_signature = f. sig . constness . is_none ( )
90
90
&& f. vis == Visibility :: Inherited
91
- && f. abi . is_none ( )
92
- && f. decl . inputs . is_empty ( )
93
- && f. decl . generics . params . is_empty ( )
94
- && f. decl . generics . where_clause . is_none ( )
95
- && f. decl . variadic . is_none ( )
96
- && match f. decl . output {
91
+ && f. sig . abi . is_none ( )
92
+ && f. sig . inputs . is_empty ( )
93
+ && f. sig . generics . params . is_empty ( )
94
+ && f. sig . generics . where_clause . is_none ( )
95
+ && f. sig . variadic . is_none ( )
96
+ && match f. sig . output {
97
97
ReturnType :: Default => false ,
98
98
ReturnType :: Type ( _, ref ty) => match * * ty {
99
99
Type :: Never ( _) => true ,
@@ -118,7 +118,7 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
118
118
119
119
// XXX should we blacklist other attributes?
120
120
let attrs = f. attrs ;
121
- let unsafety = f. unsafety ;
121
+ let unsafety = f. sig . unsafety ;
122
122
let hash = random_ident ( ) ;
123
123
let ( statics, stmts) = match extract_static_muts ( f. block . stmts ) {
124
124
Err ( e) => return e. to_compile_error ( ) . into ( ) ,
@@ -282,7 +282,7 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
282
282
}
283
283
284
284
let fspan = f. span ( ) ;
285
- let ident = f. ident ;
285
+ let ident = f. sig . ident ;
286
286
287
287
enum Exception {
288
288
DefaultHandler ,
@@ -309,19 +309,19 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
309
309
let attrs = f. attrs ;
310
310
let block = f. block ;
311
311
let stmts = block. stmts ;
312
- let unsafety = f. unsafety ;
312
+ let unsafety = f. sig . unsafety ;
313
313
314
314
let hash = random_ident ( ) ;
315
315
match exn {
316
316
Exception :: DefaultHandler => {
317
- let valid_signature = f. constness . is_none ( )
317
+ let valid_signature = f. sig . constness . is_none ( )
318
318
&& f. vis == Visibility :: Inherited
319
- && f. abi . is_none ( )
320
- && f. decl . inputs . len ( ) == 1
321
- && f. decl . generics . params . is_empty ( )
322
- && f. decl . generics . where_clause . is_none ( )
323
- && f. decl . variadic . is_none ( )
324
- && match f. decl . output {
319
+ && f. sig . abi . is_none ( )
320
+ && f. sig . inputs . len ( ) == 1
321
+ && f. sig . generics . params . is_empty ( )
322
+ && f. sig . generics . where_clause . is_none ( )
323
+ && f. sig . variadic . is_none ( )
324
+ && match f. sig . output {
325
325
ReturnType :: Default => true ,
326
326
ReturnType :: Type ( _, ref ty) => match * * ty {
327
327
Type :: Tuple ( ref tuple) => tuple. elems . is_empty ( ) ,
@@ -339,8 +339,8 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
339
339
. into ( ) ;
340
340
}
341
341
342
- let arg = match f. decl . inputs [ 0 ] {
343
- FnArg :: Captured ( ref arg) => arg,
342
+ let arg = match f. sig . inputs [ 0 ] {
343
+ FnArg :: Typed ( ref arg) => arg,
344
344
_ => unreachable ! ( ) ,
345
345
} ;
346
346
@@ -360,21 +360,21 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
360
360
. into ( )
361
361
}
362
362
Exception :: HardFault => {
363
- let valid_signature = f. constness . is_none ( )
363
+ let valid_signature = f. sig . constness . is_none ( )
364
364
&& f. vis == Visibility :: Inherited
365
- && f. abi . is_none ( )
366
- && f. decl . inputs . len ( ) == 1
367
- && match f . decl . inputs [ 0 ] {
368
- FnArg :: Captured ( ref arg) => match arg. ty {
369
- Type :: Reference ( ref r) => r. lifetime . is_none ( ) && r. mutability . is_none ( ) ,
365
+ && f. sig . abi . is_none ( )
366
+ && f. sig . inputs . len ( ) == 1
367
+ && match & f . sig . inputs [ 0 ] {
368
+ FnArg :: Typed ( arg) => match arg. ty . as_ref ( ) {
369
+ Type :: Reference ( r) => r. lifetime . is_none ( ) && r. mutability . is_none ( ) ,
370
370
_ => false ,
371
371
} ,
372
372
_ => false ,
373
373
}
374
- && f. decl . generics . params . is_empty ( )
375
- && f. decl . generics . where_clause . is_none ( )
376
- && f. decl . variadic . is_none ( )
377
- && match f. decl . output {
374
+ && f. sig . generics . params . is_empty ( )
375
+ && f. sig . generics . where_clause . is_none ( )
376
+ && f. sig . variadic . is_none ( )
377
+ && match f. sig . output {
378
378
ReturnType :: Default => false ,
379
379
ReturnType :: Type ( _, ref ty) => match * * ty {
380
380
Type :: Never ( _) => true ,
@@ -391,8 +391,8 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
391
391
. into ( ) ;
392
392
}
393
393
394
- let arg = match f. decl . inputs [ 0 ] {
395
- FnArg :: Captured ( ref arg) => arg,
394
+ let arg = match f. sig . inputs [ 0 ] {
395
+ FnArg :: Typed ( ref arg) => arg,
396
396
_ => unreachable ! ( ) ,
397
397
} ;
398
398
@@ -413,14 +413,14 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
413
413
. into ( )
414
414
}
415
415
Exception :: Other => {
416
- let valid_signature = f. constness . is_none ( )
416
+ let valid_signature = f. sig . constness . is_none ( )
417
417
&& f. vis == Visibility :: Inherited
418
- && f. abi . is_none ( )
419
- && f. decl . inputs . is_empty ( )
420
- && f. decl . generics . params . is_empty ( )
421
- && f. decl . generics . where_clause . is_none ( )
422
- && f. decl . variadic . is_none ( )
423
- && match f. decl . output {
418
+ && f. sig . abi . is_none ( )
419
+ && f. sig . inputs . is_empty ( )
420
+ && f. sig . generics . params . is_empty ( )
421
+ && f. sig . generics . where_clause . is_none ( )
422
+ && f. sig . variadic . is_none ( )
423
+ && match f. sig . output {
424
424
ReturnType :: Default => true ,
425
425
ReturnType :: Type ( _, ref ty) => match * * ty {
426
426
Type :: Tuple ( ref tuple) => tuple. elems . is_empty ( ) ,
@@ -564,23 +564,23 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
564
564
}
565
565
566
566
let fspan = f. span ( ) ;
567
- let ident = f. ident ;
567
+ let ident = f. sig . ident ;
568
568
let ident_s = ident. to_string ( ) ;
569
569
570
570
// XXX should we blacklist other attributes?
571
571
let attrs = f. attrs ;
572
572
let block = f. block ;
573
573
let stmts = block. stmts ;
574
- let unsafety = f. unsafety ;
574
+ let unsafety = f. sig . unsafety ;
575
575
576
- let valid_signature = f. constness . is_none ( )
576
+ let valid_signature = f. sig . constness . is_none ( )
577
577
&& f. vis == Visibility :: Inherited
578
- && f. abi . is_none ( )
579
- && f. decl . inputs . is_empty ( )
580
- && f. decl . generics . params . is_empty ( )
581
- && f. decl . generics . where_clause . is_none ( )
582
- && f. decl . variadic . is_none ( )
583
- && match f. decl . output {
578
+ && f. sig . abi . is_none ( )
579
+ && f. sig . inputs . is_empty ( )
580
+ && f. sig . generics . params . is_empty ( )
581
+ && f. sig . generics . where_clause . is_none ( )
582
+ && f. sig . variadic . is_none ( )
583
+ && match f. sig . output {
584
584
ReturnType :: Default => true ,
585
585
ReturnType :: Type ( _, ref ty) => match * * ty {
586
586
Type :: Tuple ( ref tuple) => tuple. elems . is_empty ( ) ,
@@ -669,15 +669,15 @@ pub fn pre_init(args: TokenStream, input: TokenStream) -> TokenStream {
669
669
let f = parse_macro_input ! ( input as ItemFn ) ;
670
670
671
671
// check the function signature
672
- let valid_signature = f. constness . is_none ( )
672
+ let valid_signature = f. sig . constness . is_none ( )
673
673
&& f. vis == Visibility :: Inherited
674
- && f. unsafety . is_some ( )
675
- && f. abi . is_none ( )
676
- && f. decl . inputs . is_empty ( )
677
- && f. decl . generics . params . is_empty ( )
678
- && f. decl . generics . where_clause . is_none ( )
679
- && f. decl . variadic . is_none ( )
680
- && match f. decl . output {
674
+ && f. sig . unsafety . is_some ( )
675
+ && f. sig . abi . is_none ( )
676
+ && f. sig . inputs . is_empty ( )
677
+ && f. sig . generics . params . is_empty ( )
678
+ && f. sig . generics . where_clause . is_none ( )
679
+ && f. sig . variadic . is_none ( )
680
+ && match f. sig . output {
681
681
ReturnType :: Default => true ,
682
682
ReturnType :: Type ( _, ref ty) => match * * ty {
683
683
Type :: Tuple ( ref tuple) => tuple. elems . is_empty ( ) ,
@@ -702,7 +702,7 @@ pub fn pre_init(args: TokenStream, input: TokenStream) -> TokenStream {
702
702
703
703
// XXX should we blacklist other attributes?
704
704
let attrs = f. attrs ;
705
- let ident = f. ident ;
705
+ let ident = f. sig . ident ;
706
706
let block = f. block ;
707
707
708
708
quote ! (
@@ -799,9 +799,5 @@ fn extract_cfgs(attrs: Vec<Attribute>) -> (Vec<Attribute>, Vec<Attribute>) {
799
799
800
800
/// Returns `true` if `attr.path` matches `name`
801
801
fn eq ( attr : & Attribute , name : & str ) -> bool {
802
- attr. style == AttrStyle :: Outer && attr. path . segments . len ( ) == 1 && {
803
- let pair = attr. path . segments . first ( ) . unwrap ( ) ;
804
- let segment = pair. value ( ) ;
805
- segment. arguments == PathArguments :: None && segment. ident . to_string ( ) == name
806
- }
802
+ attr. style == AttrStyle :: Outer && attr. path . is_ident ( name)
807
803
}
0 commit comments