stop using ParamEnv::reveal while handling MIR

This commit is contained in:
lcnr
2024-10-31 12:41:50 +01:00
parent 563c473e8d
commit 2cde638ac0
14 changed files with 100 additions and 60 deletions

View File

@@ -20,9 +20,7 @@ use smallvec::SmallVec;
use super::{BasicBlock, Const, Local, UserTypeProjection};
use crate::mir::coverage::CoverageKind;
use crate::ty::adjustment::PointerCoercion;
use crate::ty::{
self, GenericArgsRef, List, Region, Ty, TyCtxt, TypingMode, UserTypeAnnotationIndex,
};
use crate::ty::{self, GenericArgsRef, List, Region, Ty, TyCtxt, UserTypeAnnotationIndex};
/// Represents the "flavors" of MIR.
///
@@ -103,20 +101,10 @@ impl MirPhase {
}
}
pub fn typing_mode<'tcx>(&self) -> TypingMode<'tcx> {
match self {
// FIXME(#132279): the MIR is quite clearly inside of a body, so we
// should instead reveal opaques defined by that body here.
MirPhase::Built | MirPhase::Analysis(_) => TypingMode::non_body_analysis(),
MirPhase::Runtime(_) => TypingMode::PostAnalysis,
}
}
pub fn param_env<'tcx>(&self, tcx: TyCtxt<'tcx>, body_def_id: DefId) -> ty::ParamEnv<'tcx> {
match self.typing_mode() {
TypingMode::Coherence => unreachable!(),
TypingMode::Analysis { defining_opaque_types: _ } => tcx.param_env(body_def_id),
TypingMode::PostAnalysis => tcx.param_env_reveal_all_normalized(body_def_id),
match self {
MirPhase::Built | MirPhase::Analysis(_) => tcx.param_env(body_def_id),
MirPhase::Runtime(_) => tcx.param_env_reveal_all_normalized(body_def_id),
}
}
}