From ac72800fb630738e2502569935ecdc83e3e78055 Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Tue, 12 Jul 2022 14:07:51 -0300 Subject: [PATCH] fix(macros): strip `r#` from command arguments, closes #4654 (#4657) --- .changes/unraw-command-key.md | 5 +++++ core/tauri-macros/src/command/wrapper.rs | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changes/unraw-command-key.md diff --git a/.changes/unraw-command-key.md b/.changes/unraw-command-key.md new file mode 100644 index 000000000..b62f3f205 --- /dev/null +++ b/.changes/unraw-command-key.md @@ -0,0 +1,5 @@ +--- +"tauri-macros": patch +--- + +Remove raw identifier (`r#`) prefix from command arguments. diff --git a/core/tauri-macros/src/command/wrapper.rs b/core/tauri-macros/src/command/wrapper.rs index 7b6452b46..eff5a4c48 100644 --- a/core/tauri-macros/src/command/wrapper.rs +++ b/core/tauri-macros/src/command/wrapper.rs @@ -6,6 +6,7 @@ use proc_macro::TokenStream; use proc_macro2::TokenStream as TokenStream2; use quote::{format_ident, quote}; use syn::{ + ext::IdentExt, parse::{Parse, ParseBuffer}, parse_macro_input, spanned::Spanned, @@ -164,7 +165,7 @@ fn parse_arg(command: &Ident, arg: &FnArg, message: &Ident) -> syn::Result arg.ident.to_string(), + Pat::Ident(arg) => arg.ident.unraw().to_string(), Pat::Wild(_) => "".into(), // we always convert to camelCase, so "_" will end up empty anyways Pat::Struct(s) => super::path_to_command(&mut s.path).ident.to_string(), Pat::TupleStruct(s) => super::path_to_command(&mut s.path).ident.to_string(),