diff options
| author | Jubilee <workingjubilee@gmail.com> | 2024-10-31 17:50:43 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-31 17:50:43 -0700 |
| commit | c57b351d38102ca83190deb03cf956a2fa488ff2 (patch) | |
| tree | f8051219dd67caf9fe403dcaac7befa12c49f926 /compiler/rustc_middle/src | |
| parent | 6da4221d96ce6c3b5319e39e6687b3cfe9649895 (diff) | |
| parent | dc750665ae84cdedfbae4d5b3c69f4d20faa14dc (diff) | |
| download | rust-c57b351d38102ca83190deb03cf956a2fa488ff2.tar.gz rust-c57b351d38102ca83190deb03cf956a2fa488ff2.zip | |
Rollup merge of #132403 - lcnr:typing-mode, r=compiler-errors
continue `TypingMode` refactor There are still quite a few places which (indirectly) rely on the `Reveal` of a `ParamEnv`, but we're slowly getting there r? `@compiler-errors`
Diffstat (limited to 'compiler/rustc_middle/src')
| -rw-r--r-- | compiler/rustc_middle/src/mir/mod.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/mir/syntax.rs | 11 |
2 files changed, 15 insertions, 7 deletions
diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index cd148aef29b..978abab8b08 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -39,7 +39,7 @@ use crate::ty::fold::{FallibleTypeFolder, TypeFoldable}; use crate::ty::print::{FmtPrinter, Printer, pretty_print_const, with_no_trimmed_paths}; use crate::ty::visit::TypeVisitableExt; use crate::ty::{ - self, AdtDef, GenericArg, GenericArgsRef, Instance, InstanceKind, List, Ty, TyCtxt, + self, AdtDef, GenericArg, GenericArgsRef, Instance, InstanceKind, List, Ty, TyCtxt, TypingMode, UserTypeAnnotationIndex, }; @@ -452,6 +452,15 @@ impl<'tcx> Body<'tcx> { self.basic_blocks.as_mut() } + pub fn typing_mode(&self, _tcx: TyCtxt<'tcx>) -> TypingMode<'tcx> { + match self.phase { + // 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, + } + } + #[inline] pub fn local_kind(&self, local: Local) -> LocalKind { let index = local.as_usize(); diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index c610fac80f6..85beb6ef1e7 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -19,9 +19,8 @@ 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, UserTypeAnnotationIndex}; /// Represents the "flavors" of MIR. /// @@ -102,10 +101,10 @@ impl MirPhase { } } - pub fn reveal(&self) -> Reveal { - match *self { - MirPhase::Built | MirPhase::Analysis(_) => Reveal::UserFacing, - MirPhase::Runtime(_) => Reveal::All, + pub fn param_env<'tcx>(&self, tcx: TyCtxt<'tcx>, body_def_id: DefId) -> ty::ParamEnv<'tcx> { + match self { + MirPhase::Built | MirPhase::Analysis(_) => tcx.param_env(body_def_id), + MirPhase::Runtime(_) => tcx.param_env_reveal_all_normalized(body_def_id), } } } |
