@@ -166,7 +166,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
166
166
let const_val = this. eval_global ( cid, None ) . unwrap_or_else ( |err| {
167
167
panic ! ( "failed to evaluate required Rust item: {path:?}\n {err:?}" )
168
168
} ) ;
169
- this. read_scalar ( & const_val. into ( ) )
169
+ this. read_scalar ( & const_val)
170
170
. unwrap_or_else ( |err| panic ! ( "failed to read required Rust item: {path:?}\n {err:?}" ) )
171
171
}
172
172
@@ -231,7 +231,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
231
231
}
232
232
233
233
/// Project to the given *named* field (which must be a struct or union type).
234
- fn project_field_named < P : Projectable < ' mir , ' tcx , Provenance > > (
234
+ fn project_field_named < P : Projectable < ' tcx , Provenance > > (
235
235
& self ,
236
236
base : & P ,
237
237
name : & str ,
@@ -252,13 +252,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
252
252
fn write_int (
253
253
& mut self ,
254
254
i : impl Into < i128 > ,
255
- dest : & PlaceTy < ' tcx , Provenance > ,
255
+ dest : & impl Writeable < ' tcx , Provenance > ,
256
256
) -> InterpResult < ' tcx > {
257
- assert ! ( dest. layout. abi. is_scalar( ) , "write_int on non-scalar type {}" , dest. layout. ty) ;
258
- let val = if dest. layout . abi . is_signed ( ) {
259
- Scalar :: from_int ( i, dest. layout . size )
257
+ assert ! ( dest. layout( ) . abi. is_scalar( ) , "write_int on non-scalar type {}" , dest. layout( ) . ty) ;
258
+ let val = if dest. layout ( ) . abi . is_signed ( ) {
259
+ Scalar :: from_int ( i, dest. layout ( ) . size )
260
260
} else {
261
- Scalar :: from_uint ( u64:: try_from ( i. into ( ) ) . unwrap ( ) , dest. layout . size )
261
+ Scalar :: from_uint ( u64:: try_from ( i. into ( ) ) . unwrap ( ) , dest. layout ( ) . size )
262
262
} ;
263
263
self . eval_context_mut ( ) . write_scalar ( val, dest)
264
264
}
@@ -267,12 +267,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
267
267
fn write_int_fields (
268
268
& mut self ,
269
269
values : & [ i128 ] ,
270
- dest : & MPlaceTy < ' tcx , Provenance > ,
270
+ dest : & impl Writeable < ' tcx , Provenance > ,
271
271
) -> InterpResult < ' tcx > {
272
272
let this = self . eval_context_mut ( ) ;
273
273
for ( idx, & val) in values. iter ( ) . enumerate ( ) {
274
274
let field = this. project_field ( dest, idx) ?;
275
- this. write_int ( val, & field. into ( ) ) ?;
275
+ this. write_int ( val, & field) ?;
276
276
}
277
277
Ok ( ( ) )
278
278
}
@@ -281,18 +281,18 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
281
281
fn write_int_fields_named (
282
282
& mut self ,
283
283
values : & [ ( & str , i128 ) ] ,
284
- dest : & MPlaceTy < ' tcx , Provenance > ,
284
+ dest : & impl Writeable < ' tcx , Provenance > ,
285
285
) -> InterpResult < ' tcx > {
286
286
let this = self . eval_context_mut ( ) ;
287
287
for & ( name, val) in values. iter ( ) {
288
288
let field = this. project_field_named ( dest, name) ?;
289
- this. write_int ( val, & field. into ( ) ) ?;
289
+ this. write_int ( val, & field) ?;
290
290
}
291
291
Ok ( ( ) )
292
292
}
293
293
294
294
/// Write a 0 of the appropriate size to `dest`.
295
- fn write_null ( & mut self , dest : & PlaceTy < ' tcx , Provenance > ) -> InterpResult < ' tcx > {
295
+ fn write_null ( & mut self , dest : & impl Writeable < ' tcx , Provenance > ) -> InterpResult < ' tcx > {
296
296
self . write_int ( 0 , dest)
297
297
}
298
298
@@ -600,14 +600,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
600
600
/// necessary.
601
601
fn last_error_place ( & mut self ) -> InterpResult < ' tcx , MPlaceTy < ' tcx , Provenance > > {
602
602
let this = self . eval_context_mut ( ) ;
603
- if let Some ( errno_place) = this. active_thread_ref ( ) . last_error {
604
- Ok ( errno_place)
603
+ if let Some ( errno_place) = this. active_thread_ref ( ) . last_error . as_ref ( ) {
604
+ Ok ( errno_place. clone ( ) )
605
605
} else {
606
606
// Allocate new place, set initial value to 0.
607
607
let errno_layout = this. machine . layouts . u32 ;
608
608
let errno_place = this. allocate ( errno_layout, MiriMemoryKind :: Machine . into ( ) ) ?;
609
- this. write_scalar ( Scalar :: from_u32 ( 0 ) , & errno_place. into ( ) ) ?;
610
- this. active_thread_mut ( ) . last_error = Some ( errno_place) ;
609
+ this. write_scalar ( Scalar :: from_u32 ( 0 ) , & errno_place) ?;
610
+ this. active_thread_mut ( ) . last_error = Some ( errno_place. clone ( ) ) ;
611
611
Ok ( errno_place)
612
612
}
613
613
}
@@ -616,14 +616,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
616
616
fn set_last_error ( & mut self , scalar : Scalar < Provenance > ) -> InterpResult < ' tcx > {
617
617
let this = self . eval_context_mut ( ) ;
618
618
let errno_place = this. last_error_place ( ) ?;
619
- this. write_scalar ( scalar, & errno_place. into ( ) )
619
+ this. write_scalar ( scalar, & errno_place)
620
620
}
621
621
622
622
/// Gets the last error variable.
623
623
fn get_last_error ( & mut self ) -> InterpResult < ' tcx , Scalar < Provenance > > {
624
624
let this = self . eval_context_mut ( ) ;
625
625
let errno_place = this. last_error_place ( ) ?;
626
- this. read_scalar ( & errno_place. into ( ) )
626
+ this. read_scalar ( & errno_place)
627
627
}
628
628
629
629
/// This function tries to produce the most similar OS error from the `std::io::ErrorKind`
@@ -725,7 +725,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
725
725
726
726
let mplace = MPlaceTy :: from_aligned_ptr ( ptr, layout) ;
727
727
728
- this. check_mplace ( mplace) ?;
728
+ this. check_mplace ( & mplace) ?;
729
729
730
730
Ok ( mplace)
731
731
}
@@ -772,7 +772,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
772
772
) -> InterpResult < ' tcx , Scalar < Provenance > > {
773
773
let this = self . eval_context_ref ( ) ;
774
774
let value_place = this. deref_operand_and_offset ( op, offset, base_layout, value_layout) ?;
775
- this. read_scalar ( & value_place. into ( ) )
775
+ this. read_scalar ( & value_place)
776
776
}
777
777
778
778
fn write_scalar_at_offset (
@@ -785,7 +785,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
785
785
) -> InterpResult < ' tcx , ( ) > {
786
786
let this = self . eval_context_mut ( ) ;
787
787
let value_place = this. deref_operand_and_offset ( op, offset, base_layout, value_layout) ?;
788
- this. write_scalar ( value, & value_place. into ( ) )
788
+ this. write_scalar ( value, & value_place)
789
789
}
790
790
791
791
/// Parse a `timespec` struct and return it as a `std::time::Duration`. It returns `None`
@@ -797,10 +797,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
797
797
) -> InterpResult < ' tcx , Option < Duration > > {
798
798
let this = self . eval_context_mut ( ) ;
799
799
let seconds_place = this. project_field ( tp, 0 ) ?;
800
- let seconds_scalar = this. read_scalar ( & seconds_place. into ( ) ) ?;
800
+ let seconds_scalar = this. read_scalar ( & seconds_place) ?;
801
801
let seconds = seconds_scalar. to_target_isize ( this) ?;
802
802
let nanoseconds_place = this. project_field ( tp, 1 ) ?;
803
- let nanoseconds_scalar = this. read_scalar ( & nanoseconds_place. into ( ) ) ?;
803
+ let nanoseconds_scalar = this. read_scalar ( & nanoseconds_place) ?;
804
804
let nanoseconds = nanoseconds_scalar. to_target_isize ( this) ?;
805
805
806
806
Ok ( try {
0 commit comments