@@ -238,20 +238,11 @@ impl<'tcx> TypeOpInfo<'tcx> for PredicateQuery<'tcx> {
238
238
placeholder_region : ty:: Region < ' tcx > ,
239
239
error_region : Option < ty:: Region < ' tcx > > ,
240
240
) -> Option < DiagnosticBuilder < ' tcx , ErrorGuaranteed > > {
241
- mbcx. infcx . tcx . infer_ctxt ( ) . enter_with_canonical (
242
- cause. span ,
243
- & self . canonical_query ,
244
- |ref infcx, key, _| {
245
- let mut fulfill_cx = <dyn TraitEngine < ' _ > >:: new ( infcx. tcx ) ;
246
- type_op_prove_predicate_with_cause ( infcx, & mut * fulfill_cx, key, cause) ;
247
- try_extract_error_from_fulfill_cx (
248
- fulfill_cx,
249
- infcx,
250
- placeholder_region,
251
- error_region,
252
- )
253
- } ,
254
- )
241
+ let ( ref infcx, key, _) =
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)
255
246
}
256
247
}
257
248
@@ -288,37 +279,24 @@ where
288
279
placeholder_region : ty:: Region < ' tcx > ,
289
280
error_region : Option < ty:: Region < ' tcx > > ,
290
281
) -> Option < DiagnosticBuilder < ' tcx , ErrorGuaranteed > > {
291
- mbcx. infcx . tcx . infer_ctxt ( ) . enter_with_canonical (
292
- cause. span ,
293
- & self . canonical_query ,
294
- |ref infcx, key, _| {
295
- let mut fulfill_cx = <dyn TraitEngine < ' _ > >:: new ( infcx. tcx ) ;
296
-
297
- let mut selcx = SelectionContext :: new ( infcx) ;
298
-
299
- // FIXME(lqd): Unify and de-duplicate the following with the actual
300
- // `rustc_traits::type_op::type_op_normalize` query to allow the span we need in the
301
- // `ObligationCause`. The normalization results are currently different between
302
- // `AtExt::normalize` used in the query and `normalize` called below: the former fails
303
- // to normalize the `nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs` test. Check
304
- // after #85499 lands to see if its fixes have erased this difference.
305
- let ( param_env, value) = key. into_parts ( ) ;
306
- let Normalized { value : _, obligations } = rustc_trait_selection:: traits:: normalize (
307
- & mut selcx,
308
- param_env,
309
- cause,
310
- value. value ,
311
- ) ;
312
- fulfill_cx. register_predicate_obligations ( infcx, obligations) ;
313
-
314
- try_extract_error_from_fulfill_cx (
315
- fulfill_cx,
316
- infcx,
317
- placeholder_region,
318
- error_region,
319
- )
320
- } ,
321
- )
282
+ let ( ref infcx, key, _) =
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) ;
287
+
288
+ // FIXME(lqd): Unify and de-duplicate the following with the actual
289
+ // `rustc_traits::type_op::type_op_normalize` query to allow the span we need in the
290
+ // `ObligationCause`. The normalization results are currently different between
291
+ // `AtExt::normalize` used in the query and `normalize` called below: the former fails
292
+ // to normalize the `nll/relate_tys/impl-fn-ignore-binder-via-bottom.rs` test. Check
293
+ // after #85499 lands to see if its fixes have erased this difference.
294
+ 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) ;
298
+
299
+ try_extract_error_from_fulfill_cx ( fulfill_cx, infcx, placeholder_region, error_region)
322
300
}
323
301
}
324
302
@@ -349,21 +327,11 @@ impl<'tcx> TypeOpInfo<'tcx> for AscribeUserTypeQuery<'tcx> {
349
327
placeholder_region : ty:: Region < ' tcx > ,
350
328
error_region : Option < ty:: Region < ' tcx > > ,
351
329
) -> Option < DiagnosticBuilder < ' tcx , ErrorGuaranteed > > {
352
- mbcx. infcx . tcx . infer_ctxt ( ) . enter_with_canonical (
353
- cause. span ,
354
- & self . canonical_query ,
355
- |ref infcx, key, _| {
356
- let mut fulfill_cx = <dyn TraitEngine < ' _ > >:: new ( infcx. tcx ) ;
357
- type_op_ascribe_user_type_with_span ( infcx, & mut * fulfill_cx, key, Some ( cause. span ) )
358
- . ok ( ) ?;
359
- try_extract_error_from_fulfill_cx (
360
- fulfill_cx,
361
- infcx,
362
- placeholder_region,
363
- error_region,
364
- )
365
- } ,
366
- )
330
+ let ( ref infcx, key, _) =
331
+ 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)
367
335
}
368
336
}
369
337
0 commit comments