@@ -25,7 +25,7 @@ use crate::traits::project::ProjectionCacheKeyExt;
2525use crate :: traits:: ProjectionCacheKey ;
2626use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
2727use rustc_data_structures:: stack:: ensure_sufficient_stack;
28- use rustc_errors:: Diagnostic ;
28+ use rustc_errors:: { Diagnostic , ErrorGuaranteed } ;
2929use rustc_hir as hir;
3030use rustc_hir:: def_id:: DefId ;
3131use rustc_infer:: infer:: LateBoundRegionConversionTime ;
@@ -316,11 +316,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
316316 obligation : & TraitObligation < ' tcx > ,
317317 ) -> SelectionResult < ' tcx , Selection < ' tcx > > {
318318 let candidate = match self . select_from_obligation ( obligation) {
319- Err ( SelectionError :: Overflow ) => {
319+ Err ( SelectionError :: Overflow ( OverflowError :: Canonical ) ) => {
320320 // In standard mode, overflow must have been caught and reported
321321 // earlier.
322322 assert ! ( self . query_mode == TraitQueryMode :: Canonical ) ;
323- return Err ( SelectionError :: Overflow ) ;
323+ return Err ( SelectionError :: Overflow ( OverflowError :: Canonical ) ) ;
324324 }
325325 Err ( SelectionError :: Ambiguous ( _) ) => {
326326 return Ok ( None ) ;
@@ -335,9 +335,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
335335 } ;
336336
337337 match self . confirm_candidate ( obligation, candidate) {
338- Err ( SelectionError :: Overflow ) => {
338+ Err ( SelectionError :: Overflow ( OverflowError :: Canonical ) ) => {
339339 assert ! ( self . query_mode == TraitQueryMode :: Canonical ) ;
340- Err ( SelectionError :: Overflow )
340+ Err ( SelectionError :: Overflow ( OverflowError :: Canonical ) )
341341 }
342342 Err ( e) => Err ( e) ,
343343 Ok ( candidate) => {
@@ -954,7 +954,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
954954 Ok ( Some ( c) ) => self . evaluate_candidate ( stack, & c) ,
955955 Err ( SelectionError :: Ambiguous ( _) ) => Ok ( EvaluatedToAmbig ) ,
956956 Ok ( None ) => Ok ( EvaluatedToAmbig ) ,
957- Err ( Overflow ) => Err ( OverflowError :: Canonical ) ,
957+ Err ( Overflow ( OverflowError :: Canonical ) ) => Err ( OverflowError :: Canonical ) ,
958958 Err ( ErrorReporting ) => Err ( OverflowError :: ErrorReporting ) ,
959959 Err ( ..) => Ok ( EvaluatedToErr ) ,
960960 }
@@ -1113,7 +1113,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11131113 match self . query_mode {
11141114 TraitQueryMode :: Standard => {
11151115 if self . infcx . is_tainted_by_errors ( ) {
1116- return Err ( OverflowError :: ErrorReporting ) ;
1116+ return Err ( OverflowError :: Error (
1117+ ErrorGuaranteed :: unchecked_claim_error_was_emitted ( ) ,
1118+ ) ) ;
11171119 }
11181120 self . infcx . report_overflow_error ( error_obligation, true ) ;
11191121 }
@@ -1349,7 +1351,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
13491351 }
13501352
13511353 if self . can_use_global_caches ( param_env) {
1352- if let Err ( Overflow ) = candidate {
1354+ if let Err ( Overflow ( OverflowError :: Canonical ) ) = candidate {
13531355 // Don't cache overflow globally; we only produce this in certain modes.
13541356 } else if !pred. needs_infer ( ) {
13551357 if !candidate. needs_infer ( ) {
0 commit comments