diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 472747a71707..0473d3d02f8b 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -1666,6 +1666,8 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx> where C: LayoutOf> + HasTyCtxt<'tcx>, C::TyLayout: MaybeResult> { + type ParamEnv = ty::ParamEnv<'tcx>; + fn for_variant(this: TyLayout<'tcx>, cx: &C, variant_index: VariantIdx) -> TyLayout<'tcx> { let details = match this.variants { Variants::Single { index } if index == variant_index => this.details, @@ -1837,6 +1839,7 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx> this: TyLayout<'tcx>, cx: &C, offset: Size, + param_env: Self::ParamEnv, ) -> Option { match this.ty.sty { ty::RawPtr(mt) if offset.bytes() == 0 => { @@ -1850,7 +1853,7 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx> ty::Ref(_, ty, mt) if offset.bytes() == 0 => { let tcx = cx.tcx(); - let is_freeze = ty.is_freeze(tcx, ty::ParamEnv::reveal_all(), DUMMY_SP); + let is_freeze = ty.is_freeze(tcx, param_env, DUMMY_SP); let kind = match mt { hir::MutImmutable => if is_freeze { PointerKind::Frozen @@ -1929,7 +1932,7 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx> .and_then(|field| { if ptr_end <= field_start + field.size { // We found the right field, look inside it. - Self::pointee_info_at(field, cx, offset - field_start) + Self::pointee_info_at(field, cx, offset - field_start, param_env) } else { None } diff --git a/src/librustc_codegen_llvm/type_of.rs b/src/librustc_codegen_llvm/type_of.rs index e1c3c42add81..fd15fdf21764 100644 --- a/src/librustc_codegen_llvm/type_of.rs +++ b/src/librustc_codegen_llvm/type_of.rs @@ -386,7 +386,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> { return pointee; } - let result = Ty::pointee_info_at(*self, cx, offset); + let result = Ty::pointee_info_at(*self, cx, offset, ty::ParamEnv::reveal_all()); cx.pointee_infos.borrow_mut().insert((self.ty, offset), result); result diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index 74257cb3f648..1cdef7b00642 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -933,6 +933,8 @@ pub struct PointeeInfo { } pub trait TyLayoutMethods<'a, C: LayoutOf>: Sized { + type ParamEnv; + fn for_variant( this: TyLayout<'a, Self>, cx: &C, @@ -942,7 +944,8 @@ pub trait TyLayoutMethods<'a, C: LayoutOf>: Sized { fn pointee_info_at( this: TyLayout<'a, Self>, cx: &C, - offset: Size + offset: Size, + param_env: Self::ParamEnv, ) -> Option; }