Skip to content

Split SolverDelegate back out from InferCtxtLike #127333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
@@ -4170,6 +4170,7 @@ dependencies = [
"rustc_middle",
"rustc_span",
"rustc_target",
"rustc_type_ir",
"smallvec",
"tracing",
]
1 change: 1 addition & 0 deletions compiler/rustc_infer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ rustc_macros = { path = "../rustc_macros" }
rustc_middle = { path = "../rustc_middle" }
rustc_span = { path = "../rustc_span" }
rustc_target = { path = "../rustc_target" }
rustc_type_ir = { path = "../rustc_type_ir" }
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
tracing = "0.1"
# tidy-alphabetical-end
172 changes: 172 additions & 0 deletions compiler/rustc_infer/src/infer/context.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
///! Definition of `InferCtxtLike` from the librarified type layer.
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::traits::solve::{Goal, NoSolution, SolverMode};
use rustc_middle::traits::ObligationCause;
use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_span::DUMMY_SP;
use rustc_type_ir::relate::Relate;
use rustc_type_ir::InferCtxtLike;

use super::{BoundRegionConversionTime, InferCtxt, SubregionOrigin};

impl<'tcx> InferCtxtLike for InferCtxt<'tcx> {
type Interner = TyCtxt<'tcx>;

fn cx(&self) -> TyCtxt<'tcx> {
self.tcx
}

fn solver_mode(&self) -> ty::solve::SolverMode {
match self.intercrate {
true => SolverMode::Coherence,
false => SolverMode::Normal,
}
}

fn universe(&self) -> ty::UniverseIndex {
self.universe()
}

fn create_next_universe(&self) -> ty::UniverseIndex {
self.create_next_universe()
}

fn universe_of_ty(&self, vid: ty::TyVid) -> Option<ty::UniverseIndex> {
match self.probe_ty_var(vid) {
Err(universe) => Some(universe),
Ok(_) => None,
}
}

fn universe_of_lt(&self, lt: ty::RegionVid) -> Option<ty::UniverseIndex> {
match self.inner.borrow_mut().unwrap_region_constraints().probe_value(lt) {
Err(universe) => Some(universe),
Ok(_) => None,
}
}

fn universe_of_ct(&self, ct: ty::ConstVid) -> Option<ty::UniverseIndex> {
match self.probe_const_var(ct) {
Err(universe) => Some(universe),
Ok(_) => None,
}
}

fn root_ty_var(&self, var: ty::TyVid) -> ty::TyVid {
self.root_var(var)
}

fn root_const_var(&self, var: ty::ConstVid) -> ty::ConstVid {
self.root_const_var(var)
}

fn opportunistic_resolve_ty_var(&self, vid: ty::TyVid) -> Ty<'tcx> {
match self.probe_ty_var(vid) {
Ok(ty) => ty,
Err(_) => Ty::new_var(self.tcx, self.root_var(vid)),
}
}

fn opportunistic_resolve_int_var(&self, vid: ty::IntVid) -> Ty<'tcx> {
self.opportunistic_resolve_int_var(vid)
}

fn opportunistic_resolve_float_var(&self, vid: ty::FloatVid) -> Ty<'tcx> {
self.opportunistic_resolve_float_var(vid)
}

fn opportunistic_resolve_ct_var(&self, vid: ty::ConstVid) -> ty::Const<'tcx> {
match self.probe_const_var(vid) {
Ok(ct) => ct,
Err(_) => ty::Const::new_var(self.tcx, self.root_const_var(vid)),
}
}

fn opportunistic_resolve_effect_var(&self, vid: ty::EffectVid) -> ty::Const<'tcx> {
match self.probe_effect_var(vid) {
Some(ct) => ct,
None => {
ty::Const::new_infer(self.tcx, ty::InferConst::EffectVar(self.root_effect_var(vid)))
}
}
}

fn opportunistic_resolve_lt_var(&self, vid: ty::RegionVid) -> ty::Region<'tcx> {
self.inner.borrow_mut().unwrap_region_constraints().opportunistic_resolve_var(self.tcx, vid)
}

fn defining_opaque_types(&self) -> &'tcx ty::List<LocalDefId> {
self.defining_opaque_types()
}

fn next_ty_infer(&self) -> Ty<'tcx> {
self.next_ty_var(DUMMY_SP)
}

fn next_const_infer(&self) -> ty::Const<'tcx> {
self.next_const_var(DUMMY_SP)
}

