@@ -6,18 +6,16 @@ use std::fmt;
66use std:: hash:: Hash ;
77
88use 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 } ;
1211
1312use syntax:: {
1413 source_map:: { Span , DUMMY_SP } ,
1514 symbol:: Symbol ,
1615} ;
1716
1817use 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 ,
2119} ;
2220
2321mod error;
@@ -121,49 +119,6 @@ fn op_to_const<'tcx>(
121119 ecx. tcx . mk_const ( ty:: Const { val : ty:: ConstKind :: Value ( val) , ty : op. layout . ty } )
122120}
123121
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-
167122/// Extracts a field of a (variant of a) const.
168123// this function uses `unwrap` copiously, because an already validated constant must have valid
169124// fields and can thus never fail outside of compiler bugs
0 commit comments