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:
parent
f1f9343c3d
commit
d47ec57a4f
3 changed files with 10 additions and 4 deletions
|
@ -1666,6 +1666,8 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
|
||||||
where C: LayoutOf<Ty = Ty<'tcx>> + HasTyCtxt<'tcx>,
|
where C: LayoutOf<Ty = Ty<'tcx>> + HasTyCtxt<'tcx>,
|
||||||
C::TyLayout: MaybeResult<TyLayout<'tcx>>
|
C::TyLayout: MaybeResult<TyLayout<'tcx>>
|
||||||
{
|
{
|
||||||
|
type ParamEnv = ty::ParamEnv<'tcx>;
|
||||||
|
|
||||||
fn for_variant(this: TyLayout<'tcx>, cx: &C, variant_index: VariantIdx) -> TyLayout<'tcx> {
|
fn for_variant(this: TyLayout<'tcx>, cx: &C, variant_index: VariantIdx) -> TyLayout<'tcx> {
|
||||||
let details = match this.variants {
|
let details = match this.variants {
|
||||||
Variants::Single { index } if index == variant_index => this.details,
|
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>,
|
this: TyLayout<'tcx>,
|
||||||
cx: &C,
|
cx: &C,
|
||||||
offset: Size,
|
offset: Size,
|
||||||
|
param_env: Self::ParamEnv,
|
||||||
) -> Option<PointeeInfo> {
|
) -> Option<PointeeInfo> {
|
||||||
match this.ty.sty {
|
match this.ty.sty {
|
||||||
ty::RawPtr(mt) if offset.bytes() == 0 => {
|
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 => {
|
ty::Ref(_, ty, mt) if offset.bytes() == 0 => {
|
||||||
let tcx = cx.tcx();
|
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 {
|
let kind = match mt {
|
||||||
hir::MutImmutable => if is_freeze {
|
hir::MutImmutable => if is_freeze {
|
||||||
PointerKind::Frozen
|
PointerKind::Frozen
|
||||||
|
@ -1929,7 +1932,7 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
|
||||||
.and_then(|field| {
|
.and_then(|field| {
|
||||||
if ptr_end <= field_start + field.size {
|
if ptr_end <= field_start + field.size {
|
||||||
// We found the right field, look inside it.
|
// 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 {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -386,7 +386,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
|
||||||
return pointee;
|
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);
|
cx.pointee_infos.borrow_mut().insert((self.ty, offset), result);
|
||||||
result
|
result
|
||||||
|
|
|
@ -933,6 +933,8 @@ pub struct PointeeInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait TyLayoutMethods<'a, C: LayoutOf<Ty = Self>>: Sized {
|
pub trait TyLayoutMethods<'a, C: LayoutOf<Ty = Self>>: Sized {
|
||||||
|
type ParamEnv;
|
||||||
|
|
||||||
fn for_variant(
|
fn for_variant(
|
||||||
this: TyLayout<'a, Self>,
|
this: TyLayout<'a, Self>,
|
||||||
cx: &C,
|
cx: &C,
|
||||||
|
@ -942,7 +944,8 @@ pub trait TyLayoutMethods<'a, C: LayoutOf<Ty = Self>>: Sized {
|
||||||
fn pointee_info_at(
|
fn pointee_info_at(
|
||||||
this: TyLayout<'a, Self>,
|
this: TyLayout<'a, Self>,
|
||||||
cx: &C,
|
cx: &C,
|
||||||
offset: Size
|
offset: Size,
|
||||||
|
param_env: Self::ParamEnv,
|
||||||
) -> Option<PointeeInfo>;
|
) -> Option<PointeeInfo>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue