@@ -43,6 +43,16 @@ pub fn mk_borrowck_eval_cx<'a, 'mir, 'tcx>(
4343) -> EvalResult < ' tcx , CompileTimeEvalContext < ' a , ' mir , ' tcx > > {
4444 debug ! ( "mk_borrowck_eval_cx: {:?}" , instance) ;
4545 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 > > {
4656 let mut ecx = EvalContext :: new ( tcx. at ( span) , param_env, CompileTimeInterpreter :: new ( ) ) ;
4757 // insert a stack frame so any queries have the correct substs
4858 // cannot use `push_stack_frame`; if we do `const_prop` explodes
@@ -67,41 +77,8 @@ pub fn mk_eval_cx<'a, 'tcx>(
6777) -> EvalResult < ' tcx , CompileTimeEvalContext < ' a , ' tcx , ' tcx > > {
6878 debug ! ( "mk_eval_cx: {:?}, {:?}" , instance, param_env) ;
6979 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)
10582}
10683
10784pub ( crate ) fn eval_promoted < ' a , ' mir , ' tcx > (
0 commit comments