@@ -93,7 +93,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
9393 arg. push ( 0 ) ;
9494 argvs. push (
9595 ecx. memory
96- . allocate_static_bytes ( arg. as_slice ( ) , MiriMemoryKind :: Static . into ( ) ) ,
96+ . allocate_static_bytes ( arg. as_slice ( ) , MiriMemoryKind :: Env . into ( ) ) ,
9797 ) ;
9898 }
9999 // Make an array with all these pointers, in the Miri memory.
@@ -103,7 +103,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
103103 let argvs_place = ecx. allocate ( argvs_layout, MiriMemoryKind :: Env . into ( ) ) ;
104104 for ( idx, arg) in argvs. into_iter ( ) . enumerate ( ) {
105105 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 ( ) ) ?;
107107 }
108108 ecx. memory
109109 . mark_immutable ( argvs_place. ptr . assert_ptr ( ) . alloc_id ) ?;
@@ -144,19 +144,19 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
144144 // Return place (in static memory so that it does not count as leak).
145145 let ret_place = ecx. allocate (
146146 ecx. layout_of ( tcx. types . isize ) ?,
147- MiriMemoryKind :: Static . into ( ) ,
147+ MiriMemoryKind :: Env . into ( ) ,
148148 ) ;
149149 // Call start function.
150150 ecx. call_function (
151151 start_instance,
152- & [ main_ptr. into ( ) , argc, argv] ,
152+ & [ main_ptr. into ( ) , argc. into ( ) , argv. into ( ) ] ,
153153 Some ( ret_place. into ( ) ) ,
154154 StackPopCleanup :: None { cleanup : true } ,
155155 ) ?;
156156
157157 // Set the last_error to 0
158158 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 ( ) ) ;
160160 ecx. write_scalar ( Scalar :: from_u32 ( 0 ) , errno_place. into ( ) ) ?;
161161 ecx. machine . last_error = Some ( errno_place) ;
162162
@@ -217,16 +217,13 @@ pub fn eval_main<'tcx>(tcx: TyCtxt<'tcx>, main_id: DefId, config: MiriConfig) ->
217217 }
218218 err_unsup ! ( NoMirFor ( ..) ) =>
219219 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) ,
220222 _ => e. to_string ( )
221223 } ;
222224 e. print_backtrace ( ) ;
223225 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 ;
230227
231228 let msg = format ! ( "Miri evaluation error: {}" , msg) ;
232229 let mut err = ecx. tcx . sess . struct_span_err ( span, msg. as_str ( ) ) ;
0 commit comments