about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2021-12-23 19:24:51 -0800
committerMichael Goulet <michael@errs.io>2021-12-23 19:24:51 -0800
commit1458687e05f4ae4cffd6d81b65ed27e2da60fe0b (patch)
tree7b7fc6fd949138c827217bbbb9d1130f6715153c
parent77497c74f9268ccf91d7b4c17f23bf07117d7433 (diff)
downloadrust-1458687e05f4ae4cffd6d81b65ed27e2da60fe0b.tar.gz
rust-1458687e05f4ae4cffd6d81b65ed27e2da60fe0b.zip
Erase regions before calculating layout for packed field capture
-rw-r--r--compiler/rustc_typeck/src/check/upvar.rs3
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs
index ffd7d29bbbb..abdbef6f10a 100644
--- a/compiler/rustc_typeck/src/check/upvar.rs
+++ b/compiler/rustc_typeck/src/check/upvar.rs
@@ -1639,7 +1639,8 @@ fn restrict_repr_packed_field_ref_capture<'tcx>(
         match p.kind {
             ProjectionKind::Field(..) => match ty.kind() {
                 ty::Adt(def, _) if def.repr.packed() => {
-                    match tcx.layout_of(param_env.and(p.ty)) {
+                    // We erase regions here because they cannot be hashed
+                    match tcx.layout_of(param_env.and(tcx.erase_regions(p.ty))) {
                         Ok(layout) if layout.align.abi.bytes() == 1 => {
                             // if the alignment is 1, the type can't be further
                             // disaligned.