use std::fmt::Debug; use rustc_type_ir::fold::TypeFoldable; use rustc_type_ir::relate::Relate; 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; type Span: Copy; fn solver_mode(&self) -> SolverMode; fn build_with_canonical( interner: Self::Interner, solver_mode: SolverMode, canonical: &ty::Canonical, ) -> (Self, V, ty::CanonicalVarValues) where V: TypeFoldable; fn universe(&self) -> ty::UniverseIndex; fn create_next_universe(&self) -> ty::UniverseIndex; fn universe_of_ty(&self, ty: ty::TyVid) -> Option; fn universe_of_lt(&self, lt: ty::RegionVid) -> Option; fn universe_of_ct(&self, ct: ty::ConstVid) -> Option; 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) -> ::Ty; fn opportunistic_resolve_int_var(&self, vid: ty::IntVid) -> ::Ty; fn opportunistic_resolve_float_var( &self, vid: ty::FloatVid, ) -> ::Ty; fn opportunistic_resolve_ct_var( &self, vid: ty::ConstVid, ) -> ::Const; fn opportunistic_resolve_effect_var( &self, vid: ty::EffectVid, ) -> ::Const; fn opportunistic_resolve_lt_var( &self, vid: ty::RegionVid, ) -> ::Region; fn defining_opaque_types(&self) -> ::DefiningOpaqueTypes; fn next_ty_infer(&self) -> ::Ty; fn next_const_infer(&self) -> ::Const; fn fresh_args_for_item( &self, def_id: ::DefId, ) -> ::GenericArgs; fn fresh_var_for_kind_with_span( &self, arg: ::GenericArg, span: Self::Span, ) -> ::GenericArg; fn instantiate_binder_with_infer + Copy>( &self, value: ty::Binder, ) -> T; fn enter_forall + Copy, U>( &self, value: ty::Binder, f: impl FnOnce(T) -> U, ) -> U; fn relate>( &self, param_env: ::ParamEnv, lhs: T, variance: ty::Variance, rhs: T, ) -> Result::Predicate>>, NoSolution>; fn eq_structurally_relating_aliases>( &self, param_env: ::ParamEnv, lhs: T, rhs: T, ) -> Result::Predicate>>, NoSolution>; fn resolve_vars_if_possible(&self, value: T) -> T where T: TypeFoldable; fn probe(&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>, ) -> impl Iterator>>; fn try_const_eval_resolve( &self, param_env: ::ParamEnv, unevaluated: ty::UnevaluatedConst, ) -> Option<::Const>; fn sub_regions( &self, sub: ::Region, sup: ::Region, ); fn register_ty_outlives( &self, ty: ::Ty, r: ::Region, ); // FIXME: This only is here because `wf::obligations` is in `rustc_trait_selection`! fn well_formed_goals( &self, param_env: ::ParamEnv, arg: ::GenericArg, ) -> Option::Predicate>>>; fn clone_opaque_types_for_query_response( &self, ) -> Vec<(ty::OpaqueTypeKey, ::Ty)>; fn make_deduplicated_outlives_constraints( &self, ) -> Vec::GenericArg>>; fn instantiate_canonical( &self, canonical: ty::Canonical, values: ty::CanonicalVarValues, ) -> V where V: TypeFoldable; fn instantiate_canonical_var_with_infer( &self, cv_info: ty::CanonicalVarInfo, universe_map: impl Fn(ty::UniverseIndex) -> ty::UniverseIndex, ) -> ::GenericArg; // FIXME: Can we implement this in terms of `add` and `inject`? fn insert_hidden_type( &self, opaque_type_key: ty::OpaqueTypeKey, param_env: ::ParamEnv, hidden_ty: ::Ty, goals: &mut Vec::Predicate>>, ) -> Result<(), NoSolution>; fn add_item_bounds_for_hidden_type( &self, def_id: ::DefId, args: ::GenericArgs, param_env: ::ParamEnv, hidden_ty: ::Ty, goals: &mut Vec::Predicate>>, ); fn inject_new_hidden_type_unchecked( &self, key: ty::OpaqueTypeKey, hidden_ty: ::Ty, ); fn reset_opaque_types(&self); fn trait_ref_is_knowable( &self, trait_ref: ty::TraitRef, lazily_normalize_ty: impl FnMut( ::Ty, ) -> Result<::Ty, E>, ) -> Result; fn fetch_eligible_assoc_item( &self, param_env: ::ParamEnv, goal_trait_ref: ty::TraitRef, trait_assoc_def_id: ::DefId, impl_def_id: ::DefId, ) -> Result::DefId>, NoSolution>; }