Skip to content

Commit

Permalink
Move closure-to-extern-fn-ptr-coercion tests into ui
Browse files Browse the repository at this point in the history
  • Loading branch information
jplatte committed Jun 11, 2019
1 parent 4f096f4 commit 117c8b1
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
fn main() {
let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
//~^ ERROR E0133
let _: unsafe extern "C" fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
//~^ ERROR E0133
let _: unsafe fn() = || unsafe { ::std::pin::Pin::new_unchecked(&0_u8); }; // OK
let _: unsafe extern "C" fn() = || unsafe { ::std::pin::Pin::new_unchecked(&0_u8); }; // OK
}
7 changes: 0 additions & 7 deletions src/test/run-pass/typeck-closure-to-extern-c-fn-ptr.rs

This file was deleted.

7 changes: 0 additions & 7 deletions src/test/run-pass/typeck-closure-to-unsafe-extern-c-fn-ptr.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// compile-pass

fn call_extern_c(func: extern "C" fn()) {
func()
}

unsafe fn call_unsafe_extern_c(func: unsafe extern "C" fn()) {
func()
}

pub fn main() {
call_extern_c(|| {});
unsafe {
call_unsafe_extern_c(|| {});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn main() {
let _: unsafe extern "C" fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); }; //~ ERROR E0133
let _: unsafe extern "C" fn() = || unsafe { ::std::pin::Pin::new_unchecked(&0_u8); }; // OK
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
--> $DIR/coerce-unsafe-closure-to-unsafe-extern-fn-ptr.rs:2:42
|
LL | let _: unsafe extern "C" fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
= note: consult the function's documentation for information on how to avoid undefined behavior

error: aborting due to previous error

For more information about this error, try `rustc --explain E0133`.

0 comments on commit 117c8b1

Please sign in to comment.