remove remaining references to Reveal

This commit is contained in:
lcnr 2024-11-20 11:59:52 +01:00
parent 319843d8cd
commit a8c8ab1acd
34 changed files with 93 additions and 84 deletions

View File

@ -80,7 +80,7 @@ pub(crate) fn get_function_sig<'tcx>(
clif_sig_from_fn_abi(
tcx,
default_call_conv,
&RevealAllLayoutCx(tcx).fn_abi_of_instance(inst, ty::List::empty()),
&FullyMonomorphizedLayoutCx(tcx).fn_abi_of_instance(inst, ty::List::empty()),
)
}
@ -438,9 +438,9 @@ pub(crate) fn codegen_terminator_call<'tcx>(
extra_args.iter().map(|op_arg| fx.monomorphize(op_arg.node.ty(fx.mir, fx.tcx))),
);
let fn_abi = if let Some(instance) = instance {
RevealAllLayoutCx(fx.tcx).fn_abi_of_instance(instance, extra_args)
FullyMonomorphizedLayoutCx(fx.tcx).fn_abi_of_instance(instance, extra_args)
} else {
RevealAllLayoutCx(fx.tcx).fn_abi_of_fn_ptr(fn_sig, extra_args)
FullyMonomorphizedLayoutCx(fx.tcx).fn_abi_of_fn_ptr(fn_sig, extra_args)
};
let is_cold = if fn_sig.abi() == ExternAbi::RustCold {
@ -721,8 +721,8 @@ pub(crate) fn codegen_drop<'tcx>(
def: ty::InstanceKind::Virtual(drop_instance.def_id(), 0),
args: drop_instance.args,
};
let fn_abi =
RevealAllLayoutCx(fx.tcx).fn_abi_of_instance(virtual_drop, ty::List::empty());
let fn_abi = FullyMonomorphizedLayoutCx(fx.tcx)
.fn_abi_of_instance(virtual_drop, ty::List::empty());
let sig = clif_sig_from_fn_abi(fx.tcx, fx.target_config.default_call_conv, &fn_abi);
let sig = fx.bcx.import_signature(sig);
@ -764,8 +764,8 @@ pub(crate) fn codegen_drop<'tcx>(
def: ty::InstanceKind::Virtual(drop_instance.def_id(), 0),
args: drop_instance.args,
};
let fn_abi =
RevealAllLayoutCx(fx.tcx).fn_abi_of_instance(virtual_drop, ty::List::empty());
let fn_abi = FullyMonomorphizedLayoutCx(fx.tcx)
.fn_abi_of_instance(virtual_drop, ty::List::empty());
let sig = clif_sig_from_fn_abi(fx.tcx, fx.target_config.default_call_conv, &fn_abi);
let sig = fx.bcx.import_signature(sig);
@ -774,8 +774,8 @@ pub(crate) fn codegen_drop<'tcx>(
_ => {
assert!(!matches!(drop_instance.def, InstanceKind::Virtual(_, _)));
let fn_abi =
RevealAllLayoutCx(fx.tcx).fn_abi_of_instance(drop_instance, ty::List::empty());
let fn_abi = FullyMonomorphizedLayoutCx(fx.tcx)
.fn_abi_of_instance(drop_instance, ty::List::empty());
let arg_value = drop_place.place_ref(
fx,

View File

@ -103,7 +103,7 @@ pub(crate) fn codegen_fn<'tcx>(
let block_map: IndexVec<BasicBlock, Block> =
(0..mir.basic_blocks.len()).map(|_| bcx.create_block()).collect();
let fn_abi = RevealAllLayoutCx(tcx).fn_abi_of_instance(instance, ty::List::empty());
let fn_abi = FullyMonomorphizedLayoutCx(tcx).fn_abi_of_instance(instance, ty::List::empty());
// Make FunctionCx
let target_config = module.target_config();

View File

@ -311,7 +311,7 @@ pub(crate) struct FunctionCx<'m, 'clif, 'tcx: 'm> {
impl<'tcx> LayoutOfHelpers<'tcx> for FunctionCx<'_, '_, 'tcx> {
#[inline]
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
RevealAllLayoutCx(self.tcx).handle_layout_err(err, span, ty)
FullyMonomorphizedLayoutCx(self.tcx).handle_layout_err(err, span, ty)
}
}
@ -323,7 +323,7 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for FunctionCx<'_, '_, 'tcx> {
span: Span,
fn_abi_request: FnAbiRequest<'tcx>,
) -> ! {
RevealAllLayoutCx(self.tcx).handle_fn_abi_err(err, span, fn_abi_request)
FullyMonomorphizedLayoutCx(self.tcx).handle_fn_abi_err(err, span, fn_abi_request)
}
}
@ -443,9 +443,9 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
}
}
pub(crate) struct RevealAllLayoutCx<'tcx>(pub(crate) TyCtxt<'tcx>);
pub(crate) struct FullyMonomorphizedLayoutCx<'tcx>(pub(crate) TyCtxt<'tcx>);
impl<'tcx> LayoutOfHelpers<'tcx> for RevealAllLayoutCx<'tcx> {
impl<'tcx> LayoutOfHelpers<'tcx> for FullyMonomorphizedLayoutCx<'tcx> {
#[inline]
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err {
@ -459,7 +459,7 @@ impl<'tcx> LayoutOfHelpers<'tcx> for RevealAllLayoutCx<'tcx> {
}
}
impl<'tcx> FnAbiOfHelpers<'tcx> for RevealAllLayoutCx<'tcx> {
impl<'tcx> FnAbiOfHelpers<'tcx> for FullyMonomorphizedLayoutCx<'tcx> {
#[inline]
fn handle_fn_abi_err(
&self,
@ -485,25 +485,25 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for RevealAllLayoutCx<'tcx> {
}
}
impl<'tcx> layout::HasTyCtxt<'tcx> for RevealAllLayoutCx<'tcx> {
impl<'tcx> layout::HasTyCtxt<'tcx> for FullyMonomorphizedLayoutCx<'tcx> {
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
self.0
}
}
impl<'tcx> rustc_abi::HasDataLayout for RevealAllLayoutCx<'tcx> {
impl<'tcx> rustc_abi::HasDataLayout for FullyMonomorphizedLayoutCx<'tcx> {
fn data_layout(&self) -> &rustc_abi::TargetDataLayout {
&self.0.data_layout
}
}
impl<'tcx> layout::HasTypingEnv<'tcx> for RevealAllLayoutCx<'tcx> {
impl<'tcx> layout::HasTypingEnv<'tcx> for FullyMonomorphizedLayoutCx<'tcx> {
fn typing_env(&self) -> ty::TypingEnv<'tcx> {
ty::TypingEnv::fully_monomorphized()
}
}
impl<'tcx> HasTargetSpec for RevealAllLayoutCx<'tcx> {
impl<'tcx> HasTargetSpec for FullyMonomorphizedLayoutCx<'tcx> {
fn target_spec(&self) -> &Target {
&self.0.sess.target
}

View File

@ -6,7 +6,7 @@ use rustc_data_structures::fx::FxHashMap;
use rustc_middle::ty::layout::LayoutOf;
use rustc_middle::ty::{self, Ty, TyCtxt};
use crate::{DebugContext, RevealAllLayoutCx, has_ptr_meta};
use crate::{DebugContext, FullyMonomorphizedLayoutCx, has_ptr_meta};
#[derive(Default)]
pub(crate) struct TypeDebugContext<'tcx> {
@ -85,7 +85,7 @@ impl DebugContext {
type_entry.set(gimli::DW_AT_encoding, AttributeValue::Encoding(encoding));
type_entry.set(
gimli::DW_AT_byte_size,
AttributeValue::Udata(RevealAllLayoutCx(tcx).layout_of(ty).size.bytes()),
AttributeValue::Udata(FullyMonomorphizedLayoutCx(tcx).layout_of(ty).size.bytes()),
);
type_id
@ -159,7 +159,7 @@ impl DebugContext {
return_if_type_created_in_meantime!(type_dbg, tuple_type);
let name = type_names::compute_debuginfo_type_name(tcx, tuple_type, false);
let layout = RevealAllLayoutCx(tcx).layout_of(tuple_type);
let layout = FullyMonomorphizedLayoutCx(tcx).layout_of(tuple_type);
let tuple_type_id =
self.dwarf.unit.add(self.dwarf.unit.root(), gimli::DW_TAG_structure_type);
@ -178,7 +178,9 @@ impl DebugContext {
member_entry.set(gimli::DW_AT_type, AttributeValue::UnitRef(dw_ty));
member_entry.set(
gimli::DW_AT_alignment,
AttributeValue::Udata(RevealAllLayoutCx(tcx).layout_of(ty).align.pref.bytes()),
AttributeValue::Udata(
FullyMonomorphizedLayoutCx(tcx).layout_of(ty).align.pref.bytes(),
),
);
member_entry.set(
gimli::DW_AT_data_member_location,
@ -198,7 +200,11 @@ impl DebugContext {
self.debug_type(
tcx,
type_dbg,
Ty::new_array(tcx, tcx.types.u8, RevealAllLayoutCx(tcx).layout_of(ty).size.bytes()),
Ty::new_array(
tcx,
tcx.types.u8,
FullyMonomorphizedLayoutCx(tcx).layout_of(ty).size.bytes(),
),
)
}
}

View File

@ -42,7 +42,7 @@ pub(crate) fn codegen_global_asm_item(tcx: TyCtxt<'_>, global_asm: &mut String,
tcx,
op_sp,
const_value,
RevealAllLayoutCx(tcx).layout_of(ty),
FullyMonomorphizedLayoutCx(tcx).layout_of(ty),
);
global_asm.push_str(&string);
}

View File

@ -238,7 +238,7 @@ pub(crate) fn codegen_naked_asm<'tcx>(
tcx,
span,
const_value,
RevealAllLayoutCx(tcx).layout_of(cv.ty()),
FullyMonomorphizedLayoutCx(tcx).layout_of(cv.ty()),
);
CInlineAsmOperand::Const { value }
}

View File

@ -629,8 +629,7 @@ impl<'tcx> Body<'tcx> {
) -> Option<(u128, &'a SwitchTargets)> {
// There are two places here we need to evaluate a constant.
let eval_mono_const = |constant: &ConstOperand<'tcx>| {
// FIXME(#132279): what is this, why are we using an empty environment with
// `RevealAll` here.
// FIXME(#132279): what is this, why are we using an empty environment here.
let typing_env = ty::TypingEnv::fully_monomorphized();
let mono_literal = instance.instantiate_mir_and_normalize_erasing_regions(
tcx,

View File

@ -1373,9 +1373,10 @@ rustc_queries! {
/// Gets the ParameterEnvironment for a given item; this environment
/// will be in "user-facing" mode, meaning that it is suitable for
/// type-checking etc, and it does not normalize specializable
/// associated types. This is almost always what you want,
/// unless you are doing MIR optimizations, in which case you
/// might want to use `reveal_all()` method to change modes.
/// associated types.
///
/// You should pretty much only use this if an `infcx` is available,
/// otherwise use a `TypingEnv`.
query param_env(def_id: DefId) -> ty::ParamEnv<'tcx> {
desc { |tcx| "computing normalized predicates of `{}`", tcx.def_path_str(def_id) }
feedable
@ -1471,7 +1472,7 @@ rustc_queries! {
}
/// Computes the layout of a type. Note that this implicitly
/// executes in "reveal all" mode, and will normalize the input type.
/// executes in `TypingMode::PostAnalysis`, and will normalize the input type.
query layout_of(
key: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>
) -> Result<ty::layout::TyAndLayout<'tcx>, &'tcx ty::layout::LayoutError<'tcx>> {

View File

@ -504,8 +504,8 @@ impl<'tcx> Instance<'tcx> {
/// ```
///
/// trying to resolve `Debug::fmt` applied to `T` will yield `Ok(None)`, because we do not
/// know what code ought to run. (Note that this setting is also affected by the
/// `RevealMode` in the parameter environment.)
/// know what code ought to run. This setting is also affected by the current `TypingMode`
/// of the environment.
///
/// Presuming that coherence and type-check have succeeded, if this method is invoked
/// in a monomorphic context (i.e., like during codegen), then it is guaranteed to return

View File

@ -682,14 +682,14 @@ pub trait LayoutOfHelpers<'tcx>: HasDataLayout + HasTyCtxt<'tcx> + HasTypingEnv<
/// Blanket extension trait for contexts that can compute layouts of types.
pub trait LayoutOf<'tcx>: LayoutOfHelpers<'tcx> {
/// Computes the layout of a type. Note that this implicitly
/// executes in "reveal all" mode, and will normalize the input type.
/// executes in `TypingMode::PostAnalysis`, and will normalize the input type.
#[inline]
fn layout_of(&self, ty: Ty<'tcx>) -> Self::LayoutOfResult {
self.spanned_layout_of(ty, DUMMY_SP)
}
/// Computes the layout of a type, at `span`. Note that this implicitly
/// executes in "reveal all" mode, and will normalize the input type.
/// executes in `TypingMode::PostAnalysis`, and will normalize the input type.
// FIXME(eddyb) avoid passing information like this, and instead add more
// `TyCtxt::at`-like APIs to be able to do e.g. `cx.at(span).layout_of(ty)`.
#[inline]

View File

@ -423,8 +423,8 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn async_drop_glue_morphology(self, did: DefId) -> AsyncDropGlueMorphology {
let ty: Ty<'tcx> = self.type_of(did).instantiate_identity();
// Async drop glue morphology is an internal detail, so reveal_all probably
// should be fine
// Async drop glue morphology is an internal detail, so
// using `TypingMode::PostAnalysis` probably should be fine.
let typing_env = ty::TypingEnv::fully_monomorphized();
if ty.needs_async_drop(self, typing_env) {
AsyncDropGlueMorphology::Custom

View File

@ -80,11 +80,11 @@ impl<'tcx> ConstToPat<'tcx> {
let pat_from_kind = |kind| Box::new(Pat { span: self.span, ty, kind });
// It's not *technically* correct to be revealing opaque types here as borrowcheck has
// not run yet. However, CTFE itself uses `Reveal::All` unconditionally even during
// typeck and not doing so has a lot of (undesirable) fallout (#101478, #119821). As a
// result we always use a revealed env when resolving the instance to evaluate.
// not run yet. However, CTFE itself uses `TypingMode::PostAnalysis` unconditionally even
// during typeck and not doing so has a lot of (undesirable) fallout (#101478, #119821).
// As a result we always use a revealed env when resolving the instance to evaluate.
//
// FIXME: `const_eval_resolve_for_typeck` should probably just set the env to `Reveal::All`
// FIXME: `const_eval_resolve_for_typeck` should probably just modify the env itself
// instead of having this logic here
let typing_env =
self.tcx.erase_regions(self.typing_env).with_post_analysis_normalized(self.tcx);

View File

@ -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()?;

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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(

View File

@ -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) => {

View File

@ -1556,7 +1556,7 @@ fn create_mono_items_for_default_impls<'tcx>(
// Unlike 'lazy' monomorphization that begins by collecting items transitively
// called by `main` or other global items, when eagerly monomorphizing impl
// items, we never actually check that the predicates of this impl are satisfied
// in a empty reveal-all param env (i.e. with no assumptions).
// in a empty param env (i.e. with no assumptions).
//
// Even though this impl has no type or const generic parameters, because we don't
// consider higher-ranked predicates such as `for<'a> &'a mut [u8]: Copy` to

View File

@ -1,6 +1,5 @@
//! Computes a normalizes-to (projection) goal for opaque types. This goal
//! behaves differently depending on the param-env's reveal mode and whether
//! the opaque is in a defining scope.
//! behaves differently depending on the current `TypingMode`.
use rustc_index::bit_set::GrowableBitSet;
use rustc_type_ir::inherent::*;

View File

@ -603,12 +603,12 @@ pub fn try_evaluate_const<'tcx>(
};
let uv = ty::UnevaluatedConst::new(uv.def, args);
// It's not *technically* correct to be revealing opaque types here as we could still be
// before borrowchecking. However, CTFE itself uses `Reveal::All` unconditionally even during
// typeck and not doing so has a lot of (undesirable) fallout (#101478, #119821). As a result we
// always use a revealed env when resolving the instance to evaluate.
// It's not *technically* correct to be revealing opaque types here as borrowcheck has
// not run yet. However, CTFE itself uses `TypingMode::PostAnalysis` unconditionally even
// during typeck and not doing so has a lot of (undesirable) fallout (#101478, #119821).
// As a result we always use a revealed env when resolving the instance to evaluate.
//
// FIXME: `const_eval_resolve_for_typeck` should probably just set the env to `Reveal::All`
// FIXME: `const_eval_resolve_for_typeck` should probably just modify the env itself
// instead of having this logic here
let typing_env =
tcx.erase_regions(infcx.typing_env(param_env)).with_post_analysis_normalized(tcx);

View File

@ -115,7 +115,7 @@ pub(super) fn needs_normalization<'tcx, T: TypeVisitable<TyCtxt<'tcx>>>(
) -> bool {
let mut flags = ty::TypeFlags::HAS_ALIAS;
// Opaques are treated as rigid with `Reveal::UserFacing`,
// Opaques are treated as rigid outside of `TypingMode::PostAnalysis`,
// so we can ignore those.
match infcx.typing_mode() {
TypingMode::Coherence | TypingMode::Analysis { defining_opaque_types: _ } => {

View File

@ -133,8 +133,10 @@ fn resolve_associated_item<'tcx>(
bug!("{:?} not found in {:?}", trait_item_id, impl_data.impl_def_id);
});
// Since this is a trait item, we need to see if the item is either a trait default item
// or a specialization because we can't resolve those unless we can `Reveal::All`.
// Since this is a trait item, we need to see if the item is either a trait
// default item or a specialization because we can't resolve those until we're
// in `TypingMode::PostAnalysis`.
//
// NOTE: This should be kept in sync with the similar code in
// `rustc_trait_selection::traits::project::assemble_candidates_from_impls()`.
let eligible = if leaf_def.is_final() {

View File

@ -46,9 +46,9 @@ fn layout_of<'tcx>(
let PseudoCanonicalInput { typing_env, value: ty } = query;
debug!(?ty);
// Optimization: We convert to RevealAll and convert opaque types in the where bounds
// to their hidden types. This reduces overall uncached invocations of `layout_of` and
// is thus a small performance improvement.
// Optimization: We convert to TypingMode::PostAnalysis and convert opaque types in
// the where bounds to their hidden types. This reduces overall uncached invocations
// of `layout_of` and is thus a small performance improvement.
let typing_env = typing_env.with_post_analysis_normalized(tcx);
let unnormalized_ty = ty;

View File

@ -444,7 +444,7 @@ pub enum AliasTermKind {
/// An associated type in an inherent `impl`
InherentTy,
/// An opaque type (usually from `impl Trait` in type aliases or function return types)
/// Can only be normalized away in RevealAll mode
/// Can only be normalized away in PostAnalysis mode or its defining scope.
OpaqueTy,
/// A type alias that actually checks its trait bounds.
/// Currently only used if the type alias references opaque types.

View File

@ -41,7 +41,7 @@ pub enum AliasTyKind {
/// An associated type in an inherent `impl`
Inherent,
/// An opaque type (usually from `impl Trait` in type aliases or function return types)
/// Can only be normalized away in RevealAll mode
/// Can only be normalized away in PostAnalysis mode or its defining scope.
Opaque,
/// A type alias that actually checks its trait bounds.
/// Currently only used if the type alias references opaque types.

View File

@ -1,5 +1,5 @@
- // MIR for `bar` before RevealAll
+ // MIR for `bar` after RevealAll
- // MIR for `bar` before PostAnalysisNormalize
+ // MIR for `bar` after PostAnalysisNormalize
fn bar(_1: P) -> () {
debug _baz => _1;

View File

@ -1,5 +1,5 @@
- // MIR for `bar` before RevealAll
+ // MIR for `bar` after RevealAll
- // MIR for `bar` before PostAnalysisNormalize
+ // MIR for `bar` after PostAnalysisNormalize
fn bar(_1: P) -> () {
debug _baz => _1;

View File

@ -2,7 +2,7 @@
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
#![crate_type = "lib"]
// EMIT_MIR issue_78442.bar.RevealAll.diff
// EMIT_MIR issue_78442.bar.PostAnalysisNormalize.diff
// EMIT_MIR issue_78442.bar.Inline.diff
pub fn bar<P>(
// Error won't happen if "bar" is not generic

View File

@ -1,5 +1,5 @@
// This causes a query cycle due to using `Reveal::All`,
// in #119821 const eval was changed to always use `Reveal::All`
// This causes a query cycle due to using `TypingEnv::PostAnalysis`,
// in #119821 const eval was changed to always use this mode.
//
// See that PR for more details.
use std::mem::transmute;

View File

@ -1,8 +1,8 @@
// Regression test for #105009. the issue here was that even after the `RevealAll` pass,
// Regression test for #105009. the issue here was that even after the `PostAnalysisNormalize` pass,
// `validate` still used `Reveal::UserFacing`. This meant that it now ends up comparing
// opaque types with their revealed version, resulting in an ICE.
//
// We're using these flags to run the `RevealAll` pass while making it less likely to
// We're using these flags to run the `PostAnalysisNormalize` pass while making it less likely to
// accidentally removing the assignment from `Foo<fn_ptr>` to `Foo<fn_def>`.
//@ compile-flags: -Zinline_mir=yes -Zmir-opt-level=0 -Zvalidate-mir

View File

@ -39,6 +39,6 @@ fn main() {
// So why is the second generic of `test` "`()`", and not the
// `impl Sized` since we inferred it from the return type of `rpit_fn`
// during typeck? Well, that's because we're using the generics from the
// terminator of the MIR, which has had the RevealAll pass performed on it.
// terminator of the MIR, which has had the PostAnalysisNormalize pass performed on it.
let _ = test(rpit_fn);
}

View File

@ -1,4 +1,4 @@
//! We evaluate `1 + 2` with `Reveal::All` during typeck, causing
//! We evaluate `1 + 2` with `TypingMode::PostAnalysis` during typeck, causing
//! us to get the concrete type of `Bar` while computing it.
//! This again requires type checking `foo`.
#![feature(type_alias_impl_trait)]

View File

@ -1,7 +1,7 @@
//@ compile-flags: -Zvalidate-mir
//@ check-pass
// Check that we don't cause cycle errors when validating pre-`Reveal::All` MIR
// Check that we don't cause cycle errors when validating pre-`RevealOpaques` MIR
// that assigns opaques through normalized projections.
#![feature(impl_trait_in_assoc_type)]