generic_const_exprs: yeet TypingEnv::from_param_env
This commit is contained in:
parent
ffd7a50314
commit
f74951fdf1
1 changed files with 11 additions and 6 deletions
|
@ -831,8 +831,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
|
||||||
|
|
||||||
// Normalize consts in writeback, because GCE doesn't normalize eagerly.
|
// Normalize consts in writeback, because GCE doesn't normalize eagerly.
|
||||||
if tcx.features().generic_const_exprs() {
|
if tcx.features().generic_const_exprs() {
|
||||||
value =
|
value = value.fold_with(&mut EagerlyNormalizeConsts::new(self.fcx));
|
||||||
value.fold_with(&mut EagerlyNormalizeConsts { tcx, param_env: self.fcx.param_env });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
value
|
value
|
||||||
|
@ -873,16 +872,22 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Resolver<'cx, 'tcx> {
|
||||||
|
|
||||||
struct EagerlyNormalizeConsts<'tcx> {
|
struct EagerlyNormalizeConsts<'tcx> {
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
typing_env: ty::TypingEnv<'tcx>,
|
||||||
}
|
}
|
||||||
|
impl<'tcx> EagerlyNormalizeConsts<'tcx> {
|
||||||
|
fn new(fcx: &FnCtxt<'_, 'tcx>) -> Self {
|
||||||
|
// FIXME(#132279, generic_const_exprs): Using `try_normalize_erasing_regions` here
|
||||||
|
// means we can't handle opaque types in their defining scope.
|
||||||
|
EagerlyNormalizeConsts { tcx: fcx.tcx, typing_env: fcx.typing_env(fcx.param_env) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EagerlyNormalizeConsts<'tcx> {
|
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EagerlyNormalizeConsts<'tcx> {
|
||||||
fn cx(&self) -> TyCtxt<'tcx> {
|
fn cx(&self) -> TyCtxt<'tcx> {
|
||||||
self.tcx
|
self.tcx
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
|
fn fold_const(&mut self, ct: ty::Const<'tcx>) -> ty::Const<'tcx> {
|
||||||
self.tcx
|
self.tcx.try_normalize_erasing_regions(self.typing_env, ct).unwrap_or(ct)
|
||||||
.try_normalize_erasing_regions(ty::TypingEnv::from_param_env(self.param_env), ct)
|
|
||||||
.unwrap_or(ct)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue