Auto merge of #133242 - lcnr:questionable-uwu, r=compiler-errors,BoxyUwU
finish `Reveal` removal After #133212 changed the `TypingMode` to be the only source of truth, this entirely rips out `Reveal`. cc #132279 r? `@compiler-errors`
This commit is contained in:
commit
386a7c7ae2
82 changed files with 344 additions and 529 deletions
|
@ -72,7 +72,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
query_state,
|
||||
)
|
||||
.unchecked_map(|(param_env, value)| param_env.and(value));
|
||||
CanonicalQueryInput { canonical, typing_mode: self.typing_mode(param_env) }
|
||||
CanonicalQueryInput { canonical, typing_mode: self.typing_mode() }
|
||||
}
|
||||
|
||||
/// Canonicalizes a query *response* `V`. When we canonicalize a
|
||||
|
|
|
@ -20,11 +20,8 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
|
|||
self.next_trait_solver
|
||||
}
|
||||
|
||||
fn typing_mode(
|
||||
&self,
|
||||
param_env_for_debug_assertion: ty::ParamEnv<'tcx>,
|
||||
) -> ty::TypingMode<'tcx> {
|
||||
self.typing_mode(param_env_for_debug_assertion)
|
||||
fn typing_mode(&self) -> ty::TypingMode<'tcx> {
|
||||
self.typing_mode()
|
||||
}
|
||||
|
||||
fn universe(&self) -> ty::UniverseIndex {
|
||||
|
|
|
@ -43,7 +43,6 @@ use rustc_middle::ty::{
|
|||
};
|
||||
use rustc_span::Span;
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_type_ir::solve::Reveal;
|
||||
use snapshot::undo_log::InferCtxtUndoLogs;
|
||||
use tracing::{debug, instrument};
|
||||
use type_variable::TypeVariableOrigin;
|
||||
|
@ -265,11 +264,12 @@ pub struct InferCtxt<'tcx> {
|
|||
lexical_region_resolutions: RefCell<Option<LexicalRegionResolutions<'tcx>>>,
|
||||
|
||||
/// Caches the results of trait selection. This cache is used
|
||||
/// for things that have to do with the parameters in scope.
|
||||
pub selection_cache: select::SelectionCache<'tcx>,
|
||||
/// for things that depends on inference variables or placeholders.
|
||||
pub selection_cache: select::SelectionCache<'tcx, ty::ParamEnv<'tcx>>,
|
||||
|
||||
/// Caches the results of trait evaluation.
|
||||
pub evaluation_cache: select::EvaluationCache<'tcx>,
|
||||
/// Caches the results of trait evaluation. This cache is used
|
||||
/// for things that depends on inference variables or placeholders.
|
||||
pub evaluation_cache: select::EvaluationCache<'tcx, ty::ParamEnv<'tcx>>,
|
||||
|
||||
/// The set of predicates on which errors have been reported, to
|
||||
/// avoid reporting the same error twice.
|
||||
|
@ -624,22 +624,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn typing_mode(
|
||||
&self,
|
||||
param_env_for_debug_assertion: ty::ParamEnv<'tcx>,
|
||||
) -> TypingMode<'tcx> {
|
||||
if cfg!(debug_assertions) {
|
||||
match (param_env_for_debug_assertion.reveal(), self.typing_mode) {
|
||||
(Reveal::All, TypingMode::PostAnalysis)
|
||||
| (Reveal::UserFacing, TypingMode::Coherence | TypingMode::Analysis { .. }) => {}
|
||||
(r, t) => unreachable!("TypingMode x Reveal mismatch: {r:?} {t:?}"),
|
||||
}
|
||||
}
|
||||
self.typing_mode
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn typing_mode_unchecked(&self) -> TypingMode<'tcx> {
|
||||
pub fn typing_mode(&self) -> TypingMode<'tcx> {
|
||||
self.typing_mode
|
||||
}
|
||||
|
||||
|
@ -1005,7 +990,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
|
||||
#[inline(always)]
|
||||
pub fn can_define_opaque_ty(&self, id: impl Into<DefId>) -> bool {
|
||||
match self.typing_mode_unchecked() {
|
||||
match self.typing_mode() {
|
||||
TypingMode::Analysis { defining_opaque_types } => {
|
||||
id.into().as_local().is_some_and(|def_id| defining_opaque_types.contains(&def_id))
|
||||
}
|
||||
|
@ -1290,7 +1275,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
/// which contains the necessary information to use the trait system without
|
||||
/// using canonicalization or carrying this inference context around.
|
||||
pub fn typing_env(&self, param_env: ty::ParamEnv<'tcx>) -> ty::TypingEnv<'tcx> {
|
||||
let typing_mode = match self.typing_mode(param_env) {
|
||||
let typing_mode = match self.typing_mode() {
|
||||
ty::TypingMode::Coherence => ty::TypingMode::Coherence,
|
||||
// FIXME(#132279): This erases the `defining_opaque_types` as it isn't possible
|
||||
// to handle them without proper canonicalization. This means we may cause cycle
|
||||
|
|
|
@ -101,7 +101,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
let process = |a: Ty<'tcx>, b: Ty<'tcx>| match *a.kind() {
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) if def_id.is_local() => {
|
||||
let def_id = def_id.expect_local();
|
||||
if let ty::TypingMode::Coherence = self.typing_mode(param_env) {
|
||||
if let ty::TypingMode::Coherence = self.typing_mode() {
|
||||
// See comment on `insert_hidden_type` for why this is sufficient in coherence
|
||||
return Some(self.register_hidden_type(
|
||||
OpaqueTypeKey { def_id, args },
|
||||
|
@ -522,7 +522,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
// value being folded. In simple cases like `-> impl Foo`,
|
||||
// these are the same span, but not in cases like `-> (impl
|
||||
// Foo, impl Bar)`.
|
||||
match self.typing_mode(param_env) {
|
||||
match self.typing_mode() {
|
||||
ty::TypingMode::Coherence => {
|
||||
// During intercrate we do not define opaque types but instead always
|
||||
// force ambiguity unless the hidden type is known to not implement
|
||||
|
|
|
@ -520,10 +520,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
|
|||
//
|
||||
// cc trait-system-refactor-initiative#108
|
||||
if self.infcx.next_trait_solver()
|
||||
&& !matches!(
|
||||
self.infcx.typing_mode_unchecked(),
|
||||
TypingMode::Coherence
|
||||
)
|
||||
&& !matches!(self.infcx.typing_mode(), TypingMode::Coherence)
|
||||
&& self.in_alias
|
||||
{
|
||||
inner.type_variables().equate(vid, new_var_id);
|
||||
|
@ -654,10 +651,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
|
|||
// See the comment for type inference variables
|
||||
// for more details.
|
||||
if self.infcx.next_trait_solver()
|
||||
&& !matches!(
|
||||
self.infcx.typing_mode_unchecked(),
|
||||
TypingMode::Coherence
|
||||
)
|
||||
&& !matches!(self.infcx.typing_mode(), TypingMode::Coherence)
|
||||
&& self.in_alias
|
||||
{
|
||||
variable_table.union(vid, new_var_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue