File tree 2 files changed +44
-0
lines changed
src/test/ui/consts/miri_unleashed
2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Checks that we report ABI mismatches for "const extern fn"
2
+ // compile-flags: -Z unleash-the-miri-inside-of-you
3
+
4
+ #![ feature( const_extern_fn) ]
5
+
6
+ const extern "C" fn c_fn ( ) { }
7
+
8
+ const fn call_rust_fn ( my_fn : extern "Rust" fn ( ) ) {
9
+ my_fn ( ) ; //~ ERROR any use of this value will cause an error
10
+ //~^ WARN skipping const checks
11
+ }
12
+
13
+ const VAL : ( ) = call_rust_fn ( unsafe { std:: mem:: transmute ( c_fn as extern "C" fn ( ) ) } ) ;
14
+ //~^ WARN skipping const checks
15
+
16
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ warning: skipping const checks
2
+ --> $DIR/abi-mismatch.rs:9:5
3
+ |
4
+ LL | my_fn();
5
+ | ^^^^^^^
6
+
7
+ warning: skipping const checks
8
+ --> $DIR/abi-mismatch.rs:13:39
9
+ |
10
+ LL | const VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) });
11
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12
+
13
+ error: any use of this value will cause an error
14
+ --> $DIR/abi-mismatch.rs:9:5
15
+ |
16
+ LL | my_fn();
17
+ | ^^^^^^^
18
+ | |
19
+ | tried to call a function with ABI C using caller ABI Rust
20
+ | inside call to `call_rust_fn` at $DIR/abi-mismatch.rs:13:17
21
+ ...
22
+ LL | const VAL: () = call_rust_fn(unsafe { std::mem::transmute(c_fn as extern "C" fn()) });
23
+ | --------------------------------------------------------------------------------------
24
+ |
25
+ = note: `#[deny(const_err)]` on by default
26
+
27
+ error: aborting due to previous error
28
+
You can’t perform that action at this time.
0 commit comments