@@ -6,7 +6,6 @@ extern crate quote;
6
6
extern crate syn;
7
7
8
8
use proc_macro:: TokenStream ;
9
- use proc_macro2:: Span ;
10
9
use std:: { fs:: File , io:: Read , path:: Path } ;
11
10
use syn:: ext:: IdentExt ;
12
11
@@ -57,7 +56,7 @@ fn functions(input: TokenStream, dirs: &[&str]) -> TokenStream {
57
56
58
57
let mut tests = std:: collections:: HashSet :: < String > :: new ( ) ;
59
58
for f in & functions {
60
- let id = format ! ( "{}" , f. 0 . ident) ;
59
+ let id = format ! ( "{}" , f. 0 . sig . ident) ;
61
60
if id. starts_with ( "test_" ) {
62
61
tests. insert ( id) ;
63
62
}
@@ -66,7 +65,7 @@ fn functions(input: TokenStream, dirs: &[&str]) -> TokenStream {
66
65
67
66
functions. retain ( |& ( ref f, _) | {
68
67
if let syn:: Visibility :: Public ( _) = f. vis {
69
- if f. unsafety . is_some ( ) {
68
+ if f. sig . unsafety . is_some ( ) {
70
69
return true ;
71
70
}
72
71
}
@@ -79,17 +78,17 @@ fn functions(input: TokenStream, dirs: &[&str]) -> TokenStream {
79
78
let functions = functions
80
79
. iter ( )
81
80
. map ( |& ( ref f, path) | {
82
- let name = & f. ident ;
81
+ let name = & f. sig . ident ;
83
82
// println!("{}", name);
84
83
let mut arguments = Vec :: new ( ) ;
85
- for input in f. decl . inputs . iter ( ) {
84
+ for input in f. sig . inputs . iter ( ) {
86
85
let ty = match * input {
87
- syn:: FnArg :: Captured ( ref c) => & c. ty ,
86
+ syn:: FnArg :: Typed ( ref c) => & c. ty ,
88
87
_ => panic ! ( "invalid argument on {}" , name) ,
89
88
} ;
90
89
arguments. push ( to_type ( ty) ) ;
91
90
}
92
- let ret = match f. decl . output {
91
+ let ret = match f. sig . output {
93
92
syn:: ReturnType :: Default => quote ! { None } ,
94
93
syn:: ReturnType :: Type ( _, ref t) => {
95
94
let ty = to_type ( t) ;
@@ -265,7 +264,6 @@ fn extract_path_ident(path: &syn::Path) -> syn::Ident {
265
264
. segments
266
265
. first ( )
267
266
. expect ( "segment not found" )
268
- . value ( )
269
267
. arguments
270
268
{
271
269
syn:: PathArguments :: None => { }
@@ -274,7 +272,6 @@ fn extract_path_ident(path: &syn::Path) -> syn::Ident {
274
272
path. segments
275
273
. first ( )
276
274
. expect ( "segment not found" )
277
- . value ( )
278
275
. ident
279
276
. clone ( )
280
277
}
@@ -318,7 +315,7 @@ fn find_instrs(attrs: &[syn::Attribute]) -> Vec<String> {
318
315
// TODO: should probably just reuse `Invoc` from the `assert-instr-macro`
319
316
// crate.
320
317
impl syn:: parse:: Parse for AssertInstr {
321
- fn parse ( content : syn:: parse:: ParseStream ) -> syn:: parse :: Result < Self > {
318
+ fn parse ( content : syn:: parse:: ParseStream ) -> syn:: Result < Self > {
322
319
let input;
323
320
parenthesized ! ( input in content) ;
324
321
let _ = input. parse :: < syn:: Meta > ( ) ?;
@@ -352,9 +349,9 @@ fn find_instrs(attrs: &[syn::Attribute]) -> Vec<String> {
352
349
353
350
attrs
354
351
. iter ( )
355
- . filter ( |a| a. path == syn :: Ident :: new ( "cfg_attr" , Span :: call_site ( ) ) . into ( ) )
352
+ . filter ( |a| a. path . is_ident ( "cfg_attr" ) )
356
353
. filter_map ( |a| {
357
- syn:: parse2 :: < AssertInstr > ( a. tts . clone ( ) )
354
+ syn:: parse2 :: < AssertInstr > ( a. tokens . clone ( ) )
358
355
. ok ( )
359
356
. map ( |a| a. instr )
360
357
} )
@@ -365,9 +362,9 @@ fn find_target_feature(attrs: &[syn::Attribute]) -> Option<syn::Lit> {
365
362
attrs
366
363
. iter ( )
367
364
. flat_map ( |a| {
368
- if let Some ( a) = a. interpret_meta ( ) {
365
+ if let Ok ( a) = a. parse_meta ( ) {
369
366
if let syn:: Meta :: List ( i) = a {
370
- if i. ident == "target_feature" {
367
+ if i. path . is_ident ( "target_feature" ) {
371
368
return i. nested ;
372
369
}
373
370
}
@@ -376,10 +373,10 @@ fn find_target_feature(attrs: &[syn::Attribute]) -> Option<syn::Lit> {
376
373
} )
377
374
. filter_map ( |nested| match nested {
378
375
syn:: NestedMeta :: Meta ( m) => Some ( m) ,
379
- syn:: NestedMeta :: Literal ( _) => None ,
376
+ syn:: NestedMeta :: Lit ( _) => None ,
380
377
} )
381
378
. find_map ( |m| match m {
382
- syn:: Meta :: NameValue ( ref i) if i. ident == "enable" => Some ( i. clone ( ) . lit ) ,
379
+ syn:: Meta :: NameValue ( ref i) if i. path . is_ident ( "enable" ) => Some ( i. clone ( ) . lit ) ,
383
380
_ => None ,
384
381
} )
385
382
}
@@ -389,7 +386,7 @@ fn find_required_const(attrs: &[syn::Attribute]) -> Vec<usize> {
389
386
. iter ( )
390
387
. flat_map ( |a| {
391
388
if a. path . segments [ 0 ] . ident == "rustc_args_required_const" {
392
- syn:: parse :: < RustcArgsRequiredConst > ( a. tts . clone ( ) . into ( ) )
389
+ syn:: parse :: < RustcArgsRequiredConst > ( a. tokens . clone ( ) . into ( ) )
393
390
. unwrap ( )
394
391
. args
395
392
} else {
@@ -404,14 +401,13 @@ struct RustcArgsRequiredConst {
404
401
}
405
402
406
403
impl syn:: parse:: Parse for RustcArgsRequiredConst {
407
- #[ allow( clippy:: cast_possible_truncation) ]
408
- fn parse ( input : syn:: parse:: ParseStream ) -> syn:: parse:: Result < Self > {
404
+ fn parse ( input : syn:: parse:: ParseStream ) -> syn:: Result < Self > {
409
405
let content;
410
406
parenthesized ! ( content in input) ;
411
407
let list =
412
408
syn:: punctuated:: Punctuated :: < syn:: LitInt , Token ! [ , ] > :: parse_terminated ( & content) ?;
413
409
Ok ( Self {
414
- args : list. into_iter ( ) . map ( |a| a. value ( ) as usize ) . collect ( ) ,
410
+ args : list. into_iter ( ) . map ( |a| a. base10_parse :: < usize > ( ) ) . collect :: < syn :: Result < _ > > ( ) ? ,
415
411
} )
416
412
}
417
413
}
0 commit comments