@@ -166,7 +166,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
166166 let const_val = this. eval_global ( cid, None ) . unwrap_or_else ( |err| {
167167 panic ! ( "failed to evaluate required Rust item: {path:?}\n {err:?}" )
168168 } ) ;
169- this. read_scalar ( & const_val. into ( ) )
169+ this. read_scalar ( & const_val)
170170 . unwrap_or_else ( |err| panic ! ( "failed to read required Rust item: {path:?}\n {err:?}" ) )
171171 }
172172
@@ -231,7 +231,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
231231 }
232232
233233 /// 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 > > (
235235 & self ,
236236 base : & P ,
237237 name : & str ,
@@ -252,13 +252,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
252252 fn write_int (
253253 & mut self ,
254254 i : impl Into < i128 > ,
255- dest : & PlaceTy < ' tcx , Provenance > ,
255+ dest : & impl Writeable < ' tcx , Provenance > ,
256256 ) -> 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 )
260260 } 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 )
262262 } ;
263263 self . eval_context_mut ( ) . write_scalar ( val, dest)
264264 }
@@ -267,12 +267,12 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
267267 fn write_int_fields (
268268 & mut self ,
269269 values : & [ i128 ] ,
270- dest : & MPlaceTy < ' tcx , Provenance > ,
270+ dest : & impl Writeable < ' tcx , Provenance > ,
271271 ) -> InterpResult < ' tcx > {
272272 let this = self . eval_context_mut ( ) ;
273273 for ( idx, & val) in values. iter ( ) . enumerate ( ) {
274274 let field = this. project_field ( dest, idx) ?;
275- this. write_int ( val, & field. into ( ) ) ?;
275+ this. write_int ( val, & field) ?;
276276 }
277277 Ok ( ( ) )
278278 }
@@ -281,18 +281,18 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
281281 fn write_int_fields_named (
282282 & mut self ,
283283 values : & [ ( & str , i128 ) ] ,
284- dest : & MPlaceTy < ' tcx , Provenance > ,
284+ dest : & impl Writeable < ' tcx , Provenance > ,
285285 ) -> InterpResult < ' tcx > {
286286 let this = self . eval_context_mut ( ) ;
287287 for & ( name, val) in values. iter ( ) {
288288 let field = this. project_field_named ( dest, name) ?;
289- this. write_int ( val, & field. into ( ) ) ?;
289+ this. write_int ( val, & field) ?;
290290 }
291291 Ok ( ( ) )
292292 }
293293
294294 /// 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 > {
296296 self . write_int ( 0 , dest)
297297 }
298298
@@ -600,14 +600,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
600600 /// necessary.
601601 fn last_error_place ( & mut self ) -> InterpResult < ' tcx , MPlaceTy < ' tcx , Provenance > > {
602602 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 ( ) )
605605 } else {
606606 // Allocate new place, set initial value to 0.
607607 let errno_layout = this. machine . layouts . u32 ;
608608 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 ( ) ) ;
611611 Ok ( errno_place)
612612 }
613613 }
@@ -616,14 +616,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
616616 fn set_last_error ( & mut self , scalar : Scalar < Provenance > ) -> InterpResult < ' tcx > {
617617 let this = self . eval_context_mut ( ) ;
618618 let errno_place = this. last_error_place ( ) ?;
619- this. write_scalar ( scalar, & errno_place. into ( ) )
619+ this. write_scalar ( scalar, & errno_place)
620620 }
621621
622622 /// Gets the last error variable.
623623 fn get_last_error ( & mut self ) -> InterpResult < ' tcx , Scalar < Provenance > > {
624624 let this = self . eval_context_mut ( ) ;
625625 let errno_place = this. last_error_place ( ) ?;
626- this. read_scalar ( & errno_place. into ( ) )
626+ this. read_scalar ( & errno_place)
627627 }
628628
629629 /// 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> {
725725
726726 let mplace = MPlaceTy :: from_aligned_ptr ( ptr, layout) ;
727727
728- this. check_mplace ( mplace) ?;
728+ this. check_mplace ( & mplace) ?;
729729
730730 Ok ( mplace)
731731 }
@@ -772,7 +772,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
772772 ) -> InterpResult < ' tcx , Scalar < Provenance > > {
773773 let this = self . eval_context_ref ( ) ;
774774 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)
776776 }
777777
778778 fn write_scalar_at_offset (
@@ -785,7 +785,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
785785 ) -> InterpResult < ' tcx , ( ) > {
786786 let this = self . eval_context_mut ( ) ;
787787 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)
789789 }
790790
791791 /// 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> {
797797 ) -> InterpResult < ' tcx , Option < Duration > > {
798798 let this = self . eval_context_mut ( ) ;
799799 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) ?;
801801 let seconds = seconds_scalar. to_target_isize ( this) ?;
802802 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) ?;
804804 let nanoseconds = nanoseconds_scalar. to_target_isize ( this) ?;
805805
806806 Ok ( try {
0 commit comments