fn fresh_args_for_item(&self, def_id: DefId) -> ty::GenericArgsRef<'tcx> {
self.fresh_args_for_item(DUMMY_SP, def_id)
}

fn instantiate_binder_with_infer<T: TypeFoldable<TyCtxt<'tcx>> + Copy>(
&self,
value: ty::Binder<'tcx, T>,
) -> T {
self.instantiate_binder_with_fresh_vars(
DUMMY_SP,
BoundRegionConversionTime::HigherRankedType,
value,
)
}

fn enter_forall<T: TypeFoldable<TyCtxt<'tcx>> + Copy, U>(
&self,
value: ty::Binder<'tcx, T>,
f: impl FnOnce(T) -> U,
) -> U {
self.enter_forall(value, f)
}

fn relate<T: Relate<TyCtxt<'tcx>>>(
&self,
param_env: ty::ParamEnv<'tcx>,
lhs: T,
variance: ty::Variance,
rhs: T,
) -> Result<Vec<Goal<'tcx, ty::Predicate<'tcx>>>, NoSolution> {
self.at(&ObligationCause::dummy(), param_env).relate_no_trace(lhs, variance, rhs)
}

fn eq_structurally_relating_aliases<T: Relate<TyCtxt<'tcx>>>(
&self,
param_env: ty::ParamEnv<'tcx>,
lhs: T,
rhs: T,
) -> Result<Vec<Goal<'tcx, ty::Predicate<'tcx>>>, NoSolution> {
self.at(&ObligationCause::dummy(), param_env)
.eq_structurally_relating_aliases_no_trace(lhs, rhs)
}

fn resolve_vars_if_possible<T>(&self, value: T) -> T
where
T: TypeFoldable<TyCtxt<'tcx>>,
{
self.resolve_vars_if_possible(value)
}

fn probe<T>(&self, probe: impl FnOnce() -> T) -> T {
self.probe(|_| probe())
}

fn sub_regions(&self, sub: ty::Region<'tcx>, sup: ty::Region<'tcx>) {
self.sub_regions(SubregionOrigin::RelateRegionParamBound(DUMMY_SP), sub, sup)
}

fn register_ty_outlives(&self, ty: Ty<'tcx>, r: ty::Region<'tcx>) {
self.register_region_obligation_with_cause(ty, r, &ObligationCause::dummy());
}
}
1 change: 1 addition & 0 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
@@ -53,6 +53,7 @@ use type_variable::TypeVariableOrigin;

pub mod at;
pub mod canonical;
mod context;
pub mod error_reporting;
pub mod free_regions;
mod freshen;
3 changes: 2 additions & 1 deletion compiler/rustc_next_trait_solver/src/canonicalizer.rs
Original file line number Diff line number Diff line change
@@ -4,7 +4,8 @@ use rustc_type_ir::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
use rustc_type_ir::inherent::*;
use rustc_type_ir::visit::TypeVisitableExt;
use rustc_type_ir::{
self as ty, Canonical, CanonicalTyVarKind, CanonicalVarInfo, CanonicalVarKind, Interner,
self as ty, Canonical, CanonicalTyVarKind, CanonicalVarInfo, CanonicalVarKind, InferCtxtLike,
Interner,
};

use crate::delegate::SolverDelegate;
96 changes: 8 additions & 88 deletions compiler/rustc_next_trait_solver/src/delegate.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
use std::fmt::Debug;
use std::ops::Deref;

use rustc_type_ir::fold::TypeFoldable;
use rustc_type_ir::relate::Relate;
use rustc_type_ir::solve::{Certainty, Goal, NoSolution, SolverMode};
use rustc_type_ir::{self as ty, Interner};
use rustc_type_ir::{self as ty, InferCtxtLike, Interner};

