@@ -6,7 +6,6 @@ extern crate quote;
66extern crate syn;
77
88use proc_macro:: TokenStream ;
9- use proc_macro2:: Span ;
109use std:: { fs:: File , io:: Read , path:: Path } ;
1110use syn:: ext:: IdentExt ;
1211
@@ -57,7 +56,7 @@ fn functions(input: TokenStream, dirs: &[&str]) -> TokenStream {
5756
5857 let mut tests = std:: collections:: HashSet :: < String > :: new ( ) ;
5958 for f in & functions {
60- let id = format ! ( "{}" , f. 0 . ident) ;
59+ let id = format ! ( "{}" , f. 0 . sig . ident) ;
6160 if id. starts_with ( "test_" ) {
6261 tests. insert ( id) ;
6362 }
@@ -66,7 +65,7 @@ fn functions(input: TokenStream, dirs: &[&str]) -> TokenStream {
6665
6766 functions. retain ( |& ( ref f, _) | {
6867 if let syn:: Visibility :: Public ( _) = f. vis {
69- if f. unsafety . is_some ( ) {
68+ if f. sig . unsafety . is_some ( ) {
7069 return true ;
7170 }
7271 }
@@ -79,17 +78,17 @@ fn functions(input: TokenStream, dirs: &[&str]) -> TokenStream {
7978 let functions = functions
8079 . iter ( )
8180 . map ( |& ( ref f, path) | {
82- let name = & f. ident ;
81+ let name = & f. sig . ident ;
8382 // println!("{}", name);
8483 let mut arguments = Vec :: new ( ) ;
85- for input in f. decl . inputs . iter ( ) {
84+ for input in f. sig . inputs . iter ( ) {
8685 let ty = match * input {
87- syn:: FnArg :: Captured ( ref c) => & c. ty ,
86+ syn:: FnArg :: Typed ( ref c) => & c. ty ,
8887 _ => panic ! ( "invalid argument on {}" , name) ,
8988 } ;
9089 arguments. push ( to_type ( ty) ) ;
9190 }
92- let ret = match f. decl . output {
91+ let ret = match f. sig . output {
9392 syn:: ReturnType :: Default => quote ! { None } ,
9493 syn:: ReturnType :: Type ( _, ref t) => {
9594 let ty = to_type ( t) ;
@@ -265,7 +264,6 @@ fn extract_path_ident(path: &syn::Path) -> syn::Ident {
265264 . segments
266265 . first ( )
267266 . expect ( "segment not found" )
268- . value ( )
269267 . arguments
270268 {
271269 syn:: PathArguments :: None => { }
@@ -274,7 +272,6 @@ fn extract_path_ident(path: &syn::Path) -> syn::Ident {
274272 path. segments
275273 . first ( )
276274 . expect ( "segment not found" )
277- . value ( )
278275 . ident
279276 . clone ( )
280277}
@@ -318,7 +315,7 @@ fn find_instrs(attrs: &[syn::Attribute]) -> Vec<String> {
318315 // TODO: should probably just reuse `Invoc` from the `assert-instr-macro`
319316 // crate.
320317 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 > {
322319 let input;
323320 parenthesized ! ( input in content) ;
324321 let _ = input. parse :: < syn:: Meta > ( ) ?;
@@ -352,9 +349,9 @@ fn find_instrs(attrs: &[syn::Attribute]) -> Vec<String> {
352349
353350 attrs
354351 . iter ( )
355- . filter ( |a| a. path == syn :: Ident :: new ( "cfg_attr" , Span :: call_site ( ) ) . into ( ) )
352+ . filter ( |a| a. path . is_ident ( "cfg_attr" ) )
356353 . filter_map ( |a| {
357- syn:: parse2 :: < AssertInstr > ( a. tts . clone ( ) )
354+ syn:: parse2 :: < AssertInstr > ( a. tokens . clone ( ) )
358355 . ok ( )
359356 . map ( |a| a. instr )
360357 } )
@@ -365,9 +362,9 @@ fn find_target_feature(attrs: &[syn::Attribute]) -> Option<syn::Lit> {
365362 attrs
366363 . iter ( )
367364 . flat_map ( |a| {
368- if let Some ( a) = a. interpret_meta ( ) {
365+ if let Ok ( a) = a. parse_meta ( ) {
369366 if let syn:: Meta :: List ( i) = a {
370- if i. ident == "target_feature" {
367+ if i. path . is_ident ( "target_feature" ) {
371368 return i. nested ;
372369 }
373370 }
@@ -376,10 +373,10 @@ fn find_target_feature(attrs: &[syn::Attribute]) -> Option<syn::Lit> {
376373 } )
377374 . filter_map ( |nested| match nested {
378375 syn:: NestedMeta :: Meta ( m) => Some ( m) ,
379- syn:: NestedMeta :: Literal ( _) => None ,
376+ syn:: NestedMeta :: Lit ( _) => None ,
380377 } )
381378 . 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 ) ,
383380 _ => None ,
384381 } )
385382}
@@ -389,7 +386,7 @@ fn find_required_const(attrs: &[syn::Attribute]) -> Vec<usize> {
389386 . iter ( )
390387 . flat_map ( |a| {
391388 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 ( ) )
393390 . unwrap ( )
394391 . args
395392 } else {
@@ -404,14 +401,13 @@ struct RustcArgsRequiredConst {
404401}
405402
406403impl 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 > {
409405 let content;
410406 parenthesized ! ( content in input) ;
411407 let list =
412408 syn:: punctuated:: Punctuated :: < syn:: LitInt , Token ! [ , ] > :: parse_terminated ( & content) ?;
413409 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 < _ > > ( ) ? ,
415411 } )
416412 }
417413}
0 commit comments