Skip to content

Commit 7b6258b

Browse files
committed
add C-unwind test case
1 parent a61c641 commit 7b6258b

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

tests/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@ const unsafe extern "C" fn foo() -> usize {
22
5
33
}
44

5+
const unsafe extern "C-unwind" fn bar() -> usize {
6+
5
7+
}
8+
59
fn main() {
610
let a: [u8; foo()];
711
//~^ call to unsafe function `foo` is unsafe and requires unsafe function or block
812
foo();
913
//~^ ERROR call to unsafe function `foo` is unsafe and requires unsafe function or block
14+
let b: [u8; bar()];
15+
//~^ call to unsafe function `bar` is unsafe and requires unsafe function or block
16+
bar();
17+
//~^ ERROR call to unsafe function `bar` is unsafe and requires unsafe function or block
1018
}
Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
11
error[E0133]: call to unsafe function `foo` is unsafe and requires unsafe function or block
2-
--> $DIR/const-extern-fn-requires-unsafe.rs:8:5
2+
--> $DIR/const-extern-fn-requires-unsafe.rs:12:5
33
|
44
LL | foo();
55
| ^^^^^ call to unsafe function
66
|
77
= note: consult the function's documentation for information on how to avoid undefined behavior
88

9+
error[E0133]: call to unsafe function `bar` is unsafe and requires unsafe function or block
10+
--> $DIR/const-extern-fn-requires-unsafe.rs:16:5
11+
|
12+
LL | bar();
13+
| ^^^^^ call to unsafe function
14+
|
15+
= note: consult the function's documentation for information on how to avoid undefined behavior
16+
917
error[E0133]: call to unsafe function `foo` is unsafe and requires unsafe function or block
10-
--> $DIR/const-extern-fn-requires-unsafe.rs:6:17
18+
--> $DIR/const-extern-fn-requires-unsafe.rs:10:17
1119
|
1220
LL | let a: [u8; foo()];
1321
| ^^^^^ call to unsafe function
1422
|
1523
= note: consult the function's documentation for information on how to avoid undefined behavior
1624

17-
error: aborting due to 2 previous errors
25+
error[E0133]: call to unsafe function `bar` is unsafe and requires unsafe function or block
26+
--> $DIR/const-extern-fn-requires-unsafe.rs:14:17
27+
|
28+
LL | let b: [u8; bar()];
29+
| ^^^^^ call to unsafe function
30+
|
31+
= note: consult the function's documentation for information on how to avoid undefined behavior
32+
33+
error: aborting due to 4 previous errors
1834

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

0 commit comments

Comments
 (0)