use std::ops::Deref; use rustc_type_ir::fold::TypeFoldable; use rustc_type_ir::solve::{Certainty, Goal, NoSolution}; use rustc_type_ir::{self as ty, InferCtxtLike, Interner}; pub trait SolverDelegate: Deref::Infcx> + Sized { type Infcx: InferCtxtLike::Interner>; type Interner: Interner; fn cx(&self) -> Self::Interner { (**self).cx() } type Span: Copy; fn build_with_canonical( cx: Self::Interner, canonical: &ty::CanonicalQueryInput, ) -> (Self, V, ty::CanonicalVarValues) where V: TypeFoldable; fn fresh_var_for_kind_with_span( &self, arg: ::GenericArg, span: Self::Span, ) -> ::GenericArg; // FIXME: Uplift the leak check into this crate. fn leak_check(&self, max_input_universe: ty::UniverseIndex) -> Result<(), NoSolution>; fn evaluate_const( &self, param_env: ::ParamEnv, uv: ty::UnevaluatedConst, ) -> Option<::Const>; // 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 fetch_eligible_assoc_item( &self, goal_trait_ref: ty::TraitRef, trait_assoc_def_id: ::DefId, impl_def_id: ::DefId, ) -> Result< Option<::DefId>, ::ErrorGuaranteed, >; fn is_transmutable( &self, param_env: ::ParamEnv, dst: ::Ty, src: ::Ty, assume: ::Const, ) -> Result; }