code review fixes
This commit is contained in:
parent
80d5478649
commit
968eb7ff5a
2 changed files with 19 additions and 21 deletions
|
@ -1519,6 +1519,10 @@ pub trait HasTyCtxt<'tcx>: HasDataLayout {
|
||||||
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx>;
|
fn tcx<'a>(&'a self) -> TyCtxt<'a, 'tcx, 'tcx>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait HasParamEnv<'tcx> {
|
||||||
|
fn param_env(&self) -> ty::ParamEnv<'tcx>;
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> HasDataLayout for TyCtxt<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> HasDataLayout for TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
fn data_layout(&self) -> &TargetDataLayout {
|
fn data_layout(&self) -> &TargetDataLayout {
|
||||||
&self.data_layout
|
&self.data_layout
|
||||||
|
@ -1531,6 +1535,12 @@ impl<'a, 'gcx, 'tcx> HasTyCtxt<'gcx> for TyCtxt<'a, 'gcx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'tcx, C> HasParamEnv<'tcx> for LayoutCx<'tcx, C> {
|
||||||
|
fn param_env(&self) -> ty::ParamEnv<'tcx> {
|
||||||
|
self.param_env
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'tcx, T: HasDataLayout> HasDataLayout for LayoutCx<'tcx, T> {
|
impl<'tcx, T: HasDataLayout> HasDataLayout for LayoutCx<'tcx, T> {
|
||||||
fn data_layout(&self) -> &TargetDataLayout {
|
fn data_layout(&self) -> &TargetDataLayout {
|
||||||
self.tcx.data_layout()
|
self.tcx.data_layout()
|
||||||
|
@ -1662,16 +1672,6 @@ impl ty::query::TyCtxtAt<'a, 'tcx, '_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait HasParamEnv<'tcx> {
|
|
||||||
fn param_env(&self) -> ty::ParamEnv<'tcx>;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx, C> HasParamEnv<'tcx> for LayoutCx<'tcx, C> {
|
|
||||||
fn param_env(&self) -> ty::ParamEnv<'tcx> {
|
|
||||||
self.param_env
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
|
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>>,
|
||||||
|
@ -1718,9 +1718,10 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
|
||||||
let tcx = cx.tcx();
|
let tcx = cx.tcx();
|
||||||
let discr_layout = |discr: &Scalar| -> C::TyLayout {
|
let discr_layout = |discr: &Scalar| -> C::TyLayout {
|
||||||
let layout = LayoutDetails::scalar(cx, discr.clone());
|
let layout = LayoutDetails::scalar(cx, discr.clone());
|
||||||
MaybeResult::from(Ok(
|
MaybeResult::from(Ok(TyLayout {
|
||||||
TyLayout {details: tcx.intern_layout(layout),ty: discr.value.to_ty(tcx)}
|
details: tcx.intern_layout(layout),
|
||||||
))
|
ty: discr.value.to_ty(tcx),
|
||||||
|
}))
|
||||||
};
|
};
|
||||||
|
|
||||||
cx.layout_of(match this.ty.sty {
|
cx.layout_of(match this.ty.sty {
|
||||||
|
@ -1754,12 +1755,10 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
|
||||||
} else {
|
} else {
|
||||||
tcx.mk_mut_ref(tcx.lifetimes.re_static, nil)
|
tcx.mk_mut_ref(tcx.lifetimes.re_static, nil)
|
||||||
};
|
};
|
||||||
return MaybeResult::from(
|
return MaybeResult::from(cx.layout_of(ptr_ty).to_result().map(|mut ptr_layout| {
|
||||||
cx.layout_of(ptr_ty).to_result().map(|mut ptr_layout| {
|
ptr_layout.ty = this.ty;
|
||||||
ptr_layout.ty = this.ty;
|
ptr_layout
|
||||||
ptr_layout
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
match tcx.struct_tail(pointee).sty {
|
match tcx.struct_tail(pointee).sty {
|
||||||
|
|
|
@ -89,6 +89,5 @@ pub trait HasCodegen<'tcx>:
|
||||||
Type = Self::Type,
|
Type = Self::Type,
|
||||||
Funclet = Self::Funclet,
|
Funclet = Self::Funclet,
|
||||||
DIScope = Self::DIScope,
|
DIScope = Self::DIScope,
|
||||||
>
|
>;
|
||||||
+ HasParamEnv<'tcx>;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue