about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-11-14 13:49:08 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2022-11-14 13:49:08 +1100
commit9985f4611b0d52e7faf6fc68adcdbced786871a9 (patch)
tree43684c733df1c9ab3b621d9d926846e57d4e8170 /compiler/rustc_builtin_macros/src
parentc1a859b25a95999ba276075bbd8e284ea675b41a (diff)
downloadrust-9985f4611b0d52e7faf6fc68adcdbced786871a9.tar.gz
rust-9985f4611b0d52e7faf6fc68adcdbced786871a9.zip
Clarify `expand_struct_method_body`.
Spotted by @RalfJung. This causes no behavioural changes.
Diffstat (limited to 'compiler/rustc_builtin_macros/src')
-rw-r--r--compiler/rustc_builtin_macros/src/deriving/generic/mod.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
index 16ee3aa89bb..7b3c73de6de 100644
--- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
+++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
@@ -1060,18 +1060,17 @@ impl<'a> MethodDef<'a> {
                 trait_.create_struct_field_access_fields(cx, selflike_args, struct_def, true);
             mk_body(cx, selflike_fields)
         } else {
-            // Neither packed nor copy. Need to use ref patterns.
+            // Packed and not copy. Need to use ref patterns.
             let prefixes: Vec<_> =
                 (0..selflike_args.len()).map(|i| format!("__self_{}", i)).collect();
-            let addr_of = always_copy;
+            let addr_of = false;
             let selflike_fields =
                 trait_.create_struct_pattern_fields(cx, struct_def, &prefixes, addr_of);
             let mut body = mk_body(cx, selflike_fields);
 
             let struct_path = cx.path(span, vec![Ident::new(kw::SelfUpper, type_ident.span)]);
-            let by_ref = ByRef::from(is_packed && !always_copy);
             let patterns =
-                trait_.create_struct_patterns(cx, struct_path, struct_def, &prefixes, by_ref);
+                trait_.create_struct_patterns(cx, struct_path, struct_def, &prefixes, ByRef::Yes);
 
             // Do the let-destructuring.
             let mut stmts: Vec<_> = iter::zip(selflike_args, patterns)