Skip to content

Commit

Permalink
Touch up PR 227
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jan 6, 2023
1 parent f0f9309 commit 15d7e00
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, ..
Expand All @@ -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;
)
}
}
}
}
Expand Down

0 comments on commit 15d7e00

Please sign in to comment.