@@ -5,14 +5,14 @@ use rustc_infer::infer::region_constraints::Constraint;
5
5
use rustc_infer:: infer:: region_constraints:: RegionConstraintData ;
6
6
use rustc_infer:: infer:: RegionVariableOrigin ;
7
7
use rustc_infer:: infer:: { InferCtxt , RegionResolutionError , SubregionOrigin , TyCtxtInferExt as _} ;
8
- use rustc_infer:: traits:: { Normalized , ObligationCause , TraitEngine , TraitEngineExt } ;
8
+ use rustc_infer:: traits:: ObligationCause ;
9
9
use rustc_middle:: ty:: error:: TypeError ;
10
10
use rustc_middle:: ty:: RegionVid ;
11
11
use rustc_middle:: ty:: UniverseIndex ;
12
12
use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeFoldable } ;
13
13
use rustc_span:: Span ;
14
14
use rustc_trait_selection:: traits:: query:: type_op;
15
- use rustc_trait_selection:: traits:: { SelectionContext , TraitEngineExt as _ } ;
15
+ use rustc_trait_selection:: traits:: ObligationCtxt ;
16
16
use rustc_traits:: { type_op_ascribe_user_type_with_span, type_op_prove_predicate_with_cause} ;
17
17
18
18
use std:: fmt;
@@ -240,9 +240,9 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
240
240
) -> Option < DiagnosticBuilder < ' tcx , ErrorGuaranteed > > {
241
241
let ( ref infcx, key, _) =
242
242
mbcx. infcx . tcx . infer_ctxt ( ) . build_with_canonical ( cause. span , & self . canonical_query ) ;
243
- let mut fulfill_cx = < dyn TraitEngine < ' _ > > :: new ( infcx. tcx ) ;
244
- type_op_prove_predicate_with_cause ( infcx , & mut * fulfill_cx , key, cause) ;
245
- try_extract_error_from_fulfill_cx ( fulfill_cx , infcx , placeholder_region, error_region)
243
+ let ocx = ObligationCtxt :: new ( infcx) ;
244
+ type_op_prove_predicate_with_cause ( & ocx , key, cause) ;
245
+ try_extract_error_from_fulfill_cx ( & ocx , placeholder_region, error_region)
246
246
}
247
247
}
248
248
@@ -281,9 +281,7 @@ where
281
281
) -> Option < DiagnosticBuilder < ' tcx , ErrorGuaranteed > > {
282
282
let ( ref infcx, key, _) =
283
283
mbcx. infcx . tcx . infer_ctxt ( ) . build_with_canonical ( cause. span , & self . canonical_query ) ;
284
- let mut fulfill_cx = <dyn TraitEngine < ' _ > >:: new ( infcx. tcx ) ;
285
-
286
- let mut selcx = SelectionContext :: new ( infcx) ;
284
+ let ocx = ObligationCtxt :: new ( infcx) ;
287
285
288
286
// FIXME(lqd): Unify and de-duplicate the following with the actual
289
287
// `rustc_traits::type_op::type_op_normalize` query to allow the span we need in the
@@ -292,11 +290,9 @@ where
292
290
// to normalize the `nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs` test. Check
293
291
// after #85499 lands to see if its fixes have erased this difference.
294
292
let ( param_env, value) = key. into_parts ( ) ;
295
- let Normalized { value : _, obligations } =
296
- rustc_trait_selection:: traits:: normalize ( & mut selcx, param_env, cause, value. value ) ;
297
- fulfill_cx. register_predicate_obligations ( infcx, obligations) ;
293
+ let _ = ocx. normalize ( cause, param_env, value. value ) ;
298
294
299
- try_extract_error_from_fulfill_cx ( fulfill_cx , infcx , placeholder_region, error_region)
295
+ try_extract_error_from_fulfill_cx ( & ocx , placeholder_region, error_region)
300
296
}
301
297
}
302
298
@@ -329,9 +325,9 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
329
325
) -> Option < DiagnosticBuilder < ' tcx , ErrorGuaranteed > > {
330
326
let ( ref infcx, key, _) =
331
327
mbcx. infcx . tcx . infer_ctxt ( ) . build_with_canonical ( cause. span , & self . canonical_query ) ;
332
- let mut fulfill_cx = < dyn TraitEngine < ' _ > > :: new ( infcx. tcx ) ;
333
- type_op_ascribe_user_type_with_span ( infcx , & mut * fulfill_cx , key, Some ( cause. span ) ) . ok ( ) ?;
334
- try_extract_error_from_fulfill_cx ( fulfill_cx , infcx , placeholder_region, error_region)
328
+ let ocx = ObligationCtxt :: new ( infcx) ;
329
+ type_op_ascribe_user_type_with_span ( & ocx , key, Some ( cause. span ) ) . ok ( ) ?;
330
+ try_extract_error_from_fulfill_cx ( & ocx , placeholder_region, error_region)
335
331
}
336
332
}
337
333
@@ -372,25 +368,24 @@ impl<'tcx> TypeOpInfo<'tcx> for crate::type_check::InstantiateOpaqueType<'tcx> {
372
368
}
373
369
}
374
370
375
- #[ instrument( skip( fulfill_cx , infcx ) , level = "debug" ) ]
371
+ #[ instrument( skip( ocx ) , level = "debug" ) ]
376
372
fn try_extract_error_from_fulfill_cx < ' tcx > (
377
- mut fulfill_cx : Box < dyn TraitEngine < ' tcx > + ' tcx > ,
378
- infcx : & InferCtxt < ' tcx > ,
373
+ ocx : & ObligationCtxt < ' _ , ' tcx > ,
379
374
placeholder_region : ty:: Region < ' tcx > ,
380
375
error_region : Option < ty:: Region < ' tcx > > ,
381
376
) -> Option < DiagnosticBuilder < ' tcx , ErrorGuaranteed > > {
382
377
// We generally shouldn't have errors here because the query was
383
378
// already run, but there's no point using `delay_span_bug`
384
379
// when we're going to emit an error here anyway.
385
- let _errors = fulfill_cx . select_all_or_error ( infcx ) ;
386
- let region_constraints = infcx. with_region_constraints ( |r| r. clone ( ) ) ;
380
+ let _errors = ocx . select_all_or_error ( ) ;
381
+ let region_constraints = ocx . infcx . with_region_constraints ( |r| r. clone ( ) ) ;
387
382
try_extract_error_from_region_constraints (
388
- infcx,
383
+ ocx . infcx ,
389
384
placeholder_region,
390
385
error_region,
391
386
& region_constraints,
392
- |vid| infcx. region_var_origin ( vid) ,
393
- |vid| infcx. universe_of_region ( infcx. tcx . mk_region ( ty:: ReVar ( vid) ) ) ,
387
+ |vid| ocx . infcx . region_var_origin ( vid) ,
388
+ |vid| ocx . infcx . universe_of_region ( ocx . infcx . tcx . mk_region ( ty:: ReVar ( vid) ) ) ,
394
389
)
395
390
}
396
391
0 commit comments