Skip to content

Commit 117c8b1

Browse files
committed
Move closure-to-extern-fn-ptr-coercion tests into ui
1 parent 4f096f4 commit 117c8b1

6 files changed

+31
-17
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
fn main() {
22
let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
33
//~^ ERROR E0133
4-
let _: unsafe extern "C" fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
5-
//~^ ERROR E0133
64
let _: unsafe fn() = || unsafe { ::std::pin::Pin::new_unchecked(&0_u8); }; // OK
7-
let _: unsafe extern "C" fn() = || unsafe { ::std::pin::Pin::new_unchecked(&0_u8); }; // OK
85
}

src/test/run-pass/typeck-closure-to-extern-c-fn-ptr.rs

-7
This file was deleted.

src/test/run-pass/typeck-closure-to-unsafe-extern-c-fn-ptr.rs

-7
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// compile-pass
2+
3+
fn call_extern_c(func: extern "C" fn()) {
4+
func()
5+
}
6+
7+
unsafe fn call_unsafe_extern_c(func: unsafe extern "C" fn()) {
8+
func()
9+
}
10+
11+
pub fn main() {
12+
call_extern_c(|| {});
13+
unsafe {
14+
call_unsafe_extern_c(|| {});
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
let _: unsafe extern "C" fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); }; //~ ERROR E0133
3+
let _: unsafe extern "C" fn() = || unsafe { ::std::pin::Pin::new_unchecked(&0_u8); }; // OK
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
2+
--> $DIR/coerce-unsafe-closure-to-unsafe-extern-fn-ptr.rs:2:42
3+
|
4+
LL | let _: unsafe extern "C" fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
6+
|
7+
= note: consult the function's documentation for information on how to avoid undefined behavior
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0133`.

0 commit comments

Comments
 (0)