Skip to content

Commit ba93025

Browse files
committed
Bypass Sync bound implied by non-existent drop of reference
1 parent 70bf4b0 commit ba93025

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/expand.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,16 @@ fn transform_sig(
297297
}) => {}
298298
FnArg::Receiver(arg) => arg.mutability = None,
299299
FnArg::Typed(arg) => {
300-
if let Pat::Ident(ident) = &mut *arg.pat {
301-
ident.by_ref = None;
302-
ident.mutability = None;
303-
} else {
300+
let type_is_reference = match *arg.ty {
301+
Type::Reference(_) => true,
302+
_ => false,
303+
};
304+
if let Pat::Ident(pat) = &mut *arg.pat {
305+
if pat.ident == "self" || !type_is_reference {
306+
pat.by_ref = None;
307+
pat.mutability = None;
308+
}
309+
} else if !type_is_reference {
304310
let positional = positional_arg(i, &arg.pat);
305311
let m = mut_pat(&mut arg.pat);
306312
arg.pat = parse_quote!(#m #positional);
@@ -376,12 +382,16 @@ fn transform_block(context: Context, sig: &mut Signature, block: &mut Block) {
376382
self_span = Some(ident.span());
377383
let prefixed = Ident::new("__self", ident.span());
378384
quote!(let #mutability #prefixed = #ident;)
385+
} else if let Type::Reference(_) = *arg.ty {
386+
quote!()
379387
} else {
380388
quote! {
381389
#(#attrs)*
382390
let #mutability #ident = #ident;
383391
}
384392
}
393+
} else if let Type::Reference(_) = *arg.ty {
394+
quote!()
385395
} else {
386396
let pat = &arg.pat;
387397
let ident = positional_arg(i, pat);

0 commit comments

Comments
 (0)