11///! Definition of `InferCtxtLike` from the librarified type layer.
22use rustc_hir:: def_id:: { DefId , LocalDefId } ;
3+ use rustc_middle:: infer:: unify_key:: EffectVarValue ;
34use rustc_middle:: traits:: ObligationCause ;
45use rustc_middle:: traits:: solve:: { Goal , NoSolution , SolverMode } ;
56use rustc_middle:: ty:: fold:: TypeFoldable ;
7+ use rustc_middle:: ty:: relate:: combine:: PredicateEmittingRelation ;
8+ use rustc_middle:: ty:: relate:: { Relate , RelateResult } ;
69use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
7- use rustc_span:: DUMMY_SP ;
8- use rustc_type_ir:: InferCtxtLike ;
9- use rustc_type_ir:: relate:: Relate ;
10+ use rustc_span:: { DUMMY_SP , ErrorGuaranteed } ;
1011
1112use super :: { BoundRegionConversionTime , InferCtxt , SubregionOrigin } ;
1213
13- impl < ' tcx > InferCtxtLike for InferCtxt < ' tcx > {
14+ impl < ' tcx > rustc_type_ir :: InferCtxtLike for InferCtxt < ' tcx > {
1415 type Interner = TyCtxt < ' tcx > ;
1516
1617 fn cx ( & self ) -> TyCtxt < ' tcx > {
1718 self . tcx
1819 }
1920
21+ fn next_trait_solver ( & self ) -> bool {
22+ self . next_trait_solver
23+ }
24+
2025 fn solver_mode ( & self ) -> ty:: solve:: SolverMode {
2126 match self . intercrate {
2227 true => SolverMode :: Coherence ,
@@ -131,6 +136,59 @@ impl<'tcx> InferCtxtLike for InferCtxt<'tcx> {
131136 self . enter_forall ( value, f)
132137 }
133138
139+ fn equate_int_vids_raw ( & self , a : rustc_type_ir:: IntVid , b : rustc_type_ir:: IntVid ) {
140+ self . inner . borrow_mut ( ) . int_unification_table ( ) . union ( a, b) ;
141+ }
142+
143+ fn equate_float_vids_raw ( & self , a : rustc_type_ir:: FloatVid , b : rustc_type_ir:: FloatVid ) {
144+ self . inner . borrow_mut ( ) . float_unification_table ( ) . union ( a, b) ;
145+ }
146+
147+ fn equate_const_vids_raw ( & self , a : rustc_type_ir:: ConstVid , b : rustc_type_ir:: ConstVid ) {
148+ self . inner . borrow_mut ( ) . const_unification_table ( ) . union ( a, b) ;
149+ }
150+
151+ fn equate_effect_vids_raw ( & self , a : rustc_type_ir:: EffectVid , b : rustc_type_ir:: EffectVid ) {
152+ self . inner . borrow_mut ( ) . effect_unification_table ( ) . union ( a, b) ;
153+ }
154+
155+ fn instantiate_int_var_raw (
156+ & self ,
157+ vid : rustc_type_ir:: IntVid ,
158+ value : rustc_type_ir:: IntVarValue ,
159+ ) {
160+ self . inner . borrow_mut ( ) . int_unification_table ( ) . union_value ( vid, value) ;
161+ }
162+
163+ fn instantiate_float_var_raw (
164+ & self ,
165+ vid : rustc_type_ir:: FloatVid ,
166+ value : rustc_type_ir:: FloatVarValue ,
167+ ) {
168+ self . inner . borrow_mut ( ) . float_unification_table ( ) . union_value ( vid, value) ;
169+ }
170+
171+ fn instantiate_effect_var_raw ( & self , vid : rustc_type_ir:: EffectVid , value : ty:: Const < ' tcx > ) {
172+ self . inner
173+ . borrow_mut ( )
174+ . effect_unification_table ( )
175+ . union_value ( vid, EffectVarValue :: Known ( value) ) ;
176+ }
177+
178+ fn instantiate_const_var_raw < R : PredicateEmittingRelation < Self > > (
179+ & self ,
180+ relation : & mut R ,
181+ target_is_expected : bool ,
182+ target_vid : rustc_type_ir:: ConstVid ,
183+ source_ct : ty:: Const < ' tcx > ,
184+ ) -> RelateResult < ' tcx , ( ) > {
185+ self . instantiate_const_var ( relation, target_is_expected, target_vid, source_ct)
186+ }
187+
188+ fn set_tainted_by_errors ( & self , e : ErrorGuaranteed ) {
189+ self . set_tainted_by_errors ( e)
190+ }
191+
134192 fn relate < T : Relate < TyCtxt < ' tcx > > > (
135193 & self ,
136194 param_env : ty:: ParamEnv < ' tcx > ,
@@ -154,6 +212,9 @@ impl<'tcx> InferCtxtLike for InferCtxt<'tcx> {
154212 fn shallow_resolve ( & self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
155213 self . shallow_resolve ( ty)
156214 }
215+ fn shallow_resolve_const ( & self , ct : ty:: Const < ' tcx > ) -> ty:: Const < ' tcx > {
216+ self . shallow_resolve_const ( ct)
217+ }
157218
158219 fn resolve_vars_if_possible < T > ( & self , value : T ) -> T
159220 where
0 commit comments