@@ -93,7 +93,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
93
93
arg. push ( 0 ) ;
94
94
argvs. push (
95
95
ecx. memory
96
- . allocate_static_bytes ( arg. as_slice ( ) , MiriMemoryKind :: Static . into ( ) ) ,
96
+ . allocate_static_bytes ( arg. as_slice ( ) , MiriMemoryKind :: Env . into ( ) ) ,
97
97
) ;
98
98
}
99
99
// Make an array with all these pointers, in the Miri memory.
@@ -103,7 +103,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
103
103
let argvs_place = ecx. allocate ( argvs_layout, MiriMemoryKind :: Env . into ( ) ) ;
104
104
for ( idx, arg) in argvs. into_iter ( ) . enumerate ( ) {
105
105
let place = ecx. mplace_field ( argvs_place, idx as u64 ) ?;
106
- ecx. write_scalar ( Scalar :: Ptr ( arg) , place. into ( ) ) ?;
106
+ ecx. write_scalar ( arg, place. into ( ) ) ?;
107
107
}
108
108
ecx. memory
109
109
. mark_immutable ( argvs_place. ptr . assert_ptr ( ) . alloc_id ) ?;
@@ -144,19 +144,19 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
144
144
// Return place (in static memory so that it does not count as leak).
145
145
let ret_place = ecx. allocate (
146
146
ecx. layout_of ( tcx. types . isize ) ?,
147
- MiriMemoryKind :: Static . into ( ) ,
147
+ MiriMemoryKind :: Env . into ( ) ,
148
148
) ;
149
149
// Call start function.
150
150
ecx. call_function (
151
151
start_instance,
152
- & [ main_ptr. into ( ) , argc, argv] ,
152
+ & [ main_ptr. into ( ) , argc. into ( ) , argv. into ( ) ] ,
153
153
Some ( ret_place. into ( ) ) ,
154
154
StackPopCleanup :: None { cleanup : true } ,
155
155
) ?;
156
156
157
157
// Set the last_error to 0
158
158
let errno_layout = ecx. layout_of ( tcx. types . u32 ) ?;
159
- let errno_place = ecx. allocate ( errno_layout, MiriMemoryKind :: Static . into ( ) ) ;
159
+ let errno_place = ecx. allocate ( errno_layout, MiriMemoryKind :: Env . into ( ) ) ;
160
160
ecx. write_scalar ( Scalar :: from_u32 ( 0 ) , errno_place. into ( ) ) ?;
161
161
ecx. machine . last_error = Some ( errno_place) ;
162
162
@@ -217,16 +217,13 @@ pub fn eval_main<'tcx>(tcx: TyCtxt<'tcx>, main_id: DefId, config: MiriConfig) ->
217
217
}
218
218
err_unsup ! ( NoMirFor ( ..) ) =>
219
219
format ! ( "{}. Did you set `MIRI_SYSROOT` to a Miri-enabled sysroot? You can prepare one with `cargo miri setup`." , e) ,
220
+ InterpError :: InvalidProgram ( _) =>
221
+ bug ! ( "This error should be impossible in Miri: {}" , e) ,
220
222
_ => e. to_string ( )
221
223
} ;
222
224
e. print_backtrace ( ) ;
223
225
if let Some ( frame) = ecx. stack ( ) . last ( ) {
224
- let block = & frame. body . basic_blocks ( ) [ frame. block . unwrap ( ) ] ;
225
- let span = if frame. stmt < block. statements . len ( ) {
226
- block. statements [ frame. stmt ] . source_info . span
227
- } else {
228
- block. terminator ( ) . source_info . span
229
- } ;
226
+ let span = frame. current_source_info ( ) . unwrap ( ) . span ;
230
227
231
228
let msg = format ! ( "Miri evaluation error: {}" , msg) ;
232
229
let mut err = ecx. tcx . sess . struct_span_err ( span, msg. as_str ( ) ) ;
0 commit comments