@@ -6,18 +6,16 @@ use std::fmt;
6
6
use std:: hash:: Hash ;
7
7
8
8
use rustc:: mir;
9
- use rustc:: mir:: interpret:: ScalarMaybeUndef ;
10
- use rustc:: ty:: layout:: { self , LayoutOf , VariantIdx } ;
11
- use rustc:: ty:: { self , subst:: Subst , TyCtxt } ;
9
+ use rustc:: ty:: layout:: { self , VariantIdx } ;
10
+ use rustc:: ty:: { self , TyCtxt } ;
12
11
13
12
use syntax:: {
14
13
source_map:: { Span , DUMMY_SP } ,
15
14
symbol:: Symbol ,
16
15
} ;
17
16
18
17
use crate :: interpret:: {
19
- intern_const_alloc_recursive, Allocation , ConstValue , GlobalId , ImmTy , Immediate , InterpCx ,
20
- InterpResult , MPlaceTy , MemoryKind , OpTy , Scalar , StackPopCleanup ,
18
+ intern_const_alloc_recursive, Allocation , ConstValue , ImmTy , Immediate , InterpCx , OpTy , Scalar ,
21
19
} ;
22
20
23
21
mod error;
@@ -121,49 +119,6 @@ fn op_to_const<'tcx>(
121
119
ecx. tcx . mk_const ( ty:: Const { val : ty:: ConstKind :: Value ( val) , ty : op. layout . ty } )
122
120
}
123
121
124
- // Returns a pointer to where the result lives
125
- fn eval_body_using_ecx < ' mir , ' tcx > (
126
- ecx : & mut CompileTimeEvalContext < ' mir , ' tcx > ,
127
- cid : GlobalId < ' tcx > ,
128
- body : & ' mir mir:: Body < ' tcx > ,
129
- ) -> InterpResult < ' tcx , MPlaceTy < ' tcx > > {
130
- debug ! ( "eval_body_using_ecx: {:?}, {:?}" , cid, ecx. param_env) ;
131
- let tcx = ecx. tcx . tcx ;
132
- let layout = ecx. layout_of ( body. return_ty ( ) . subst ( tcx, cid. instance . substs ) ) ?;
133
- assert ! ( !layout. is_unsized( ) ) ;
134
- let ret = ecx. allocate ( layout, MemoryKind :: Stack ) ;
135
-
136
- let name = ty:: tls:: with ( |tcx| tcx. def_path_str ( cid. instance . def_id ( ) ) ) ;
137
- let prom = cid. promoted . map_or ( String :: new ( ) , |p| format ! ( "::promoted[{:?}]" , p) ) ;
138
- trace ! ( "eval_body_using_ecx: pushing stack frame for global: {}{}" , name, prom) ;
139
-
140
- // Assert all args (if any) are zero-sized types; `eval_body_using_ecx` doesn't
141
- // make sense if the body is expecting nontrivial arguments.
142
- // (The alternative would be to use `eval_fn_call` with an args slice.)
143
- for arg in body. args_iter ( ) {
144
- let decl = body. local_decls . get ( arg) . expect ( "arg missing from local_decls" ) ;
145
- let layout = ecx. layout_of ( decl. ty . subst ( tcx, cid. instance . substs ) ) ?;
146
- assert ! ( layout. is_zst( ) )
147
- }
148
-
149
- ecx. push_stack_frame (
150
- cid. instance ,
151
- body. span ,
152
- body,
153
- Some ( ret. into ( ) ) ,
154
- StackPopCleanup :: None { cleanup : false } ,
155
- ) ?;
156
-
157
- // The main interpreter loop.
158
- ecx. run ( ) ?;
159
-
160
- // Intern the result
161
- intern_const_alloc_recursive ( ecx, tcx. static_mutability ( cid. instance . def_id ( ) ) , ret) ?;
162
-
163
- debug ! ( "eval_body_using_ecx done: {:?}" , * ret) ;
164
- Ok ( ret)
165
- }
166
-
167
122
/// Extracts a field of a (variant of a) const.
168
123
// this function uses `unwrap` copiously, because an already validated constant must have valid
169
124
// fields and can thus never fail outside of compiler bugs
0 commit comments