pub trait SolverDelegate: Sized {
pub trait SolverDelegate:
Deref<Target: InferCtxtLike<Interner = <Self as SolverDelegate>::Interner>> + Sized
{
type Interner: Interner;
fn cx(&self) -> Self::Interner;
fn cx(&self) -> Self::Interner {
(**self).cx()
}

type Span: Copy;

fn solver_mode(&self) -> SolverMode;

fn build_with_canonical<V>(
cx: Self::Interner,
solver_mode: SolverMode,
@@ -21,82 +23,12 @@ pub trait SolverDelegate: Sized {
where
V: TypeFoldable<Self::Interner>;

fn universe(&self) -> ty::UniverseIndex;
fn create_next_universe(&self) -> ty::UniverseIndex;

fn universe_of_ty(&self, ty: ty::TyVid) -> Option<ty::UniverseIndex>;
fn universe_of_lt(&self, lt: ty::RegionVid) -> Option<ty::UniverseIndex>;
fn universe_of_ct(&self, ct: ty::ConstVid) -> Option<ty::UniverseIndex>;

fn root_ty_var(&self, var: ty::TyVid) -> ty::TyVid;
fn root_const_var(&self, var: ty::ConstVid) -> ty::ConstVid;

fn opportunistic_resolve_ty_var(&self, vid: ty::TyVid) -> <Self::Interner as Interner>::Ty;
fn opportunistic_resolve_int_var(&self, vid: ty::IntVid) -> <Self::Interner as Interner>::Ty;
fn opportunistic_resolve_float_var(
&self,
vid: ty::FloatVid,
) -> <Self::Interner as Interner>::Ty;
fn opportunistic_resolve_ct_var(
&self,
vid: ty::ConstVid,
) -> <Self::Interner as Interner>::Const;
fn opportunistic_resolve_effect_var(
&self,
vid: ty::EffectVid,
) -> <Self::Interner as Interner>::Const;
fn opportunistic_resolve_lt_var(
&self,
vid: ty::RegionVid,
) -> <Self::Interner as Interner>::Region;

fn defining_opaque_types(&self) -> <Self::Interner as Interner>::DefiningOpaqueTypes;

fn next_ty_infer(&self) -> <Self::Interner as Interner>::Ty;
fn next_const_infer(&self) -> <Self::Interner as Interner>::Const;
fn fresh_args_for_item(
&self,
def_id: <Self::Interner as Interner>::DefId,
) -> <Self::Interner as Interner>::GenericArgs;

fn fresh_var_for_kind_with_span(
&self,
arg: <Self::Interner as Interner>::GenericArg,
span: Self::Span,
) -> <Self::Interner as Interner>::GenericArg;

fn instantiate_binder_with_infer<T: TypeFoldable<Self::Interner> + Copy>(
&self,
value: ty::Binder<Self::Interner, T>,
) -> T;

fn enter_forall<T: TypeFoldable<Self::Interner> + Copy, U>(
&self,
value: ty::Binder<Self::Interner, T>,
f: impl FnOnce(T) -> U,
) -> U;

fn relate<T: Relate<Self::Interner>>(
&self,
param_env: <Self::Interner as Interner>::ParamEnv,
lhs: T,
variance: ty::Variance,
rhs: T,
) -> Result<Vec<Goal<Self::Interner, <Self::Interner as Interner>::Predicate>>, NoSolution>;

fn eq_structurally_relating_aliases<T: Relate<Self::Interner>>(
&self,
param_env: <Self::Interner as Interner>::ParamEnv,
lhs: T,
rhs: T,
) -> Result<Vec<Goal<Self::Interner, <Self::Interner as Interner>::Predicate>>, NoSolution>;

fn resolve_vars_if_possible<T>(&self, value: T) -> T
where
T: TypeFoldable<Self::Interner>;

fn probe<T>(&self, probe: impl FnOnce() -> T) -> T;

// FIXME: Uplift the leak check into this crate.
fn leak_check(&self, max_input_universe: ty::UniverseIndex) -> Result<(), NoSolution>;

@@ -112,18 +44,6 @@ pub trait SolverDelegate: Sized {
unevaluated: ty::UnevaluatedConst<Self::Interner>,
) -> Option<<Self::Interner as Interner>::Const>;

fn sub_regions(
&self,
sub: <Self::Interner as Interner>::Region,
sup: <Self::Interner as Interner>::Region,
);

fn register_ty_outlives(
&self,
ty: <Self::Interner as Interner>::Ty,
r: <Self::Interner as Interner>::Region,
);

// FIXME: This only is here because `wf::obligations` is in `rustc_trait_selection`!
fn well_formed_goals(
&self,
2 changes: 1 addition & 1 deletion compiler/rustc_next_trait_solver/src/resolve.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ use crate::delegate::SolverDelegate;
use rustc_type_ir::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
use rustc_type_ir::inherent::*;
use rustc_type_ir::visit::TypeVisitableExt;
use rustc_type_ir::{self as ty, Interner};
use rustc_type_ir::{self as ty, InferCtxtLike, Interner};

///////////////////////////////////////////////////////////////////////////
// EAGER RESOLUTION
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ use std::iter;
use rustc_index::IndexVec;
use rustc_type_ir::fold::TypeFoldable;
use rustc_type_ir::inherent::*;
use rustc_type_ir::{self as ty, Canonical, CanonicalVarValues, Interner};
use rustc_type_ir::{self as ty, Canonical, CanonicalVarValues, InferCtxtLike, Interner};
use tracing::{instrument, trace};

use crate::canonicalizer::{CanonicalizeMode, Canonicalizer};
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ use rustc_type_ir::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
use rustc_type_ir::inherent::*;
use rustc_type_ir::relate::Relate;
use rustc_type_ir::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor};
use rustc_type_ir::{self as ty, CanonicalVarValues, Interner};
use rustc_type_ir::{self as ty, CanonicalVarValues, InferCtxtLike, Interner};
use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic};
use tracing::{instrument, trace};

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::marker::PhantomData;

use rustc_type_ir::Interner;
use rustc_type_ir::{InferCtxtLike, Interner};
use tracing::instrument;

use crate::delegate::SolverDelegate;
171 changes: 2 additions & 169 deletions compiler/rustc_trait_selection/src/solve/delegate.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
use std::ops::Deref;

use rustc_data_structures::fx::FxHashSet;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::def_id::DefId;
use rustc_infer::infer::canonical::query_response::make_query_region_constraints;
use rustc_infer::infer::canonical::{
Canonical, CanonicalExt as _, CanonicalVarInfo, CanonicalVarValues,
};
use rustc_infer::infer::{
BoundRegionConversionTime, InferCtxt, RegionVariableOrigin, SubregionOrigin, TyCtxtInferExt,
};
use rustc_infer::infer::{InferCtxt, RegionVariableOrigin, TyCtxtInferExt};
use rustc_infer::traits::solve::Goal;
use rustc_infer::traits::util::supertraits;
use rustc_infer::traits::{ObligationCause, Reveal};
use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt as _};
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
use rustc_type_ir::relate::Relate;
use rustc_type_ir::solve::{Certainty, NoSolution, SolverMode};

use crate::traits::coherence::trait_ref_is_knowable;
@@ -48,13 +45,6 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<

type Span = Span;

fn solver_mode(&self) -> ty::solve::SolverMode {
match self.intercrate {
true => SolverMode::Coherence,
false => SolverMode::Normal,
}
}

fn build_with_canonical<V>(
interner: TyCtxt<'tcx>,
solver_mode: SolverMode,
@@ -74,104 +64,6 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
(SolverDelegate(infcx), value, vars)
}

fn universe(&self) -> ty::UniverseIndex {
self.0.universe()
}

fn create_next_universe(&self) -> ty::UniverseIndex {
self.0.create_next_universe()
}

fn universe_of_ty(&self, vid: ty::TyVid) -> Option<ty::UniverseIndex> {
// FIXME(BoxyUwU): this is kind of jank and means that printing unresolved
// ty infers will give you the universe of the var it resolved to not the universe
// it actually had. It also means that if you have a `?0.1` and infer it to `u8` then
// try to print out `?0.1` it will just print `?0`.
match self.0.probe_ty_var(vid) {
Err(universe) => Some(universe),
Ok(_) => None,
}
}

fn universe_of_lt(&self, lt: ty::RegionVid) -> Option<ty::UniverseIndex> {
match self.0.inner.borrow_mut().unwrap_region_constraints().probe_value(lt) {
Err(universe) => Some(universe),
Ok(_) => None,
}
}

fn universe_of_ct(&self, ct: ty::ConstVid) -> Option<ty::UniverseIndex> {
// Same issue as with `universe_of_ty`
match self.0.probe_const_var(ct) {
Err(universe) => Some(universe),
Ok(_) => None,
}
}

fn root_ty_var(&self, var: ty::TyVid) -> ty::TyVid {
self.0.root_var(var)
}

fn root_const_var(&self, var: ty::ConstVid) -> ty::ConstVid {
self.0.root_const_var(var)
}

fn opportunistic_resolve_ty_var(&self, vid: ty::TyVid) -> Ty<'tcx> {
match self.0.probe_ty_var(vid) {
Ok(ty) => ty,
Err(_) => Ty::new_var(self.0.tcx, self.0.root_var(vid)),
}
}

fn opportunistic_resolve_int_var(&self, vid: ty::IntVid) -> Ty<'tcx> {
self.0.opportunistic_resolve_int_var(vid)
}

