This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -586,6 +586,24 @@ fn write_bytes() {
586586 ) ;
587587}
588588
589+ #[ test]
590+ fn write_via_move ( ) {
591+ check_number (
592+ r#"
593+ extern "rust-intrinsic" {
594+ fn write_via_move<T>(ptr: *mut T, value: T);
595+ }
596+
597+ const GOAL: i32 = unsafe {
598+ let mut x = 2;
599+ write_via_move(&mut x, 100);
600+ x
601+ };
602+ "# ,
603+ 100 ,
604+ ) ;
605+ }
606+
589607#[ test]
590608fn copy ( ) {
591609 check_number (
Original file line number Diff line number Diff line change @@ -1200,6 +1200,22 @@ impl Evaluator<'_> {
12001200 let addr = Address :: from_bytes ( arg. interval . get ( self ) ?) ?;
12011201 destination. write_from_interval ( self , Interval { addr, size : destination. size } )
12021202 }
1203+ "write_via_move" => {
1204+ let [ ptr, val] = args else {
1205+ return Err ( MirEvalError :: TypeError ( "write_via_move args are not provided" ) ) ;
1206+ } ;
1207+ let dst = Address :: from_bytes ( ptr. get ( self ) ?) ?;
1208+ let Some ( ty) =
1209+ generic_args. as_slice ( Interner ) . get ( 0 ) . and_then ( |it| it. ty ( Interner ) )
1210+ else {
1211+ return Err ( MirEvalError :: TypeError (
1212+ "write_via_copy generic arg is not provided" ,
1213+ ) ) ;
1214+ } ;
1215+ let size = self . size_of_sized ( ty, locals, "write_via_move ptr type" ) ?;
1216+ Interval { addr : dst, size } . write_from_interval ( self , val. interval ) ?;
1217+ Ok ( ( ) )
1218+ }
12031219 "write_bytes" => {
12041220 let [ dst, val, count] = args else {
12051221 return Err ( MirEvalError :: TypeError ( "write_bytes args are not provided" ) ) ;
You can’t perform that action at this time.
0 commit comments