@@ -38,6 +38,7 @@ use crate::traits::project::ProjectionCacheKeyExt;
38
38
use rustc_ast:: attr;
39
39
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
40
40
use rustc_data_structures:: stack:: ensure_sufficient_stack;
41
+ use rustc_errors:: ErrorReported ;
41
42
use rustc_hir as hir;
42
43
use rustc_hir:: def_id:: DefId ;
43
44
use rustc_hir:: lang_items;
@@ -514,17 +515,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
514
515
515
516
let evaluate = |c : & ' tcx ty:: Const < ' tcx > | {
516
517
if let ty:: ConstKind :: Unevaluated ( def_id, substs, promoted) = c. val {
517
- match self . infcx . const_eval_resolve (
518
- obligation. param_env ,
519
- def_id,
520
- substs,
521
- promoted,
522
- Some ( obligation. cause . span ) ,
523
- ) {
524
- Ok ( val) => Ok ( ty:: Const :: from_value ( self . tcx ( ) , val, c. ty ) ) ,
525
- Err ( ErrorHandled :: TooGeneric ) => Err ( EvaluatedToAmbig ) ,
526
- Err ( _) => Err ( EvaluatedToErr ) ,
527
- }
518
+ self . infcx
519
+ . const_eval_resolve (
520
+ obligation. param_env ,
521
+ def_id,
522
+ substs,
523
+ promoted,
524
+ Some ( obligation. cause . span ) ,
525
+ )
526
+ . map ( |val| ty:: Const :: from_value ( self . tcx ( ) , val, c. ty ) )
528
527
} else {
529
528
Ok ( c)
530
529
}
@@ -537,8 +536,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
537
536
Err ( _) => Ok ( EvaluatedToErr ) ,
538
537
}
539
538
}
540
- ( Err ( EvaluatedToErr ) , _) | ( _, Err ( EvaluatedToErr ) ) => Ok ( EvaluatedToErr ) ,
541
- _ => Ok ( EvaluatedToAmbig ) ,
539
+ ( Err ( ErrorHandled :: Reported ( ErrorReported ) ) , _)
540
+ | ( _, Err ( ErrorHandled :: Reported ( ErrorReported ) ) ) => Ok ( EvaluatedToErr ) ,
541
+ ( Err ( ErrorHandled :: Linted ) , _) | ( _, Err ( ErrorHandled :: Linted ) ) => span_bug ! (
542
+ obligation. cause. span( self . tcx( ) ) ,
543
+ "ConstEquate: const_eval_resolve returned an unexpected error"
544
+ ) ,
545
+ ( Err ( ErrorHandled :: TooGeneric ) , _) | ( _, Err ( ErrorHandled :: TooGeneric ) ) => {
546
+ Ok ( EvaluatedToAmbig )
547
+ }
542
548
}
543
549
}
544
550
}
0 commit comments