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:: solve:: { Goal , NoSolution , SolverMode } ;
4
5
use rustc_middle:: traits:: ObligationCause ;
5
6
use rustc_middle:: ty:: fold:: TypeFoldable ;
6
7
use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
7
- use rustc_span:: DUMMY_SP ;
8
+ use rustc_span:: { ErrorGuaranteed , DUMMY_SP } ;
9
+ use rustc_type_ir:: relate:: combine:: PredicateEmittingRelation ;
8
10
use rustc_type_ir:: relate:: Relate ;
9
11
use rustc_type_ir:: InferCtxtLike ;
10
12
11
13
use super :: { BoundRegionConversionTime , InferCtxt , SubregionOrigin } ;
14
+ use crate :: infer:: RelateResult ;
12
15
13
16
impl < ' tcx > InferCtxtLike for InferCtxt < ' tcx > {
14
17
type Interner = TyCtxt < ' tcx > ;
@@ -155,6 +158,10 @@ impl<'tcx> InferCtxtLike for InferCtxt<'tcx> {
155
158
self . shallow_resolve ( ty)
156
159
}
157
160
161
+ fn shallow_resolve_const ( & self , ct : ty:: Const < ' tcx > ) -> ty:: Const < ' tcx > {
162
+ self . shallow_resolve_const ( ct)
163
+ }
164
+
158
165
fn resolve_vars_if_possible < T > ( & self , value : T ) -> T
159
166
where
160
167
T : TypeFoldable < TyCtxt < ' tcx > > ,
@@ -167,10 +174,96 @@ impl<'tcx> InferCtxtLike for InferCtxt<'tcx> {
167
174
}
168
175
169
176
fn sub_regions ( & self , sub : ty:: Region < ' tcx > , sup : ty:: Region < ' tcx > ) {
170
- self . sub_regions ( SubregionOrigin :: RelateRegionParamBound ( DUMMY_SP ) , sub, sup)
177
+ self . inner . borrow_mut ( ) . unwrap_region_constraints ( ) . make_subregion (
178
+ SubregionOrigin :: RelateRegionParamBound ( DUMMY_SP ) ,
179
+ sub,
180
+ sup,
181
+ ) ;
182
+ }
183
+
184
+ fn equate_regions ( & self , a : ty:: Region < ' tcx > , b : ty:: Region < ' tcx > ) {
185
+ self . inner . borrow_mut ( ) . unwrap_region_constraints ( ) . make_eqregion (
186
+ SubregionOrigin :: RelateRegionParamBound ( DUMMY_SP ) ,
187
+ a,
188
+ b,
189
+ ) ;
171
190
}
172
191
173
192
fn register_ty_outlives ( & self , ty : Ty < ' tcx > , r : ty:: Region < ' tcx > ) {
174
193
self . register_region_obligation_with_cause ( ty, r, & ObligationCause :: dummy ( ) ) ;
175
194
}
195
+
196
+ fn equate_ty_vids_raw ( & self , a : rustc_type_ir:: TyVid , b : rustc_type_ir:: TyVid ) {
197
+ self . inner . borrow_mut ( ) . type_variables ( ) . equate ( a, b) ;
198
+ }
199
+
200
+ fn equate_int_vids_raw ( & self , a : rustc_type_ir:: IntVid , b : rustc_type_ir:: IntVid ) {
201
+ self . inner . borrow_mut ( ) . int_unification_table ( ) . union ( a, b) ;
202
+ }
203
+
204
+ fn equate_float_vids_raw ( & self , a : rustc_type_ir:: FloatVid , b : rustc_type_ir:: FloatVid ) {
205
+ self . inner . borrow_mut ( ) . float_unification_table ( ) . union ( a, b) ;
206
+ }
207
+
208
+ fn equate_const_vids_raw ( & self , a : rustc_type_ir:: ConstVid , b : rustc_type_ir:: ConstVid ) {
209
+ self . inner . borrow_mut ( ) . const_unification_table ( ) . union ( a, b) ;
210
+ }
211
+
212
+ fn equate_effect_vids_raw ( & self , a : rustc_type_ir:: EffectVid , b : rustc_type_ir:: EffectVid ) {
213
+ self . inner . borrow_mut ( ) . effect_unification_table ( ) . union ( a, b) ;
214
+ }
215
+
216
+ fn instantiate_ty_var_raw < R : PredicateEmittingRelation < Self > > (
217
+ & self ,
218
+ relation : & mut R ,
219
+ target_is_expected : bool ,
220
+ target_vid : rustc_type_ir:: TyVid ,
221
+ instantiation_variance : rustc_type_ir:: Variance ,
222
+ source_ty : Ty < ' tcx > ,
223
+ ) -> RelateResult < ' tcx , ( ) > {
224
+ self . instantiate_ty_var (
225
+ relation,
226
+ target_is_expected,
227
+ target_vid,
228
+ instantiation_variance,
229
+ source_ty,
230
+ )
231
+ }
232
+
233
+ fn instantiate_int_var_raw (
234
+ & self ,
235
+ vid : rustc_type_ir:: IntVid ,
236
+ value : rustc_type_ir:: IntVarValue ,
237
+ ) {
238
+ self . inner . borrow_mut ( ) . int_unification_table ( ) . union_value ( vid, value) ;
239
+ }
240
+
241
+ fn instantiate_float_var_raw (
242
+ & self ,
243
+ vid : rustc_type_ir:: FloatVid ,
244
+ value : rustc_type_ir:: FloatVarValue ,
245
+ ) {
246
+ self . inner . borrow_mut ( ) . float_unification_table ( ) . union_value ( vid, value) ;
247
+ }
248
+
249
+ fn instantiate_effect_var_raw ( & self , vid : rustc_type_ir:: EffectVid , value : ty:: Const < ' tcx > ) {
250
+ self . inner
251
+ . borrow_mut ( )
252
+ . effect_unification_table ( )
253
+ . union_value ( vid, EffectVarValue :: Known ( value) ) ;
254
+ }
255
+
256
+ fn instantiate_const_var_raw < R : PredicateEmittingRelation < Self > > (
257
+ & self ,
258
+ relation : & mut R ,
259
+ target_is_expected : bool ,
260
+ target_vid : rustc_type_ir:: ConstVid ,
261
+ source_ct : ty:: Const < ' tcx > ,
262
+ ) -> RelateResult < ' tcx , ( ) > {
263
+ self . instantiate_const_var ( relation, target_is_expected, target_vid, source_ct)
264
+ }
265
+
266
+ fn set_tainted_by_errors ( & self , e : ErrorGuaranteed ) {
267
+ self . set_tainted_by_errors ( e)
268
+ }
176
269
}
0 commit comments