@@ -20,6 +20,7 @@ use rustc_middle::ty::{
20
20
} ;
21
21
use rustc_middle:: { bug, span_bug} ;
22
22
use rustc_span:: def_id:: DefId ;
23
+ use rustc_span:: ErrorGuaranteed ;
23
24
24
25
use crate :: traits:: normalize:: { normalize_with_depth, normalize_with_depth_to} ;
25
26
use crate :: traits:: util:: { self , closure_trait_ref_and_return_type} ;
@@ -61,7 +62,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
61
62
}
62
63
63
64
ImplCandidate ( impl_def_id) => {
64
- ImplSource :: UserDefined ( self . confirm_impl_candidate ( obligation, impl_def_id) )
65
+ ImplSource :: UserDefined ( self . confirm_impl_candidate ( obligation, impl_def_id) ? )
65
66
}
66
67
67
68
AutoImplCandidate => {
@@ -116,7 +117,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
116
117
}
117
118
118
119
TraitAliasCandidate => {
119
- let data = self . confirm_trait_alias_candidate ( obligation) ;
120
+ let data = self . confirm_trait_alias_candidate ( obligation) ? ;
120
121
ImplSource :: Builtin ( BuiltinImplSource :: Misc , data)
121
122
}
122
123
@@ -421,7 +422,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
421
422
422
423
let self_ty = obligation. predicate . self_ty ( ) . map_bound ( |ty| self . infcx . shallow_resolve ( ty) ) ;
423
424
let types = self . constituent_types_for_ty ( self_ty) ?;
424
- Ok ( self . vtable_auto_impl ( obligation, obligation. predicate . def_id ( ) , types) )
425
+ Ok ( self . vtable_auto_impl ( obligation, obligation. predicate . def_id ( ) , types) ? )
425
426
}
426
427
427
428
/// See `confirm_auto_impl_candidate`.
@@ -430,21 +431,21 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
430
431
obligation : & PolyTraitObligation < ' tcx > ,
431
432
trait_def_id : DefId ,
432
433
nested : ty:: Binder < ' tcx , Vec < Ty < ' tcx > > > ,
433
- ) -> Vec < PredicateObligation < ' tcx > > {
434
+ ) -> Result < Vec < PredicateObligation < ' tcx > > , ErrorGuaranteed > {
434
435
debug ! ( ?nested, "vtable_auto_impl" ) ;
435
436
ensure_sufficient_stack ( || {
436
437
let cause = obligation. derived_cause ( ObligationCauseCode :: BuiltinDerived ) ;
437
438
438
439
let poly_trait_ref = obligation. predicate . to_poly_trait_ref ( ) ;
439
440
let trait_ref = self . infcx . enter_forall_and_leak_universe ( poly_trait_ref) ;
440
- let trait_obligations: Vec < PredicateObligation < ' _ > > = self . impl_or_trait_obligations (
441
+ let trait_obligations = self . impl_or_trait_obligations (
441
442
& cause,
442
443
obligation. recursion_depth + 1 ,
443
444
obligation. param_env ,
444
445
trait_def_id,
445
446
trait_ref. args ,
446
447
obligation. predicate ,
447
- ) ;
448
+ ) ? ;
448
449
449
450
let mut obligations = self . collect_predicates_for_types (
450
451
obligation. param_env ,
@@ -460,15 +461,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
460
461
461
462
debug ! ( ?obligations, "vtable_auto_impl" ) ;
462
463
463
- obligations
464
+ Ok ( obligations)
464
465
} )
465
466
}
466
467
467
468
fn confirm_impl_candidate (
468
469
& mut self ,
469
470
obligation : & PolyTraitObligation < ' tcx > ,
470
471
impl_def_id : DefId ,
471
- ) -> ImplSourceUserDefinedData < ' tcx , PredicateObligation < ' tcx > > {
472
+ ) -> Result < ImplSourceUserDefinedData < ' tcx , PredicateObligation < ' tcx > > , ErrorGuaranteed > {
472
473
debug ! ( ?obligation, ?impl_def_id, "confirm_impl_candidate" ) ;
473
474
474
475
// First, create the generic parameters by matching the impl again,
@@ -495,7 +496,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
495
496
recursion_depth : usize ,
496
497
param_env : ty:: ParamEnv < ' tcx > ,
497
498
parent_trait_pred : ty:: Binder < ' tcx , ty:: TraitPredicate < ' tcx > > ,
498
- ) -> ImplSourceUserDefinedData < ' tcx , PredicateObligation < ' tcx > > {
499
+ ) -> Result < ImplSourceUserDefinedData < ' tcx , PredicateObligation < ' tcx > > , ErrorGuaranteed > {
499
500
debug ! ( ?impl_def_id, ?args, ?recursion_depth, "vtable_impl" ) ;
500
501
501
502
let mut impl_obligations = self . impl_or_trait_obligations (
@@ -505,7 +506,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
505
506
impl_def_id,
506
507
args. value ,
507
508
parent_trait_pred,
508
- ) ;
509
+ ) ? ;
509
510
510
511
debug ! ( ?impl_obligations, "vtable_impl" ) ;
511
512
@@ -516,7 +517,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
516
517
// e.g., `impl<U: Tr, V: Iterator<Item=U>> Foo<<U as Tr>::T> for V`
517
518
impl_obligations. extend ( args. obligations ) ;
518
519
519
- ImplSourceUserDefinedData { impl_def_id, args : args. value , nested : impl_obligations }
520
+ Ok ( ImplSourceUserDefinedData { impl_def_id, args : args. value , nested : impl_obligations } )
520
521
}
521
522
522
523
fn confirm_object_candidate (
@@ -737,7 +738,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
737
738
fn confirm_trait_alias_candidate (
738
739
& mut self ,
739
740
obligation : & PolyTraitObligation < ' tcx > ,
740
- ) -> Vec < PredicateObligation < ' tcx > > {
741
+ ) -> Result < Vec < PredicateObligation < ' tcx > > , ErrorGuaranteed > {
741
742
debug ! ( ?obligation, "confirm_trait_alias_candidate" ) ;
742
743
743
744
let predicate = self . infcx . enter_forall_and_leak_universe ( obligation. predicate ) ;
@@ -1377,7 +1378,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1377
1378
new_obligation. param_env ,
1378
1379
obligation. predicate ,
1379
1380
)
1380
- } ) ;
1381
+ } ) ? ;
1381
1382
nested. extend ( obligations. nested ) ;
1382
1383
}
1383
1384
0 commit comments