@@ -20,8 +20,8 @@ use super::ObligationCauseCode;
20
20
use super :: Selection ;
21
21
use super :: SelectionResult ;
22
22
use super :: TraitQueryMode ;
23
+ use super :: { ErrorReporting , Overflow , SelectionError , Unimplemented } ;
23
24
use super :: { ObligationCause , PredicateObligation , TraitObligation } ;
24
- use super :: { Overflow , SelectionError , Unimplemented } ;
25
25
26
26
use crate :: infer:: { InferCtxt , InferOk , TypeFreshener } ;
27
27
use crate :: traits:: error_reporting:: InferCtxtExt ;
@@ -900,7 +900,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
900
900
match self . candidate_from_obligation ( stack) {
901
901
Ok ( Some ( c) ) => self . evaluate_candidate ( stack, & c) ,
902
902
Ok ( None ) => Ok ( EvaluatedToAmbig ) ,
903
- Err ( Overflow ) => Err ( OverflowError ) ,
903
+ Err ( Overflow ) => Err ( OverflowError :: Cannonical ) ,
904
+ Err ( ErrorReporting ) => Err ( OverflowError :: ErrorReporting ) ,
904
905
Err ( ..) => Ok ( EvaluatedToErr ) ,
905
906
}
906
907
}
@@ -1057,10 +1058,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1057
1058
if !self . infcx . tcx . recursion_limit ( ) . value_within_limit ( depth) {
1058
1059
match self . query_mode {
1059
1060
TraitQueryMode :: Standard => {
1061
+ if self . infcx . is_tainted_by_errors ( ) {
1062
+ return Err ( OverflowError :: ErrorReporting ) ;
1063
+ }
1060
1064
self . infcx . report_overflow_error ( error_obligation, true ) ;
1061
1065
}
1062
1066
TraitQueryMode :: Canonical => {
1063
- return Err ( OverflowError ) ;
1067
+ return Err ( OverflowError :: Cannonical ) ;
1064
1068
}
1065
1069
}
1066
1070
}
0 commit comments