Skip to content

Commit 60f480d

Browse files
committed
test E0133 when calling free/impl async unsafe fn in async fn
1 parent e65c1c4 commit 60f480d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/test/ui/async-await/async-unsafe-fn-call-in-safe.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ impl S {
1010

1111
async unsafe fn f() {}
1212

13+
async fn g() {
14+
S::f(); //~ ERROR call to unsafe function is unsafe
15+
f(); //~ ERROR call to unsafe function is unsafe
16+
}
17+
1318
fn main() {
1419
S::f(); //~ ERROR call to unsafe function is unsafe
1520
f(); //~ ERROR call to unsafe function is unsafe

src/test/ui/async-await/async-unsafe-fn-call-in-safe.stderr

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@ LL | f();
1414
|
1515
= note: consult the function's documentation for information on how to avoid undefined behavior
1616

17-
error: aborting due to 2 previous errors
17+
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
18+
--> $DIR/async-unsafe-fn-call-in-safe.rs:19:5
19+
|
20+
LL | S::f();
21+
| ^^^^^^ call to unsafe function
22+
|
23+
= note: consult the function's documentation for information on how to avoid undefined behavior
24+
25+
error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
26+
--> $DIR/async-unsafe-fn-call-in-safe.rs:20:5
27+
|
28+
LL | f();
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)