@@ -4,15 +4,15 @@ use rustc_hir::def_id::LocalDefId;
4
4
use rustc_hir:: OpaqueTyOrigin ;
5
5
use rustc_infer:: infer:: TyCtxtInferExt as _;
6
6
use rustc_infer:: infer:: { DefiningAnchor , InferCtxt } ;
7
- use rustc_infer:: traits:: { Obligation , ObligationCause , TraitEngine } ;
7
+ use rustc_infer:: traits:: { Obligation , ObligationCause } ;
8
8
use rustc_middle:: ty:: subst:: { GenericArgKind , InternalSubsts } ;
9
9
use rustc_middle:: ty:: visit:: TypeVisitable ;
10
10
use rustc_middle:: ty:: {
11
11
self , OpaqueHiddenType , OpaqueTypeKey , ToPredicate , Ty , TyCtxt , TypeFoldable ,
12
12
} ;
13
13
use rustc_span:: Span ;
14
14
use rustc_trait_selection:: traits:: error_reporting:: TypeErrCtxtExt as _;
15
- use rustc_trait_selection:: traits:: TraitEngineExt as _ ;
15
+ use rustc_trait_selection:: traits:: ObligationCtxt ;
16
16
17
17
use super :: RegionInferenceContext ;
18
18
@@ -252,48 +252,45 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
252
252
// type-alias-impl-trait/issue-67844-nested-opaque.rs
253
253
let infcx =
254
254
self . tcx . infer_ctxt ( ) . with_opaque_type_inference ( DefiningAnchor :: Bubble ) . build ( ) ;
255
+ let ocx = ObligationCtxt :: new ( & infcx) ;
255
256
// Require the hidden type to be well-formed with only the generics of the opaque type.
256
257
// Defining use functions may have more bounds than the opaque type, which is ok, as long as the
257
258
// hidden type is well formed even without those bounds.
258
259
let predicate = ty:: Binder :: dummy ( ty:: PredicateKind :: WellFormed ( definition_ty. into ( ) ) )
259
260
. to_predicate ( infcx. tcx ) ;
260
- let mut fulfillment_cx = <dyn TraitEngine < ' tcx > >:: new ( infcx. tcx ) ;
261
261
262
262
let id_substs = InternalSubsts :: identity_for_item ( self . tcx , def_id. to_def_id ( ) ) ;
263
263
264
264
// Require that the hidden type actually fulfills all the bounds of the opaque type, even without
265
265
// the bounds that the function supplies.
266
266
let opaque_ty = self . tcx . mk_opaque ( def_id. to_def_id ( ) , id_substs) ;
267
- match infcx
268
- . at ( & ObligationCause :: misc ( instantiated_ty. span , body_id) , param_env)
269
- . eq ( opaque_ty, definition_ty)
270
- {
271
- Ok ( infer_ok) => {
272
- for obligation in infer_ok. obligations {
273
- fulfillment_cx. register_predicate_obligation ( & infcx, obligation) ;
274
- }
275
- }
276
- Err ( err) => {
277
- infcx
278
- . err_ctxt ( )
279
- . report_mismatched_types (
280
- & ObligationCause :: misc ( instantiated_ty. span , body_id) ,
281
- opaque_ty,
282
- definition_ty,
283
- err,
284
- )
285
- . emit ( ) ;
286
- }
267
+ if let Err ( err) = ocx. eq (
268
+ & ObligationCause :: misc ( instantiated_ty. span , body_id) ,
269
+ param_env,
270
+ opaque_ty,
271
+ definition_ty,
272
+ ) {
273
+ infcx
274
+ . err_ctxt ( )
275
+ . report_mismatched_types (
276
+ & ObligationCause :: misc ( instantiated_ty. span , body_id) ,
277
+ opaque_ty,
278
+ definition_ty,
279
+ err,
280
+ )
281
+ . emit ( ) ;
287
282
}
288
283
289
- fulfillment_cx. register_predicate_obligation (
290
- & infcx,
291
- Obligation :: misc ( instantiated_ty. span , body_id, param_env, predicate) ,
292
- ) ;
284
+ ocx. register_obligation ( Obligation :: misc (
285
+ instantiated_ty. span ,
286
+ body_id,
287
+ param_env,
288
+ predicate,
289
+ ) ) ;
293
290
294
291
// Check that all obligations are satisfied by the implementation's
295
292
// version.
296
- let errors = fulfillment_cx . select_all_or_error ( & infcx ) ;
293
+ let errors = ocx . select_all_or_error ( ) ;
297
294
298
295
// This is still required for many(half of the tests in ui/type-alias-impl-trait)
299
296
// tests to pass
0 commit comments