@@ -43,6 +43,16 @@ pub fn mk_borrowck_eval_cx<'a, 'mir, 'tcx>(
43
43
) -> EvalResult < ' tcx , CompileTimeEvalContext < ' a , ' mir , ' tcx > > {
44
44
debug ! ( "mk_borrowck_eval_cx: {:?}" , instance) ;
45
45
let param_env = tcx. param_env ( instance. def_id ( ) ) ;
46
+ mk_eval_cx_inner ( tcx, instance, mir, span, param_env)
47
+ }
48
+
49
+ fn mk_eval_cx_inner < ' a , ' mir , ' tcx > (
50
+ tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
51
+ instance : Instance < ' tcx > ,
52
+ mir : & ' mir mir:: Mir < ' tcx > ,
53
+ span : Span ,
54
+ param_env : ty:: ParamEnv < ' tcx > ,
55
+ ) -> EvalResult < ' tcx , CompileTimeEvalContext < ' a , ' mir , ' tcx > > {
46
56
let mut ecx = EvalContext :: new ( tcx. at ( span) , param_env, CompileTimeInterpreter :: new ( ) ) ;
47
57
// insert a stack frame so any queries have the correct substs
48
58
// cannot use `push_stack_frame`; if we do `const_prop` explodes
@@ -67,41 +77,8 @@ pub fn mk_eval_cx<'a, 'tcx>(
67
77
) -> EvalResult < ' tcx , CompileTimeEvalContext < ' a , ' tcx , ' tcx > > {
68
78
debug ! ( "mk_eval_cx: {:?}, {:?}" , instance, param_env) ;
69
79
let span = tcx. def_span ( instance. def_id ( ) ) ;
70
- let mut ecx = EvalContext :: new ( tcx. at ( span) , param_env, CompileTimeInterpreter :: new ( ) ) ;
71
- let mir = mir:: Mir :: new (
72
- :: std:: iter:: once (
73
- mir:: BasicBlockData {
74
- statements : Vec :: new ( ) ,
75
- is_cleanup : false ,
76
- terminator : Some ( mir:: Terminator {
77
- source_info : mir:: SourceInfo {
78
- scope : mir:: OUTERMOST_SOURCE_SCOPE ,
79
- span : DUMMY_SP ,
80
- } ,
81
- kind : mir:: TerminatorKind :: Return ,
82
- } ) ,
83
- }
84
- ) . collect ( ) , // basic blocks
85
- IndexVec :: new ( ) , // source_scopes
86
- mir:: ClearCrossCrate :: Clear , // source_scope_local_data
87
- IndexVec :: new ( ) , // promoted
88
- None , // yield ty
89
- :: std:: iter:: once ( mir:: LocalDecl :: new_return_place ( tcx. types . unit , DUMMY_SP ) ) . collect ( ) ,
90
- IndexVec :: new ( ) , //user_type_annotations
91
- 0 , // arg_count
92
- Vec :: new ( ) , // upvar_decls
93
- DUMMY_SP , // span
94
- Vec :: new ( ) , // control_flow_destroyed
95
- ) ;
96
- // insert a stack frame so any queries have the correct substs
97
- ecx. push_stack_frame (
98
- instance,
99
- span,
100
- tcx. alloc_mir ( mir) ,
101
- None ,
102
- StackPopCleanup :: Goto ( None ) , // never pop
103
- ) ?;
104
- Ok ( ecx)
80
+ let mir = tcx. optimized_mir ( instance. def . def_id ( ) ) ;
81
+ mk_eval_cx_inner ( tcx, instance, mir, span, param_env)
105
82
}
106
83
107
84
pub ( crate ) fn eval_promoted < ' a , ' mir , ' tcx > (
0 commit comments