diff options
Diffstat (limited to 'library/stdarch/crates/assert-instr-macro/src')
| -rw-r--r-- | library/stdarch/crates/assert-instr-macro/src/lib.rs | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/library/stdarch/crates/assert-instr-macro/src/lib.rs b/library/stdarch/crates/assert-instr-macro/src/lib.rs index 7939fccb7ff..b6375154f5f 100644 --- a/library/stdarch/crates/assert-instr-macro/src/lib.rs +++ b/library/stdarch/crates/assert-instr-macro/src/lib.rs @@ -15,6 +15,7 @@ extern crate quote; extern crate syn; use proc_macro2::TokenStream; +use quote::ToTokens; #[proc_macro_attribute] pub fn assert_instr( @@ -38,7 +39,6 @@ pub fn assert_instr( let disable_assert_instr = std::env::var("STDSIMD_DISABLE_ASSERT_INSTR").is_ok(); - use quote::ToTokens; let instr_str = instr .replace('.', "_") .replace(|c: char| c.is_whitespace(), ""); @@ -62,15 +62,13 @@ pub fn assert_instr( syn::Pat::Ident(ref i) => &i.ident, _ => panic!("must have bare arguments"), }; - match invoc.args.iter().find(|a| *ident == a.0) { - Some(&(_, ref tts)) => { - input_vals.push(quote! { #tts }); - } - None => { - inputs.push(capture); - input_vals.push(quote! { #ident }); - } - }; + if let Some(&(_, ref tts)) = invoc.args.iter().find(|a| *ident == a.0) + { + input_vals.push(quote! { #tts }); + } else { + inputs.push(capture); + input_vals.push(quote! { #ident }); + } } let attrs = func @@ -133,8 +131,7 @@ pub fn assert_instr( stringify!(#shim_name), #instr); } - } - .into(); + }; // why? necessary now to get tests to work? let tts: TokenStream = tts.to_string().parse().expect("cannot parse tokenstream"); @@ -142,8 +139,7 @@ pub fn assert_instr( let tts: TokenStream = quote! { #item #tts - } - .into(); + }; tts.into() } @@ -167,7 +163,7 @@ impl syn::parse::Parse for Invoc { let expr = input.parse::<syn::Expr>()?; args.push((name, expr)); } - Ok(Invoc { instr, args }) + Ok(Self { instr, args }) } } |
