-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move closure-to-extern-fn-ptr-coercion tests into ui
- Loading branch information
Showing
6 changed files
with
31 additions
and
17 deletions.
There are no files selected for viewing
3 changes: 0 additions & 3 deletions
3
src/test/compile-fail/coerce-unsafe-closure-to-unsafe-fn-ptr.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
src/test/run-pass/typeck-closure-to-unsafe-extern-c-fn-ptr.rs
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
src/test/ui/closure-to-extern-fn-ptr-coercion/coerce-closure-to-extern-c-fn-ptr.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(|| {}); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...est/ui/closure-to-extern-fn-ptr-coercion/coerce-unsafe-closure-to-unsafe-extern-fn-ptr.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
11 changes: 11 additions & 0 deletions
11
...ui/closure-to-extern-fn-ptr-coercion/coerce-unsafe-closure-to-unsafe-extern-fn-ptr.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`. |