File tree 2 files changed +25
-0
lines changed
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,24 @@ fn transmute() {
163
163
) ;
164
164
}
165
165
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
+
166
184
#[ test]
167
185
fn const_eval_select ( ) {
168
186
check_number (
Original file line number Diff line number Diff line change @@ -888,6 +888,13 @@ impl Evaluator<'_> {
888
888
}
889
889
not_supported ! ( "FnOnce was not available for executing const_eval_select" ) ;
890
890
}
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
+ }
891
898
_ => not_supported ! ( "unknown intrinsic {name}" ) ,
892
899
}
893
900
}
You can’t perform that action at this time.
0 commit comments