@@ -7,7 +7,7 @@ use crate::interpret::{
7
7
} ;
8
8
9
9
use rustc_errors:: ErrorReported ;
10
- use rustc_hir:: def:: DefKind ;
10
+ use rustc_hir:: { ConstContext , def:: DefKind } ;
11
11
use rustc_middle:: mir;
12
12
use rustc_middle:: mir:: interpret:: ErrorHandled ;
13
13
use rustc_middle:: traits:: Reveal ;
@@ -30,14 +30,14 @@ fn eval_body_using_ecx<'mir, 'tcx>(
30
30
body : & ' mir mir:: Body < ' tcx > ,
31
31
) -> InterpResult < ' tcx , MPlaceTy < ' tcx > > {
32
32
debug ! ( "eval_body_using_ecx: {:?}, {:?}" , cid, ecx. param_env) ;
33
+ let tcx = * ecx. tcx ;
33
34
assert ! (
34
35
cid. promoted. is_some( )
35
36
|| matches!(
36
- ecx. tcx. hir( ) . body_const_context( def_id) ,
37
+ ecx. tcx. hir( ) . body_const_context( cid . instance . def_id( ) . expect_local ( ) ) ,
37
38
Some ( ConstContext :: Const | ConstContext :: Static ( _) )
38
39
)
39
40
) ;
40
- let tcx = * ecx. tcx ;
41
41
let layout = ecx. layout_of ( body. return_ty ( ) . subst ( tcx, cid. instance . substs ) ) ?;
42
42
assert ! ( !layout. is_unsized( ) ) ;
43
43
let ret = ecx. allocate ( layout, MemoryKind :: Stack ) ;
@@ -47,14 +47,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
47
47
let prom = cid. promoted . map_or ( String :: new ( ) , |p| format ! ( "::promoted[{:?}]" , p) ) ;
48
48
trace ! ( "eval_body_using_ecx: pushing stack frame for global: {}{}" , name, prom) ;
49
49
50
- // Assert all args (if any) are zero-sized types; `eval_body_using_ecx` doesn't
51
- // make sense if the body is expecting nontrivial arguments.
52
- // (The alternative would be to use `eval_fn_call` with an args slice.)
53
- for arg in body. args_iter ( ) {
54
- let decl = body. local_decls . get ( arg) . expect ( "arg missing from local_decls" ) ;
55
- let layout = ecx. layout_of ( decl. ty . subst ( tcx, cid. instance . substs ) ) ?;
56
- assert ! ( layout. is_zst( ) )
57
- }
50
+
58
51
59
52
ecx. push_stack_frame (
60
53
cid. instance ,
0 commit comments