File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,24 @@ fn transmute() {
163163 ) ;
164164}
165165
166+ #[ test]
167+ fn read_via_copy ( ) {
168+ check_number (
169+ r#"
170+ extern "rust-intrinsic" {
171+ pub fn read_via_copy<T>(e: *const T) -> T;
172+ pub fn volatile_load<T>(e: *const T) -> T;
173+ }
174+
175+ const GOAL: i32 = {
176+ let x = 2;
177+ read_via_copy(&x) + volatile_load(&x)
178+ };
179+ "# ,
180+ 4 ,
181+ ) ;
182+ }
183+
166184#[ test]
167185fn const_eval_select ( ) {
168186 check_number (
Original file line number Diff line number Diff line change @@ -888,6 +888,13 @@ impl Evaluator<'_> {
888888 }
889889 not_supported ! ( "FnOnce was not available for executing const_eval_select" ) ;
890890 }
891+ "read_via_copy" | "volatile_load" => {
892+ let [ arg] = args else {
893+ return Err ( MirEvalError :: TypeError ( "read_via_copy args are not provided" ) ) ;
894+ } ;
895+ let addr = Address :: from_bytes ( arg. interval . get ( self ) ?) ?;
896+ destination. write_from_interval ( self , Interval { addr, size : destination. size } )
897+ }
891898 _ => not_supported ! ( "unknown intrinsic {name}" ) ,
892899 }
893900 }
You can’t perform that action at this time.
0 commit comments