Skip to content

Commit

Permalink
fix(macros): strip r# from command arguments, closes #4654
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Jul 12, 2022
1 parent c635a0d commit d4c9e73
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/unraw-command-key.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri-macros": patch
---

Remove raw identifier (`r#`) prefix from command arguments.
3 changes: 2 additions & 1 deletion core/tauri-macros/src/command/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -164,7 +165,7 @@ fn parse_arg(command: &Ident, arg: &FnArg, message: &Ident) -> syn::Result<Token

// we only support patterns that allow us to extract some sort of keyed identifier
let mut key = match &mut arg {
Pat::Ident(arg) => 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(),
Expand Down

0 comments on commit d4c9e73

Please sign in to comment.