From c17954ccbaefbcf755ad819f76eb3c9f83ef325f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Kr=C3=B6ger?= Date: Thu, 31 Dec 2020 15:38:10 +0100 Subject: [PATCH] Fix warnings for tasks that take mutable parameters #[task] pub async fn run(mut param: Param) {} warning: variable does not need to be mutable --- embassy-macros/src/lib.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/embassy-macros/src/lib.rs b/embassy-macros/src/lib.rs index c2e2d9e2..c46f114a 100644 --- a/embassy-macros/src/lib.rs +++ b/embassy-macros/src/lib.rs @@ -55,9 +55,9 @@ pub fn task(args: TokenStream, item: TokenStream) -> TokenStream { let mut arg_names: syn::punctuated::Punctuated = syn::punctuated::Punctuated::new(); - let args = &task_fn.sig.inputs; + let mut args = task_fn.sig.inputs.clone(); - for arg in args.iter() { + for arg in args.iter_mut() { match arg { syn::FnArg::Receiver(_) => { arg.span() @@ -66,8 +66,11 @@ pub fn task(args: TokenStream, item: TokenStream) -> TokenStream { .emit(); fail = true; } - syn::FnArg::Typed(t) => match t.pat.as_ref() { - syn::Pat::Ident(i) => arg_names.push(i.ident.clone()), + syn::FnArg::Typed(t) => match t.pat.as_mut() { + syn::Pat::Ident(i) => { + arg_names.push(i.ident.clone()); + i.mutability = None; + } _ => { arg.span() .unwrap()