@@ -398,36 +398,21 @@ impl<'tcx> Const<'tcx> {
398398 }
399399 }
400400
401- /// Returns the evaluated constant
402- #[ inline]
403- pub fn eval (
404- self ,
405- tcx : TyCtxt < ' tcx > ,
406- param_env : ParamEnv < ' tcx > ,
407- span : Span ,
408- ) -> Result < ( Ty < ' tcx > , ValTree < ' tcx > ) , ErrorHandled > {
409- self . eval_valtree ( tcx, param_env, span) . map_err ( |err| {
410- match err {
411- Either :: Right ( err) => err,
412- Either :: Left ( _bad_ty) => {
413- // This can happen when we run on ill-typed code.
414- let e = tcx. dcx ( ) . span_delayed_bug (
415- span,
416- "`ty::Const::eval` called on a non-valtree-compatible type" ,
417- ) ;
418- e. into ( )
419- }
420- }
421- } )
422- }
423-
424401 /// Normalizes the constant to a value or an error if possible.
425402 #[ inline]
426403 pub fn normalize ( self , tcx : TyCtxt < ' tcx > , param_env : ParamEnv < ' tcx > ) -> Self {
427- match self . eval ( tcx, param_env, DUMMY_SP ) {
404+ match self . eval_valtree ( tcx, param_env, DUMMY_SP ) {
428405 Ok ( ( ty, val) ) => Self :: new_value ( tcx, val, ty) ,
429- Err ( ErrorHandled :: Reported ( r, _span) ) => Self :: new_error ( tcx, r. into ( ) ) ,
430- Err ( ErrorHandled :: TooGeneric ( _span) ) => self ,
406+ Err ( Either :: Left ( _bad_ty) ) => {
407+ // This can happen when we run on ill-typed code.
408+ Self :: new_error (
409+ tcx,
410+ tcx. dcx ( )
411+ . delayed_bug ( "`ty::Const::eval` called on a non-valtree-compatible type" ) ,
412+ )
413+ }
414+ Err ( Either :: Right ( ErrorHandled :: Reported ( r, _span) ) ) => Self :: new_error ( tcx, r. into ( ) ) ,
415+ Err ( Either :: Right ( ErrorHandled :: TooGeneric ( _span) ) ) => self ,
431416 }
432417 }
433418
0 commit comments