fn opportunistic_resolve_float_var(&self, vid: ty::FloatVid) -> Ty<'tcx> {
self.0.opportunistic_resolve_float_var(vid)
}

fn opportunistic_resolve_ct_var(&self, vid: ty::ConstVid) -> ty::Const<'tcx> {
match self.0.probe_const_var(vid) {
Ok(ct) => ct,
Err(_) => ty::Const::new_var(self.0.tcx, self.0.root_const_var(vid)),
}
}

fn opportunistic_resolve_effect_var(&self, vid: ty::EffectVid) -> ty::Const<'tcx> {
match self.0.probe_effect_var(vid) {
Some(ct) => ct,
None => ty::Const::new_infer(
self.0.tcx,
ty::InferConst::EffectVar(self.0.root_effect_var(vid)),
),
}
}

fn opportunistic_resolve_lt_var(&self, vid: ty::RegionVid) -> ty::Region<'tcx> {
self.0
.inner
.borrow_mut()
.unwrap_region_constraints()
.opportunistic_resolve_var(self.0.tcx, vid)
}

fn defining_opaque_types(&self) -> &'tcx ty::List<LocalDefId> {
self.0.defining_opaque_types()
}

fn next_ty_infer(&self) -> Ty<'tcx> {
self.0.next_ty_var(DUMMY_SP)
}

