@@ -18,6 +18,7 @@ use crate::ty::{List, ParamEnv, ParamEnvAnd, TyS};
1818use polonius_engine:: Atom ;
1919use rustc_ast:: ast:: { self , Ident } ;
2020use rustc_data_structures:: captures:: Captures ;
21+ use rustc_errors:: ErrorReported ;
2122use rustc_hir as hir;
2223use rustc_hir:: def_id:: { DefId , LocalDefId } ;
2324use rustc_index:: vec:: Idx ;
@@ -2340,6 +2341,8 @@ impl<'tcx> Const<'tcx> {
23402341 /// unevaluated constant.
23412342 pub fn eval ( & self , tcx : TyCtxt < ' tcx > , param_env : ParamEnv < ' tcx > ) -> & Const < ' tcx > {
23422343 if let ConstKind :: Unevaluated ( did, substs, promoted) = self . val {
2344+ use crate :: mir:: interpret:: ErrorHandled ;
2345+
23432346 let param_env_and_substs = param_env. with_reveal_all ( ) . and ( substs) ;
23442347
23452348 // HACK(eddyb) this erases lifetimes even though `const_eval_resolve`
@@ -2369,8 +2372,10 @@ impl<'tcx> Const<'tcx> {
23692372 // (which may be identity substs, see above),
23702373 // can leak through `val` into the const we return.
23712374 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+ }
23742379 }
23752380 } else {
23762381 self
0 commit comments