Skip to content

Commit 6f4b539

Browse files
committed
introduce helper function
1 parent 1297cb7 commit 6f4b539

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

compiler/rustc_middle/src/ty/normalize_erasing_regions.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,32 @@ struct NormalizeAfterErasingRegionsFolder<'tcx> {
8888
param_env: ty::ParamEnv<'tcx>,
8989
}
9090

91+
impl<'tcx> NormalizeAfterErasingRegionsFolder<'tcx> {
92+
fn normalize_generic_arg_after_erasing_regions(
93+
&self,
94+
arg: ty::GenericArg<'tcx>,
95+
) -> ty::GenericArg<'tcx> {
96+
let arg = self.param_env.and(arg);
97+
self.tcx.normalize_generic_arg_after_erasing_regions(arg)
98+
}
99+
}
100+
91101
impl TypeFolder<'tcx> for NormalizeAfterErasingRegionsFolder<'tcx> {
92102
fn tcx(&self) -> TyCtxt<'tcx> {
93103
self.tcx
94104
}
95105

96106
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
97-
let arg = self.param_env.and(ty.into());
98-
self.tcx.normalize_generic_arg_after_erasing_regions(arg).expect_ty()
107+
self.normalize_generic_arg_after_erasing_regions(ty.into()).expect_ty()
99108
}
100109

101110
fn fold_const(&mut self, c: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
102-
let arg = self.param_env.and(c.into());
103-
self.tcx.normalize_generic_arg_after_erasing_regions(arg).expect_const()
111+
self.normalize_generic_arg_after_erasing_regions(c.into()).expect_const()
104112
}
105113

106114
#[inline]
107115
fn fold_mir_const(&mut self, c: mir::ConstantKind<'tcx>) -> mir::ConstantKind<'tcx> {
116+
// FIXME: This *probalby* needs canonicalization too!
108117
let arg = self.param_env.and(c);
109118
self.tcx.normalize_mir_const_after_erasing_regions(arg)
110119
}

0 commit comments

Comments
 (0)