introduce helper function
This commit is contained in:
parent
1297cb7f37
commit
6f4b539a62
@ -88,23 +88,32 @@ struct NormalizeAfterErasingRegionsFolder<'tcx> {
|
|||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'tcx> NormalizeAfterErasingRegionsFolder<'tcx> {
|
||||||
|
fn normalize_generic_arg_after_erasing_regions(
|
||||||
|
&self,
|
||||||
|
arg: ty::GenericArg<'tcx>,
|
||||||
|
) -> ty::GenericArg<'tcx> {
|
||||||
|
let arg = self.param_env.and(arg);
|
||||||
|
self.tcx.normalize_generic_arg_after_erasing_regions(arg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl TypeFolder<'tcx> for NormalizeAfterErasingRegionsFolder<'tcx> {
|
impl TypeFolder<'tcx> for NormalizeAfterErasingRegionsFolder<'tcx> {
|
||||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||||
self.tcx
|
self.tcx
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||||
let arg = self.param_env.and(ty.into());
|
self.normalize_generic_arg_after_erasing_regions(ty.into()).expect_ty()
|
||||||
self.tcx.normalize_generic_arg_after_erasing_regions(arg).expect_ty()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_const(&mut self, c: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
|
fn fold_const(&mut self, c: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
|
||||||
let arg = self.param_env.and(c.into());
|
self.normalize_generic_arg_after_erasing_regions(c.into()).expect_const()
|
||||||
self.tcx.normalize_generic_arg_after_erasing_regions(arg).expect_const()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn fold_mir_const(&mut self, c: mir::ConstantKind<'tcx>) -> mir::ConstantKind<'tcx> {
|
fn fold_mir_const(&mut self, c: mir::ConstantKind<'tcx>) -> mir::ConstantKind<'tcx> {
|
||||||
|
// FIXME: This *probalby* needs canonicalization too!
|
||||||
let arg = self.param_env.and(c);
|
let arg = self.param_env.and(c);
|
||||||
self.tcx.normalize_mir_const_after_erasing_regions(arg)
|
self.tcx.normalize_mir_const_after_erasing_regions(arg)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user