Add param_env parameter to pointee_info_at.

An associated type ParamEnv has been added to TyLayoutMethods to
facilitate this.
This commit is contained in:
Daan de Graaf 2018-12-28 15:19:23 +01:00 committed by Saleem Jaffer
parent f1f9343c3d
commit d47ec57a4f
3 changed files with 10 additions and 4 deletions

View file

@ -1666,6 +1666,8 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
where C: LayoutOf<Ty = Ty<'tcx>> + HasTyCtxt<'tcx>,
C::TyLayout: MaybeResult<TyLayout<'tcx>>
{
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<PointeeInfo> {
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
}

View file

@ -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

View file

@ -933,6 +933,8 @@ pub struct PointeeInfo {
}
pub trait TyLayoutMethods<'a, C: LayoutOf<Ty = Self>>: Sized {
type ParamEnv;
fn for_variant(
this: TyLayout<'a, Self>,
cx: &C,
@ -942,7 +944,8 @@ pub trait TyLayoutMethods<'a, C: LayoutOf<Ty = Self>>: Sized {
fn pointee_info_at(
this: TyLayout<'a, Self>,
cx: &C,
offset: Size
offset: Size,
param_env: Self::ParamEnv,
) -> Option<PointeeInfo>;
}