diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs index 0482e8b895b..428a866c1fe 100644 --- a/compiler/rustc_typeck/src/check/upvar.rs +++ b/compiler/rustc_typeck/src/check/upvar.rs @@ -1648,7 +1648,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.