Skip to content

Commit 65978cf

Browse files
committed
Test that unsafe extern defines unsafe fns
1 parent a4115fa commit 65978cf

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
unsafe extern "C" {
2+
fn test1(i: i32);
3+
}
4+
5+
fn test2(i: i32) {
6+
test1(i);
7+
//~^ ERROR: call to unsafe function `test1` is unsafe and requires unsafe function or block [E0133]
8+
}
9+
10+
unsafe fn test3(i: i32) {
11+
test1(i);
12+
}
13+
14+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0133]: call to unsafe function `test1` is unsafe and requires unsafe function or block
2+
--> $DIR/extern-items-unsafe.rs:6:5
3+
|
4+
LL | test1(i);
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 1 previous error
10+
11+
For more information about this error, try `rustc --explain E0133`.

0 commit comments

Comments
 (0)