@@ -18,6 +18,7 @@ use crate::ty::{List, ParamEnv, ParamEnvAnd, TyS};
18
18
use polonius_engine:: Atom ;
19
19
use rustc_ast:: ast:: { self , Ident } ;
20
20
use rustc_data_structures:: captures:: Captures ;
21
+ use rustc_errors:: ErrorReported ;
21
22
use rustc_hir as hir;
22
23
use rustc_hir:: def_id:: { DefId , LocalDefId } ;
23
24
use rustc_index:: vec:: Idx ;
@@ -2340,6 +2341,8 @@ impl<'tcx> Const<'tcx> {
2340
2341
/// unevaluated constant.
2341
2342
pub fn eval ( & self , tcx : TyCtxt < ' tcx > , param_env : ParamEnv < ' tcx > ) -> & Const < ' tcx > {
2342
2343
if let ConstKind :: Unevaluated ( did, substs, promoted) = self . val {
2344
+ use crate :: mir:: interpret:: ErrorHandled ;
2345
+
2343
2346
let param_env_and_substs = param_env. with_reveal_all ( ) . and ( substs) ;
2344
2347
2345
2348
// HACK(eddyb) this erases lifetimes even though `const_eval_resolve`
@@ -2369,8 +2372,10 @@ impl<'tcx> Const<'tcx> {
2369
2372
// (which may be identity substs, see above),
2370
2373
// can leak through `val` into the const we return.
2371
2374
Ok ( val) => Const :: from_value ( tcx, val, self . ty ) ,
2372
-
2373
- Err ( _) => self ,
2375
+ Err ( ErrorHandled :: TooGeneric | ErrorHandled :: Linted ) => self ,
2376
+ Err ( ErrorHandled :: Reported ( ErrorReported ) ) => {
2377
+ tcx. mk_const ( ty:: Const { val : ty:: ConstKind :: Error , ty : self . ty } )
2378
+ }
2374
2379
}
2375
2380
} else {
2376
2381
self
0 commit comments