fn next_const_infer(&self) -> ty::Const<'tcx> {
self.0.next_const_var(DUMMY_SP)
}

fn fresh_args_for_item(&self, def_id: DefId) -> ty::GenericArgsRef<'tcx> {
self.0.fresh_args_for_item(DUMMY_SP, def_id)
}

fn fresh_var_for_kind_with_span(
&self,
arg: ty::GenericArg<'tcx>,
@@ -186,57 +78,6 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
}
}

fn instantiate_binder_with_infer<T: TypeFoldable<TyCtxt<'tcx>> + Copy>(
&self,
value: ty::Binder<'tcx, T>,
) -> T {
self.0.instantiate_binder_with_fresh_vars(
DUMMY_SP,
BoundRegionConversionTime::HigherRankedType,
value,
)
}

fn enter_forall<T: TypeFoldable<TyCtxt<'tcx>> + Copy, U>(
&self,
value: ty::Binder<'tcx, T>,
f: impl FnOnce(T) -> U,
) -> U {
self.0.enter_forall(value, f)
}

fn relate<T: Relate<TyCtxt<'tcx>>>(
&self,
param_env: ty::ParamEnv<'tcx>,
lhs: T,
variance: ty::Variance,
rhs: T,
) -> Result<Vec<Goal<'tcx, ty::Predicate<'tcx>>>, NoSolution> {
self.0.at(&ObligationCause::dummy(), param_env).relate_no_trace(lhs, variance, rhs)
}

fn eq_structurally_relating_aliases<T: Relate<TyCtxt<'tcx>>>(
&self,
param_env: ty::ParamEnv<'tcx>,
lhs: T,
rhs: T,
) -> Result<Vec<Goal<'tcx, ty::Predicate<'tcx>>>, NoSolution> {
self.0
.at(&ObligationCause::dummy(), param_env)
.eq_structurally_relating_aliases_no_trace(lhs, rhs)
}

fn resolve_vars_if_possible<T>(&self, value: T) -> T
where
T: TypeFoldable<TyCtxt<'tcx>>,
{
self.0.resolve_vars_if_possible(value)
}

fn probe<T>(&self, probe: impl FnOnce() -> T) -> T {
self.0.probe(|_| probe())
}

fn leak_check(&self, max_input_universe: ty::UniverseIndex) -> Result<(), NoSolution> {
self.0.leak_check(max_input_universe, None).map_err(|_| NoSolution)
}
@@ -265,14 +106,6 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
}
}

fn sub_regions(&self, sub: ty::Region<'tcx>, sup: ty::Region<'tcx>) {
self.0.sub_regions(SubregionOrigin::RelateRegionParamBound(DUMMY_SP), sub, sup)
}

fn register_ty_outlives(&self, ty: Ty<'tcx>, r: ty::Region<'tcx>) {
self.0.register_region_obligation_with_cause(ty, r, &ObligationCause::dummy());
}

