@@ -8,15 +8,14 @@ use either::{Either, Left, Right};
8
8
use rustc_hir:: def:: Namespace ;
9
9
use rustc_middle:: ty:: layout:: { LayoutOf , TyAndLayout } ;
10
10
use rustc_middle:: ty:: print:: { FmtPrinter , PrettyPrinter } ;
11
- use rustc_middle:: ty:: { ConstInt , Ty , ValTree } ;
11
+ use rustc_middle:: ty:: { ConstInt , Ty } ;
12
12
use rustc_middle:: { mir, ty} ;
13
- use rustc_span:: Span ;
14
13
use rustc_target:: abi:: { self , Abi , Align , HasDataLayout , Size } ;
15
14
16
15
use super :: {
17
- alloc_range, from_known_layout, mir_assign_valid_types, AllocId , ConstValue , Frame , GlobalId ,
18
- InterpCx , InterpResult , MPlaceTy , Machine , MemPlace , MemPlaceMeta , PlaceTy , Pointer ,
19
- Projectable , Provenance , Scalar ,
16
+ alloc_range, from_known_layout, mir_assign_valid_types, AllocId , ConstValue , Frame , InterpCx ,
17
+ InterpResult , MPlaceTy , Machine , MemPlace , MemPlaceMeta , PlaceTy , Pointer , Projectable ,
18
+ Provenance , Scalar ,
20
19
} ;
21
20
22
21
/// An `Immediate` represents a single immediate self-contained Rust value.
@@ -693,54 +692,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
693
692
Ok ( op)
694
693
}
695
694
696
- fn eval_ty_constant (
697
- & self ,
698
- val : ty:: Const < ' tcx > ,
699
- span : Option < Span > ,
700
- ) -> InterpResult < ' tcx , ValTree < ' tcx > > {
701
- Ok ( match val. kind ( ) {
702
- ty:: ConstKind :: Param ( _) | ty:: ConstKind :: Placeholder ( ..) => {
703
- throw_inval ! ( TooGeneric )
704
- }
705
- // FIXME(generic_const_exprs): `ConstKind::Expr` should be able to be evaluated
706
- ty:: ConstKind :: Expr ( _) => throw_inval ! ( TooGeneric ) ,
707
- ty:: ConstKind :: Error ( reported) => {
708
- throw_inval ! ( AlreadyReported ( reported. into( ) ) )
709
- }
710
- ty:: ConstKind :: Unevaluated ( uv) => {
711
- let instance = self . resolve ( uv. def , uv. args ) ?;
712
- let cid = GlobalId { instance, promoted : None } ;
713
- self . ctfe_query ( span, |tcx| tcx. eval_to_valtree ( self . param_env . and ( cid) ) ) ?
714
- . unwrap_or_else ( || bug ! ( "unable to create ValTree for {uv:?}" ) )
715
- }
716
- ty:: ConstKind :: Bound ( ..) | ty:: ConstKind :: Infer ( ..) => {
717
- span_bug ! ( self . cur_span( ) , "unexpected ConstKind in ctfe: {val:?}" )
718
- }
719
- ty:: ConstKind :: Value ( valtree) => valtree,
720
- } )
721
- }
722
-
723
- pub fn eval_mir_constant (
724
- & self ,
725
- val : & mir:: ConstantKind < ' tcx > ,
726
- span : Option < Span > ,
727
- layout : Option < TyAndLayout < ' tcx > > ,
728
- ) -> InterpResult < ' tcx , OpTy < ' tcx , M :: Provenance > > {
729
- match * val {
730
- mir:: ConstantKind :: Ty ( ct) => {
731
- let ty = ct. ty ( ) ;
732
- let valtree = self . eval_ty_constant ( ct, span) ?;
733
- let const_val = self . tcx . valtree_to_const_val ( ( ty, valtree) ) ;
734
- self . const_val_to_op ( const_val, ty, layout)
735
- }
736
- mir:: ConstantKind :: Val ( val, ty) => self . const_val_to_op ( val, ty, layout) ,
737
- mir:: ConstantKind :: Unevaluated ( uv, _) => {
738
- let instance = self . resolve ( uv. def , uv. args ) ?;
739
- Ok ( self . eval_global ( GlobalId { instance, promoted : uv. promoted } , span) ?. into ( ) )
740
- }
741
- }
742
- }
743
-
744
695
pub ( crate ) fn const_val_to_op (
745
696
& self ,
746
697
val_val : ConstValue < ' tcx > ,
0 commit comments