Test that unsafe extern defines unsafe fns
This commit is contained in:
parent
6d670b74e5
commit
46cd80b691
@ -0,0 +1,11 @@
|
||||
error[E0133]: call to unsafe function `test1` is unsafe and requires unsafe function or block
|
||||
--> $DIR/extern-items-unsafe.rs:11:5
|
||||
|
|
||||
LL | test1(i);
|
||||
| ^^^^^^^^ call to unsafe function
|
||||
|
|
||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0133`.
|
@ -0,0 +1,11 @@
|
||||
error[E0133]: call to unsafe function `test1` is unsafe and requires unsafe block
|
||||
--> $DIR/extern-items-unsafe.rs:11:5
|
||||
|
|
||||
LL | test1(i);
|
||||
| ^^^^^^^^ call to unsafe function
|
||||
|
|
||||
= note: consult the function's documentation for information on how to avoid undefined behavior
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0133`.
|
@ -0,0 +1,21 @@
|
||||
//@ revisions: edition2021 edition2024
|
||||
//@[edition2021] edition:2021
|
||||
//@[edition2024] edition:2024
|
||||
//@[edition2024] compile-flags: -Zunstable-options
|
||||
|
||||
unsafe extern "C" {
|
||||
fn test1(i: i32);
|
||||
}
|
||||
|
||||
fn test2(i: i32) {
|
||||
test1(i);
|
||||
//~^ ERROR: call to unsafe function `test1` is unsafe
|
||||
}
|
||||
|
||||
fn test3(i: i32) {
|
||||
unsafe {
|
||||
test1(i);
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user