fn well_formed_goals(
&self,
param_env: ty::ParamEnv<'tcx>,
93 changes: 93 additions & 0 deletions compiler/rustc_type_ir/src/infer_ctxt.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
use crate::fold::TypeFoldable;
use crate::relate::Relate;
use crate::solve::{Goal, NoSolution, SolverMode};
use crate::{self as ty, Interner};

pub trait InferCtxtLike {
type Interner: Interner;
fn cx(&self) -> Self::Interner;

fn solver_mode(&self) -> SolverMode;

fn universe(&self) -> ty::UniverseIndex;
fn create_next_universe(&self) -> ty::UniverseIndex;

fn universe_of_ty(&self, ty: ty::TyVid) -> Option<ty::UniverseIndex>;
fn universe_of_lt(&self, lt: ty::RegionVid) -> Option<ty::UniverseIndex>;
fn universe_of_ct(&self, ct: ty::ConstVid) -> Option<ty::UniverseIndex>;

fn root_ty_var(&self, var: ty::TyVid) -> ty::TyVid;
fn root_const_var(&self, var: ty::ConstVid) -> ty::ConstVid;

fn opportunistic_resolve_ty_var(&self, vid: ty::TyVid) -> <Self::Interner as Interner>::Ty;
fn opportunistic_resolve_int_var(&self, vid: ty::IntVid) -> <Self::Interner as Interner>::Ty;
fn opportunistic_resolve_float_var(
&self,
vid: ty::FloatVid,
) -> <Self::Interner as Interner>::Ty;
fn opportunistic_resolve_ct_var(
&self,
vid: ty::ConstVid,
) -> <Self::Interner as Interner>::Const;
fn opportunistic_resolve_effect_var(
&self,
vid: ty::EffectVid,
) -> <Self::Interner as Interner>::Const;
fn opportunistic_resolve_lt_var(
&self,
vid: ty::RegionVid,
) -> <Self::Interner as Interner>::Region;

fn defining_opaque_types(&self) -> <Self::Interner as Interner>::DefiningOpaqueTypes;

fn next_ty_infer(&self) -> <Self::Interner as Interner>::Ty;
fn next_const_infer(&self) -> <Self::Interner as Interner>::Const;
fn fresh_args_for_item(
&self,
def_id: <Self::Interner as Interner>::DefId,
) -> <Self::Interner as Interner>::GenericArgs;

fn instantiate_binder_with_infer<T: TypeFoldable<Self::Interner> + Copy>(
&self,
value: ty::Binder<Self::Interner, T>,
) -> T;

fn enter_forall<T: TypeFoldable<Self::Interner> + Copy, U>(
&self,
value: ty::Binder<Self::Interner, T>,
f: impl FnOnce(T) -> U,
) -> U;

fn relate<T: Relate<Self::Interner>>(
&self,
param_env: <Self::Interner as Interner>::ParamEnv,
lhs: T,
variance: ty::Variance,
rhs: T,
) -> Result<Vec<Goal<Self::Interner, <Self::Interner as Interner>::Predicate>>, NoSolution>;

fn eq_structurally_relating_aliases<T: Relate<Self::Interner>>(
&self,
param_env: <Self::Interner as Interner>::ParamEnv,
lhs: T,
rhs: T,
) -> Result<Vec<Goal<Self::Interner, <Self::Interner as Interner>::Predicate>>, NoSolution>;

fn resolve_vars_if_possible<T>(&self, value: T) -> T
where
T: TypeFoldable<Self::Interner>;

fn probe<T>(&self, probe: impl FnOnce() -> T) -> T;

fn sub_regions(
&self,
sub: <Self::Interner as Interner>::Region,
sup: <Self::Interner as Interner>::Region,
);

fn register_ty_outlives(
&self,
ty: <Self::Interner as Interner>::Ty,
r: <Self::Interner as Interner>::Region,
);
}
2 changes: 2 additions & 0 deletions compiler/rustc_type_ir/src/lib.rs
Original file line number Diff line number Diff line change
@@ -39,6 +39,7 @@ mod const_kind;
mod effects;
mod flags;
mod generic_arg;
mod infer_ctxt;
mod interner;
mod opaque_ty;
mod predicate;
@@ -56,6 +57,7 @@ pub use const_kind::*;
pub use effects::*;
pub use flags::*;
pub use generic_arg::*;
pub use infer_ctxt::*;
pub use interner::*;
pub use opaque_ty::*;
pub use predicate::*;