1
1
///! Definition of `InferCtxtLike` from the librarified type layer.
2
2
use rustc_hir:: def_id:: { DefId , LocalDefId } ;
3
+ use rustc_middle:: infer:: unify_key:: EffectVarValue ;
3
4
use rustc_middle:: traits:: ObligationCause ;
4
5
use rustc_middle:: traits:: solve:: { Goal , NoSolution , SolverMode } ;
5
6
use rustc_middle:: ty:: fold:: TypeFoldable ;
7
+ use rustc_middle:: ty:: relate:: combine:: PredicateEmittingRelation ;
8
+ use rustc_middle:: ty:: relate:: { Relate , RelateResult } ;
6
9
use 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 } ;
10
11
11
12
use super :: { BoundRegionConversionTime , InferCtxt , SubregionOrigin } ;
12
13
13
- impl < ' tcx > InferCtxtLike for InferCtxt < ' tcx > {
14
+ impl < ' tcx > rustc_type_ir :: InferCtxtLike for InferCtxt < ' tcx > {
14
15
type Interner = TyCtxt < ' tcx > ;
15
16
16
17
fn cx ( & self ) -> TyCtxt < ' tcx > {
17
18
self . tcx
18
19
}
19
20
21
+ fn next_trait_solver ( & self ) -> bool {
22
+ self . next_trait_solver
23
+ }
24
+
20
25
fn solver_mode ( & self ) -> ty:: solve:: SolverMode {
21
26
match self . intercrate {
22
27
true => SolverMode :: Coherence ,
@@ -131,6 +136,59 @@ impl<'tcx> InferCtxtLike for InferCtxt<'tcx> {
131
136
self . enter_forall ( value, f)
132
137
}
133
138
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
+
134
192
fn relate < T : Relate < TyCtxt < ' tcx > > > (
135
193
& self ,
136
194
param_env : ty:: ParamEnv < ' tcx > ,
@@ -154,6 +212,9 @@ impl<'tcx> InferCtxtLike for InferCtxt<'tcx> {
154
212
fn shallow_resolve ( & self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
155
213
self . shallow_resolve ( ty)
156
214
}
215
+ fn shallow_resolve_const ( & self , ct : ty:: Const < ' tcx > ) -> ty:: Const < ' tcx > {
216
+ self . shallow_resolve_const ( ct)
217
+ }
157
218
158
219
fn resolve_vars_if_possible < T > ( & self , value : T ) -> T
159
220
where
0 commit comments