Skip to content

Commit ac72800

Browse files
authored
fix(macros): strip r# from command arguments, closes #4654 (#4657)
1 parent c635a0d commit ac72800

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎.changes/unraw-command-key.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-macros": patch
3+
---
4+
5+
Remove raw identifier (`r#`) prefix from command arguments.

‎core/tauri-macros/src/command/wrapper.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use proc_macro::TokenStream;
66
use proc_macro2::TokenStream as TokenStream2;
77
use quote::{format_ident, quote};
88
use syn::{
9+
ext::IdentExt,
910
parse::{Parse, ParseBuffer},
1011
parse_macro_input,
1112
spanned::Spanned,
@@ -164,7 +165,7 @@ fn parse_arg(command: &Ident, arg: &FnArg, message: &Ident) -> syn::Result<Token
164165

165166
// we only support patterns that allow us to extract some sort of keyed identifier
166167
let mut key = match &mut arg {
167-
Pat::Ident(arg) => arg.ident.to_string(),
168+
Pat::Ident(arg) => arg.ident.unraw().to_string(),
168169
Pat::Wild(_) => "".into(), // we always convert to camelCase, so "_" will end up empty anyways
169170
Pat::Struct(s) => super::path_to_command(&mut s.path).ident.to_string(),
170171
Pat::TupleStruct(s) => super::path_to_command(&mut s.path).ident.to_string(),

0 commit comments

Comments
 (0)