Skip to content

Commit 9985f46

Browse files
committed
Clarify expand_struct_method_body.
Spotted by @RalfJung. This causes no behavioural changes.
1 parent c1a859b commit 9985f46

File tree

1 file changed

+3
-4
lines changed
  • compiler/rustc_builtin_macros/src/deriving/generic

1 file changed

+3
-4
lines changed

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,18 +1060,17 @@ impl<'a> MethodDef<'a> {
10601060
trait_.create_struct_field_access_fields(cx, selflike_args, struct_def, true);
10611061
mk_body(cx, selflike_fields)
10621062
} else {
1063-
// Neither packed nor copy. Need to use ref patterns.
1063+
// Packed and not copy. Need to use ref patterns.
10641064
let prefixes: Vec<_> =
10651065
(0..selflike_args.len()).map(|i| format!("__self_{}", i)).collect();
1066-
let addr_of = always_copy;
1066+
let addr_of = false;
10671067
let selflike_fields =
10681068
trait_.create_struct_pattern_fields(cx, struct_def, &prefixes, addr_of);
10691069
let mut body = mk_body(cx, selflike_fields);
10701070

10711071
let struct_path = cx.path(span, vec![Ident::new(kw::SelfUpper, type_ident.span)]);
1072-
let by_ref = ByRef::from(is_packed && !always_copy);
10731072
let patterns =
1074-
trait_.create_struct_patterns(cx, struct_path, struct_def, &prefixes, by_ref);
1073+
trait_.create_struct_patterns(cx, struct_path, struct_def, &prefixes, ByRef::Yes);
10751074

10761075
// Do the let-destructuring.
10771076
let mut stmts: Vec<_> = iter::zip(selflike_args, patterns)

0 commit comments

Comments
 (0)