about summary refs log tree commit diff
path: root/compiler/rustc_next_trait_solver/src/infcx.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_next_trait_solver/src/infcx.rs')
-rw-r--r--compiler/rustc_next_trait_solver/src/infcx.rs116
1 files changed, 114 insertions, 2 deletions
diff --git a/compiler/rustc_next_trait_solver/src/infcx.rs b/compiler/rustc_next_trait_solver/src/infcx.rs
index cb46d8f8f73..e1d5c37fada 100644
--- a/compiler/rustc_next_trait_solver/src/infcx.rs
+++ b/compiler/rustc_next_trait_solver/src/infcx.rs
@@ -1,13 +1,27 @@
+use std::fmt::Debug;
+
 use rustc_type_ir::fold::TypeFoldable;
 use rustc_type_ir::relate::Relate;
-use rustc_type_ir::solve::{Goal, NoSolution};
+use rustc_type_ir::solve::{Goal, NoSolution, SolverMode};
 use rustc_type_ir::{self as ty, Interner};
 
 pub trait SolverDelegate: Sized {
     type Interner: Interner;
-
     fn interner(&self) -> Self::Interner;
 
+    fn solver_mode(&self) -> SolverMode;
+
+    fn build_with_canonical<V>(
+        interner: Self::Interner,
+        solver_mode: SolverMode,
+        canonical: &ty::Canonical<Self::Interner, V>,
+    ) -> (Self, V, ty::CanonicalVarValues<Self::Interner>)
+    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>;
@@ -74,4 +88,102 @@ pub trait SolverDelegate: Sized {
         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>;
+
+    // FIXME: This is only here because elaboration lives in `rustc_infer`!
+    fn elaborate_supertraits(
+        interner: Self::Interner,
+        trait_ref: ty::Binder<Self::Interner, ty::TraitRef<Self::Interner>>,
+    ) -> impl Iterator<Item = ty::Binder<Self::Interner, ty::TraitRef<Self::Interner>>>;
+
+    fn try_const_eval_resolve(
+        &self,
+        param_env: <Self::Interner as Interner>::ParamEnv,
+        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,
+        param_env: <Self::Interner as Interner>::ParamEnv,
+        arg: <Self::Interner as Interner>::GenericArg,
+    ) -> Option<Vec<Goal<Self::Interner, <Self::Interner as Interner>::Predicate>>>;
+
+    fn clone_opaque_types_for_query_response(
+        &self,
+    ) -> Vec<(ty::OpaqueTypeKey<Self::Interner>, <Self::Interner as Interner>::Ty)>;
+
+    fn make_deduplicated_outlives_constraints(
+        &self,
+    ) -> Vec<ty::OutlivesPredicate<Self::Interner, <Self::Interner as Interner>::GenericArg>>;
+
+    fn instantiate_canonical<V>(
+        &self,
+        canonical: ty::Canonical<Self::Interner, V>,
+        values: ty::CanonicalVarValues<Self::Interner>,
+    ) -> V
+    where
+        V: TypeFoldable<Self::Interner>;
+
+    fn instantiate_canonical_var_with_infer(
+        &self,
+        cv_info: ty::CanonicalVarInfo<Self::Interner>,
+        universe_map: impl Fn(ty::UniverseIndex) -> ty::UniverseIndex,
+    ) -> <Self::Interner as Interner>::GenericArg;
+
+    // FIXME: Can we implement this in terms of `add` and `inject`?
+    fn insert_hidden_type(
+        &self,
+        opaque_type_key: ty::OpaqueTypeKey<Self::Interner>,
+        param_env: <Self::Interner as Interner>::ParamEnv,
+        hidden_ty: <Self::Interner as Interner>::Ty,
+        goals: &mut Vec<Goal<Self::Interner, <Self::Interner as Interner>::Predicate>>,
+    ) -> Result<(), NoSolution>;
+
+    fn add_item_bounds_for_hidden_type(
+        &self,
+        def_id: <Self::Interner as Interner>::DefId,
+        args: <Self::Interner as Interner>::GenericArgs,
+        param_env: <Self::Interner as Interner>::ParamEnv,
+        hidden_ty: <Self::Interner as Interner>::Ty,
+        goals: &mut Vec<Goal<Self::Interner, <Self::Interner as Interner>::Predicate>>,
+    );
+
+    fn inject_new_hidden_type_unchecked(
+        &self,
+        key: ty::OpaqueTypeKey<Self::Interner>,
+        hidden_ty: <Self::Interner as Interner>::Ty,
+    );
+
+    fn reset_opaque_types(&self);
+
+    fn trait_ref_is_knowable<E: Debug>(
+        &self,
+        trait_ref: ty::TraitRef<Self::Interner>,
+        lazily_normalize_ty: impl FnMut(
+            <Self::Interner as Interner>::Ty,
+        ) -> Result<<Self::Interner as Interner>::Ty, E>,
+    ) -> Result<bool, E>;
+
+    fn fetch_eligible_assoc_item(
+        &self,
+        param_env: <Self::Interner as Interner>::ParamEnv,
+        goal_trait_ref: ty::TraitRef<Self::Interner>,
+        trait_assoc_def_id: <Self::Interner as Interner>::DefId,
+        impl_def_id: <Self::Interner as Interner>::DefId,
+    ) -> Result<Option<<Self::Interner as Interner>::DefId>, NoSolution>;
 }