diff options
| author | lcnr <rust@lcnr.de> | 2024-10-31 12:22:05 +0100 |
|---|---|---|
| committer | lcnr <rust@lcnr.de> | 2024-10-31 12:43:22 +0100 |
| commit | aab149b58ca47b19a8e1e1673b9fbc367f984c59 (patch) | |
| tree | 8b5661e5134ca69d1386383ab79655d17da8ef30 /compiler/rustc_middle | |
| parent | 84295b917d9c29bb1d1cae9b24cf68d6b0d47d54 (diff) | |
| download | rust-aab149b58ca47b19a8e1e1673b9fbc367f984c59.tar.gz rust-aab149b58ca47b19a8e1e1673b9fbc367f984c59.zip | |
`ConstCx` stop using `ParamEnv::reveal`
Diffstat (limited to 'compiler/rustc_middle')
| -rw-r--r-- | compiler/rustc_middle/src/mir/syntax.rs | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index c610fac80f6..10b12ee6282 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -19,9 +19,10 @@ use smallvec::SmallVec; use super::{BasicBlock, Const, Local, UserTypeProjection}; use crate::mir::coverage::CoverageKind; -use crate::traits::Reveal; use crate::ty::adjustment::PointerCoercion; -use crate::ty::{self, GenericArgsRef, List, Region, Ty, UserTypeAnnotationIndex}; +use crate::ty::{ + self, GenericArgsRef, List, Region, Ty, TyCtxt, TypingMode, UserTypeAnnotationIndex, +}; /// Represents the "flavors" of MIR. /// @@ -102,10 +103,20 @@ impl MirPhase { } } - pub fn reveal(&self) -> Reveal { - match *self { - MirPhase::Built | MirPhase::Analysis(_) => Reveal::UserFacing, - MirPhase::Runtime(_) => Reveal::All, + 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), } } } |
