File tree 1 file changed +10
-6
lines changed
compiler/rustc_mir/src/const_eval
1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ use crate::interpret::{
7
7
} ;
8
8
9
9
use rustc_errors:: ErrorReported ;
10
- use rustc_hir:: { ConstContext , def:: DefKind } ;
10
+ use rustc_hir:: def:: DefKind ;
11
11
use rustc_middle:: mir;
12
12
use rustc_middle:: mir:: interpret:: ErrorHandled ;
13
13
use rustc_middle:: traits:: Reveal ;
@@ -34,9 +34,15 @@ fn eval_body_using_ecx<'mir, 'tcx>(
34
34
assert ! (
35
35
cid. promoted. is_some( )
36
36
|| matches!(
37
- ecx. tcx. hir( ) . body_const_context( cid. instance. def_id( ) . expect_local( ) ) ,
38
- Some ( ConstContext :: Const | ConstContext :: Static ( _) )
39
- )
37
+ ecx. tcx. def_kind( cid. instance. def_id( ) ) ,
38
+ DefKind :: Const
39
+ | DefKind :: Static
40
+ | DefKind :: ConstParam
41
+ | DefKind :: AnonConst
42
+ | DefKind :: AssocConst
43
+ ) ,
44
+ "Unexpected DefKind: {:?}" ,
45
+ ecx. tcx. def_kind( cid. instance. def_id( ) )
40
46
) ;
41
47
let layout = ecx. layout_of ( body. return_ty ( ) . subst ( tcx, cid. instance . substs ) ) ?;
42
48
assert ! ( !layout. is_unsized( ) ) ;
@@ -47,8 +53,6 @@ fn eval_body_using_ecx<'mir, 'tcx>(
47
53
let prom = cid. promoted . map_or ( String :: new ( ) , |p| format ! ( "::promoted[{:?}]" , p) ) ;
48
54
trace ! ( "eval_body_using_ecx: pushing stack frame for global: {}{}" , name, prom) ;
49
55
50
-
51
-
52
56
ecx. push_stack_frame (
53
57
cid. instance ,
54
58
body,
You can’t perform that action at this time.
0 commit comments