@@ -20,8 +20,8 @@ use super::ObligationCauseCode;
2020use super :: Selection ;
2121use super :: SelectionResult ;
2222use super :: TraitQueryMode ;
23+ use super :: { ErrorReporting , Overflow , SelectionError , Unimplemented } ;
2324use super :: { ObligationCause , PredicateObligation , TraitObligation } ;
24- use super :: { Overflow , SelectionError , Unimplemented } ;
2525
2626use crate :: infer:: { InferCtxt , InferOk , TypeFreshener } ;
2727use crate :: traits:: error_reporting:: InferCtxtExt ;
@@ -900,7 +900,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
900900 match self . candidate_from_obligation ( stack) {
901901 Ok ( Some ( c) ) => self . evaluate_candidate ( stack, & c) ,
902902 Ok ( None ) => Ok ( EvaluatedToAmbig ) ,
903- Err ( Overflow ) => Err ( OverflowError ) ,
903+ Err ( Overflow ) => Err ( OverflowError :: Cannonical ) ,
904+ Err ( ErrorReporting ) => Err ( OverflowError :: ErrorReporting ) ,
904905 Err ( ..) => Ok ( EvaluatedToErr ) ,
905906 }
906907 }
@@ -1057,10 +1058,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10571058 if !self . infcx . tcx . recursion_limit ( ) . value_within_limit ( depth) {
10581059 match self . query_mode {
10591060 TraitQueryMode :: Standard => {
1061+ if self . infcx . is_tainted_by_errors ( ) {
1062+ return Err ( OverflowError :: ErrorReporting ) ;
1063+ }
10601064 self . infcx . report_overflow_error ( error_obligation, true ) ;
10611065 }
10621066 TraitQueryMode :: Canonical => {
1063- return Err ( OverflowError ) ;
1067+ return Err ( OverflowError :: Cannonical ) ;
10641068 }
10651069 }
10661070 }
0 commit comments