From 15d7e008cb6412a5ba1a26f0c8090d5a0003cb81 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 6 Jan 2023 14:43:24 -0800 Subject: [PATCH] Touch up PR 227 --- src/expand.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/expand.rs b/src/expand.rs index 8e6cd28..2c06b69 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -362,11 +362,11 @@ fn transform_block(context: Context, sig: &mut Signature, block: &mut Block) { quote!(let #mutability #ident = #self_token;) } FnArg::Typed(arg) => { - // If there is a `#[cfg(..)]` attribute that selectively - // enables the parameter, forward it to the variable. + // If there is a #[cfg(...)] attribute that selectively enables + // the parameter, forward it to the variable. // - // This is currently not applied to the `self` parameter - let attrs = arg.attrs.iter(); + // This is currently not applied to the `self` parameter. + let attrs = arg.attrs.iter().filter(|attr| attr.path.is_ident("cfg")); if let Pat::Ident(PatIdent { ident, mutability, .. @@ -377,24 +377,24 @@ fn transform_block(context: Context, sig: &mut Signature, block: &mut Block) { let prefixed = Ident::new("__self", ident.span()); quote!(let #mutability #prefixed = #ident;) } else { - quote!( + quote! { #(#attrs)* let #mutability #ident = #ident; - ) + } } } else { let pat = &arg.pat; let ident = positional_arg(i, pat); if let Pat::Wild(_) = **pat { - quote!( + quote! { #(#attrs)* let #ident = #ident; - ) + } } else { - quote!( + quote! { #(#attrs)* let #pat = #ident; - ) + } } } }