@@ -29,7 +29,7 @@ use crate::traits::project::ProjectionCacheKeyExt;
29
29
use crate :: traits:: ProjectionCacheKey ;
30
30
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
31
31
use rustc_data_structures:: stack:: ensure_sufficient_stack;
32
- use rustc_errors:: Diagnostic ;
32
+ use rustc_errors:: { Diagnostic , ErrorGuaranteed } ;
33
33
use rustc_hir as hir;
34
34
use rustc_hir:: def_id:: DefId ;
35
35
use rustc_infer:: infer:: LateBoundRegionConversionTime ;
@@ -320,11 +320,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
320
320
obligation : & TraitObligation < ' tcx > ,
321
321
) -> SelectionResult < ' tcx , Selection < ' tcx > > {
322
322
let candidate = match self . select_from_obligation ( obligation) {
323
- Err ( SelectionError :: Overflow ) => {
323
+ Err ( SelectionError :: Overflow ( OverflowError :: Canonical ) ) => {
324
324
// In standard mode, overflow must have been caught and reported
325
325
// earlier.
326
326
assert ! ( self . query_mode == TraitQueryMode :: Canonical ) ;
327
- return Err ( SelectionError :: Overflow ) ;
327
+ return Err ( SelectionError :: Overflow ( OverflowError :: Canonical ) ) ;
328
328
}
329
329
Err ( SelectionError :: Ambiguous ( _) ) => {
330
330
return Ok ( None ) ;
@@ -339,9 +339,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
339
339
} ;
340
340
341
341
match self . confirm_candidate ( obligation, candidate) {
342
- Err ( SelectionError :: Overflow ) => {
342
+ Err ( SelectionError :: Overflow ( OverflowError :: Canonical ) ) => {
343
343
assert ! ( self . query_mode == TraitQueryMode :: Canonical ) ;
344
- Err ( SelectionError :: Overflow )
344
+ Err ( SelectionError :: Overflow ( OverflowError :: Canonical ) )
345
345
}
346
346
Err ( e) => Err ( e) ,
347
347
Ok ( candidate) => {
@@ -958,7 +958,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
958
958
Ok ( Some ( c) ) => self . evaluate_candidate ( stack, & c) ,
959
959
Err ( SelectionError :: Ambiguous ( _) ) => Ok ( EvaluatedToAmbig ) ,
960
960
Ok ( None ) => Ok ( EvaluatedToAmbig ) ,
961
- Err ( Overflow ) => Err ( OverflowError :: Canonical ) ,
961
+ Err ( Overflow ( OverflowError :: Canonical ) ) => Err ( OverflowError :: Canonical ) ,
962
962
Err ( ErrorReporting ) => Err ( OverflowError :: ErrorReporting ) ,
963
963
Err ( ..) => Ok ( EvaluatedToErr ) ,
964
964
}
@@ -1117,7 +1117,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1117
1117
match self . query_mode {
1118
1118
TraitQueryMode :: Standard => {
1119
1119
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
+ ) ) ;
1121
1123
}
1122
1124
self . infcx . report_overflow_error ( error_obligation, true ) ;
1123
1125
}
@@ -1353,7 +1355,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1353
1355
}
1354
1356
1355
1357
if self . can_use_global_caches ( param_env) {
1356
- if let Err ( Overflow ) = candidate {
1358
+ if let Err ( Overflow ( OverflowError :: Canonical ) ) = candidate {
1357
1359
// Don't cache overflow globally; we only produce this in certain modes.
1358
1360
} else if !pred. needs_infer ( ) {
1359
1361
if !candidate. needs_infer ( ) {
0 commit comments