remove remaining references to Reveal
This commit is contained in:
parent
319843d8cd
commit
a8c8ab1acd
34 changed files with 93 additions and 84 deletions
|
@ -258,7 +258,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
|||
// Normalization needed b/c known panics lint runs in
|
||||
// `mir_drops_elaborated_and_const_checked`, which happens before
|
||||
// optimized MIR. Only after optimizing the MIR can we guarantee
|
||||
// that the `RevealAll` pass has happened and that the body's consts
|
||||
// that the `PostAnalysisNormalize` pass has happened and that the body's consts
|
||||
// are normalized, so any call to resolve before that needs to be
|
||||
// manually normalized.
|
||||
let val = self.tcx.try_normalize_erasing_regions(self.typing_env, c.const_).ok()?;
|
||||
|
|
|
@ -163,7 +163,7 @@ declare_passes! {
|
|||
mod remove_unneeded_drops : RemoveUnneededDrops;
|
||||
mod remove_zsts : RemoveZsts;
|
||||
mod required_consts : RequiredConstsVisitor;
|
||||
mod reveal_all : RevealAll;
|
||||
mod post_analysis_normalize : PostAnalysisNormalize;
|
||||
mod sanity_check : SanityCheck;
|
||||
// This pass is public to allow external drivers to perform MIR cleanup
|
||||
pub mod simplify :
|
||||
|
@ -604,8 +604,8 @@ fn run_runtime_lowering_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
|||
// These next passes must be executed together.
|
||||
&add_call_guards::CriticalCallEdges,
|
||||
// Must be done before drop elaboration because we need to drop opaque types, too.
|
||||
&reveal_all::RevealAll,
|
||||
// Calling this after reveal_all ensures that we don't deal with opaque types.
|
||||
&post_analysis_normalize::PostAnalysisNormalize,
|
||||
// Calling this after `PostAnalysisNormalize` ensures that we don't deal with opaque types.
|
||||
&add_subtyping_projections::Subtyper,
|
||||
&elaborate_drops::ElaborateDrops,
|
||||
// This will remove extraneous landing pads which are no longer
|
||||
|
|
|
@ -1,26 +1,27 @@
|
|||
//! Normalizes MIR in RevealAll mode.
|
||||
//! Normalizes MIR in TypingMode::PostAnalysis mode, most notably revealing
|
||||
//! its opaques.
|
||||
|
||||
use rustc_middle::mir::visit::*;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
|
||||
pub(super) struct RevealAll;
|
||||
pub(super) struct PostAnalysisNormalize;
|
||||
|
||||
impl<'tcx> crate::MirPass<'tcx> for RevealAll {
|
||||
impl<'tcx> crate::MirPass<'tcx> for PostAnalysisNormalize {
|
||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
||||
// FIXME(#132279): This is used during the phase transition from analysis
|
||||
// to runtime, so we have to manually specify the correct typing mode.
|
||||
let typing_env = ty::TypingEnv::post_analysis(tcx, body.source.def_id());
|
||||
RevealAllVisitor { tcx, typing_env }.visit_body_preserves_cfg(body);
|
||||
PostAnalysisNormalizeVisitor { tcx, typing_env }.visit_body_preserves_cfg(body);
|
||||
}
|
||||
}
|
||||
|
||||
struct RevealAllVisitor<'tcx> {
|
||||
struct PostAnalysisNormalizeVisitor<'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
typing_env: ty::TypingEnv<'tcx>,
|
||||
}
|
||||
|
||||
impl<'tcx> MutVisitor<'tcx> for RevealAllVisitor<'tcx> {
|
||||
impl<'tcx> MutVisitor<'tcx> for PostAnalysisNormalizeVisitor<'tcx> {
|
||||
#[inline]
|
||||
fn tcx(&self) -> TyCtxt<'tcx> {
|
||||
self.tcx
|
||||
|
@ -38,7 +39,7 @@ impl<'tcx> MutVisitor<'tcx> for RevealAllVisitor<'tcx> {
|
|||
return;
|
||||
}
|
||||
// `OpaqueCast` projections are only needed if there are opaque types on which projections
|
||||
// are performed. After the `RevealAll` pass, all opaque types are replaced with their
|
||||
// are performed. After the `PostAnalysisNormalize` pass, all opaque types are replaced with their
|
||||
// hidden types, so we don't need these projections anymore.
|
||||
place.projection = self.tcx.mk_place_elems(
|
||||
&place
|
|
@ -2,7 +2,8 @@
|
|||
//!
|
||||
//! When the MIR is built, we check `needs_drop` before emitting a `Drop` for a place. This pass is
|
||||
//! useful because (unlike MIR building) it runs after type checking, so it can make use of
|
||||
//! `Reveal::All` to provide more precise type information.
|
||||
//! `TypingMode::PostAnalysis` to provide more precise type information, especially about opaque
|
||||
//! types.
|
||||
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
|
|
|
@ -141,7 +141,7 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceKind<'tcx>) -> Body<
|
|||
debug!("make_shim({:?}) = untransformed {:?}", instance, result);
|
||||
|
||||
// We don't validate MIR here because the shims may generate code that's
|
||||
// only valid in a reveal-all param-env. However, since we do initial
|
||||
// only valid in a `PostAnalysis` param-env. However, since we do initial
|
||||
// validation with the MirBuilt phase, which uses a user-facing param-env.
|
||||
// This causes validation errors when TAITs are involved.
|
||||
pm::run_passes_no_validate(
|
||||
|
|
|
@ -646,7 +646,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
|
|||
{
|
||||
self.fail(
|
||||
location,
|
||||
format!("explicit opaque type cast to `{ty}` after `RevealAll`"),
|
||||
format!("explicit opaque type cast to `{ty}` after `PostAnalysisNormalize`"),
|
||||
)
|
||||
}
|
||||
ProjectionElem::Index(index) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue