@@ -29,7 +29,7 @@ use crate::traits::project::ProjectionCacheKeyExt;
2929use crate :: traits:: ProjectionCacheKey ;
3030use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
3131use rustc_data_structures:: stack:: ensure_sufficient_stack;
32- use rustc_errors:: Diagnostic ;
32+ use rustc_errors:: { Diagnostic , ErrorGuaranteed } ;
3333use rustc_hir as hir;
3434use rustc_hir:: def_id:: DefId ;
3535use rustc_infer:: infer:: LateBoundRegionConversionTime ;
@@ -320,11 +320,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
320320 obligation : & TraitObligation < ' tcx > ,
321321 ) -> SelectionResult < ' tcx , Selection < ' tcx > > {
322322 let candidate = match self . select_from_obligation ( obligation) {
323- Err ( SelectionError :: Overflow ) => {
323+ Err ( SelectionError :: Overflow ( OverflowError :: Canonical ) ) => {
324324 // In standard mode, overflow must have been caught and reported
325325 // earlier.
326326 assert ! ( self . query_mode == TraitQueryMode :: Canonical ) ;
327- return Err ( SelectionError :: Overflow ) ;
327+ return Err ( SelectionError :: Overflow ( OverflowError :: Canonical ) ) ;
328328 }
329329 Err ( SelectionError :: Ambiguous ( _) ) => {
330330 return Ok ( None ) ;
@@ -339,9 +339,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
339339 } ;
340340
341341 match self . confirm_candidate ( obligation, candidate) {
342- Err ( SelectionError :: Overflow ) => {
342+ Err ( SelectionError :: Overflow ( OverflowError :: Canonical ) ) => {
343343 assert ! ( self . query_mode == TraitQueryMode :: Canonical ) ;
344- Err ( SelectionError :: Overflow )
344+ Err ( SelectionError :: Overflow ( OverflowError :: Canonical ) )
345345 }
346346 Err ( e) => Err ( e) ,
347347 Ok ( candidate) => {
@@ -958,7 +958,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
958958 Ok ( Some ( c) ) => self . evaluate_candidate ( stack, & c) ,
959959 Err ( SelectionError :: Ambiguous ( _) ) => Ok ( EvaluatedToAmbig ) ,
960960 Ok ( None ) => Ok ( EvaluatedToAmbig ) ,
961- Err ( Overflow ) => Err ( OverflowError :: Canonical ) ,
961+ Err ( Overflow ( OverflowError :: Canonical ) ) => Err ( OverflowError :: Canonical ) ,
962962 Err ( ErrorReporting ) => Err ( OverflowError :: ErrorReporting ) ,
963963 Err ( ..) => Ok ( EvaluatedToErr ) ,
964964 }
@@ -1117,7 +1117,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11171117 match self . query_mode {
11181118 TraitQueryMode :: Standard => {
11191119 if self . infcx . is_tainted_by_errors ( ) {
1120- return Err ( OverflowError :: ErrorReporting ) ;
1120+ return Err ( OverflowError :: Error (
1121+ ErrorGuaranteed :: unchecked_claim_error_was_emitted ( ) ,
1122+ ) ) ;
11211123 }
11221124 self . infcx . report_overflow_error ( error_obligation, true ) ;
11231125 }
@@ -1353,7 +1355,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
13531355 }
13541356
13551357 if self . can_use_global_caches ( param_env) {
1356- if let Err ( Overflow ) = candidate {
1358+ if let Err ( Overflow ( OverflowError :: Canonical ) ) = candidate {
13571359 // Don't cache overflow globally; we only produce this in certain modes.
13581360 } else if !pred. needs_infer ( ) {
13591361 if !candidate. needs_infer ( ) {
0 commit comments