@@ -15,7 +15,7 @@ use rustc_middle::ty::{self, suggest_constraining_type_params, Ty, TyCtxt, TypeV
15
15
use rustc_trait_selection:: traits:: error_reporting:: InferCtxtExt ;
16
16
use rustc_trait_selection:: traits:: misc:: { can_type_implement_copy, CopyImplementationError } ;
17
17
use rustc_trait_selection:: traits:: predicate_for_trait_def;
18
- use rustc_trait_selection:: traits:: { self , ObligationCause , TraitEngine , TraitEngineExt } ;
18
+ use rustc_trait_selection:: traits:: { self , ObligationCause } ;
19
19
use std:: collections:: BTreeMap ;
20
20
21
21
pub fn check_trait ( tcx : TyCtxt < ' _ > , trait_def_id : DefId ) {
@@ -109,15 +109,13 @@ fn visit_implementation_of_copy(tcx: TyCtxt<'_>, impl_did: LocalDefId) {
109
109
// it is not immediately clear why Copy is not implemented for a field, since
110
110
// all we point at is the field itself.
111
111
tcx. infer_ctxt ( ) . ignoring_regions ( ) . enter ( |infcx| {
112
- let mut fulfill_cx = <dyn TraitEngine < ' _ > >:: new ( tcx) ;
113
- fulfill_cx. register_bound (
112
+ for error in traits:: fully_solve_bound (
114
113
& infcx,
114
+ traits:: ObligationCause :: dummy_with_span ( field_ty_span) ,
115
115
param_env,
116
116
ty,
117
117
tcx. lang_items ( ) . copy_trait ( ) . unwrap ( ) ,
118
- traits:: ObligationCause :: dummy_with_span ( field_ty_span) ,
119
- ) ;
120
- for error in fulfill_cx. select_all_or_error ( & infcx) {
118
+ ) {
121
119
let error_predicate = error. obligation . predicate ;
122
120
// Only note if it's not the root obligation, otherwise it's trivial and
123
121
// should be self-explanatory (i.e. a field literally doesn't implement Copy).
@@ -315,24 +313,20 @@ fn visit_implementation_of_dispatch_from_dyn<'tcx>(tcx: TyCtxt<'tcx>, impl_did:
315
313
) )
316
314
. emit ( ) ;
317
315
} else {
318
- let mut fulfill_cx = <dyn TraitEngine < ' _ > >:: new ( infcx. tcx ) ;
319
-
320
- for field in coerced_fields {
321
- let predicate = predicate_for_trait_def (
322
- tcx,
323
- param_env,
324
- cause. clone ( ) ,
325
- dispatch_from_dyn_trait,
326
- 0 ,
327
- field. ty ( tcx, substs_a) ,
328
- & [ field. ty ( tcx, substs_b) . into ( ) ] ,
329
- ) ;
330
-
331
- fulfill_cx. register_predicate_obligation ( & infcx, predicate) ;
332
- }
333
-
334
- // Check that all transitive obligations are satisfied.
335
- let errors = fulfill_cx. select_all_or_error ( & infcx) ;
316
+ let errors = traits:: fully_solve_obligations (
317
+ & infcx,
318
+ coerced_fields. into_iter ( ) . map ( |field| {
319
+ predicate_for_trait_def (
320
+ tcx,
321
+ param_env,
322
+ cause. clone ( ) ,
323
+ dispatch_from_dyn_trait,
324
+ 0 ,
325
+ field. ty ( tcx, substs_a) ,
326
+ & [ field. ty ( tcx, substs_b) . into ( ) ] ,
327
+ )
328
+ } ) ,
329
+ ) ;
336
330
if !errors. is_empty ( ) {
337
331
infcx. report_fulfillment_errors ( & errors, None , false ) ;
338
332
}
@@ -573,8 +567,6 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn
573
567
}
574
568
} ;
575
569
576
- let mut fulfill_cx = <dyn TraitEngine < ' _ > >:: new ( infcx. tcx ) ;
577
-
578
570
// Register an obligation for `A: Trait<B>`.
579
571
let cause = traits:: ObligationCause :: misc ( span, impl_hir_id) ;
580
572
let predicate = predicate_for_trait_def (
@@ -586,10 +578,7 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: DefId) -> CoerceUn
586
578
source,
587
579
& [ target. into ( ) ] ,
588
580
) ;
589
- fulfill_cx. register_predicate_obligation ( & infcx, predicate) ;
590
-
591
- // Check that all transitive obligations are satisfied.
592
- let errors = fulfill_cx. select_all_or_error ( & infcx) ;
581
+ let errors = traits:: fully_solve_obligation ( & infcx, predicate) ;
593
582
if !errors. is_empty ( ) {
594
583
infcx. report_fulfillment_errors ( & errors, None , false ) ;
595
584
}
0 commit comments