@@ -25,7 +25,7 @@ use crate::traits::project::ProjectionCacheKeyExt;
25
25
use crate :: traits:: ProjectionCacheKey ;
26
26
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
27
27
use rustc_data_structures:: stack:: ensure_sufficient_stack;
28
- use rustc_errors:: Diagnostic ;
28
+ use rustc_errors:: { Diagnostic , ErrorGuaranteed } ;
29
29
use rustc_hir as hir;
30
30
use rustc_hir:: def_id:: DefId ;
31
31
use rustc_infer:: infer:: LateBoundRegionConversionTime ;
@@ -316,11 +316,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
316
316
obligation : & TraitObligation < ' tcx > ,
317
317
) -> SelectionResult < ' tcx , Selection < ' tcx > > {
318
318
let candidate = match self . select_from_obligation ( obligation) {
319
- Err ( SelectionError :: Overflow ) => {
319
+ Err ( SelectionError :: Overflow ( OverflowError :: Canonical ) ) => {
320
320
// In standard mode, overflow must have been caught and reported
321
321
// earlier.
322
322
assert ! ( self . query_mode == TraitQueryMode :: Canonical ) ;
323
- return Err ( SelectionError :: Overflow ) ;
323
+ return Err ( SelectionError :: Overflow ( OverflowError :: Canonical ) ) ;
324
324
}
325
325
Err ( SelectionError :: Ambiguous ( _) ) => {
326
326
return Ok ( None ) ;
@@ -335,9 +335,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
335
335
} ;
336
336
337
337
match self . confirm_candidate ( obligation, candidate) {
338
- Err ( SelectionError :: Overflow ) => {
338
+ Err ( SelectionError :: Overflow ( OverflowError :: Canonical ) ) => {
339
339
assert ! ( self . query_mode == TraitQueryMode :: Canonical ) ;
340
- Err ( SelectionError :: Overflow )
340
+ Err ( SelectionError :: Overflow ( OverflowError :: Canonical ) )
341
341
}
342
342
Err ( e) => Err ( e) ,
343
343
Ok ( candidate) => {
@@ -954,7 +954,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
954
954
Ok ( Some ( c) ) => self . evaluate_candidate ( stack, & c) ,
955
955
Err ( SelectionError :: Ambiguous ( _) ) => Ok ( EvaluatedToAmbig ) ,
956
956
Ok ( None ) => Ok ( EvaluatedToAmbig ) ,
957
- Err ( Overflow ) => Err ( OverflowError :: Canonical ) ,
957
+ Err ( Overflow ( OverflowError :: Canonical ) ) => Err ( OverflowError :: Canonical ) ,
958
958
Err ( ErrorReporting ) => Err ( OverflowError :: ErrorReporting ) ,
959
959
Err ( ..) => Ok ( EvaluatedToErr ) ,
960
960
}
@@ -1113,7 +1113,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1113
1113
match self . query_mode {
1114
1114
TraitQueryMode :: Standard => {
1115
1115
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
+ ) ) ;
1117
1119
}
1118
1120
self . infcx . report_overflow_error ( error_obligation, true ) ;
1119
1121
}
@@ -1349,7 +1351,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1349
1351
}
1350
1352
1351
1353
if self . can_use_global_caches ( param_env) {
1352
- if let Err ( Overflow ) = candidate {
1354
+ if let Err ( Overflow ( OverflowError :: Canonical ) ) = candidate {
1353
1355
// Don't cache overflow globally; we only produce this in certain modes.
1354
1356
} else if !pred. needs_infer ( ) {
1355
1357
if !candidate. needs_infer ( ) {
0 commit comments