diff options
Diffstat (limited to 'library/stdarch/crates/assert-instr-macro/src/lib.rs')
| -rw-r--r-- | library/stdarch/crates/assert-instr-macro/src/lib.rs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/library/stdarch/crates/assert-instr-macro/src/lib.rs b/library/stdarch/crates/assert-instr-macro/src/lib.rs index 24b0e888cf6..5066d0bbcd4 100644 --- a/library/stdarch/crates/assert-instr-macro/src/lib.rs +++ b/library/stdarch/crates/assert-instr-macro/src/lib.rs @@ -39,8 +39,15 @@ pub fn assert_instr( (quote! { #[ignore] }).into() }; let name = &func.ident; + use quote::ToTokens; + let instr_str = instr + .clone() + .into_tokens() + .to_string() + .replace('.', "_") + .replace(|c: char| c.is_whitespace(), ""); let assert_name = syn::Ident::from( - &format!("assert_{}_{}", name.as_ref(), instr.as_ref())[..], + &format!("assert_{}_{}", name.as_ref(), instr_str)[..], ); let shim_name = syn::Ident::from(format!("{}_shim", name.as_ref())); let mut inputs = Vec::new(); @@ -72,7 +79,7 @@ pub fn assert_instr( attr.path .segments .first() - .unwrap() + .expect("attr.path.segments.first() failed") .value() .ident .as_ref() @@ -109,7 +116,8 @@ pub fn assert_instr( } }.into(); // why? necessary now to get tests to work? - let tts: TokenStream = tts.to_string().parse().unwrap(); + let tts: TokenStream = + tts.to_string().parse().expect("cannot parse tokenstream"); let tts: TokenStream = quote! { #item @@ -119,13 +127,13 @@ pub fn assert_instr( } struct Invoc { - instr: syn::Ident, + instr: syn::Expr, args: Vec<(syn::Ident, syn::Expr)>, } impl syn::synom::Synom for Invoc { named!(parse -> Self, map!(parens!(do_parse!( - instr: syn!(syn::Ident) >> + instr: syn!(syn::Expr) >> args: many0!(do_parse!( syn!(syn::token::Comma) >> name: syn!(syn::Ident) >> |
