1
Fork 0

no more Reveal :(

This commit is contained in:
lcnr 2024-11-20 11:31:49 +01:00
parent f4b516b10c
commit 319843d8cd
46 changed files with 112 additions and 299 deletions

View file

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

View file

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

View file

@ -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;
@ -624,22 +623,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 +989,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 +1274,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

View file

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

View file

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