Skip to content

Commit 3ff1024

Browse files
committed
Test async fn
1 parent c5a4e07 commit 3ff1024

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// edition: 2018
2+
// known-bug: #120240
3+
#![feature(never_patterns)]
4+
#![allow(incomplete_features)]
5+
6+
fn main() {}
7+
8+
enum Void {}
9+
10+
// Divergence is not detected.
11+
async fn async_never(!: Void) -> ! {} // gives an error
12+
13+
// Divergence is detected
14+
async fn async_let(x: Void) -> ! {
15+
let ! = x;
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/120240-async-fn-never-arg.rs:11:36
3+
|
4+
LL | async fn async_never(!: Void) -> ! {} // gives an error
5+
| ^^ expected `!`, found `()`
6+
|
7+
= note: expected type `!`
8+
found unit type `()`
9+
10+
error: aborting due to 1 previous error
11+
12+
For more information about this error, try `rustc --explain E0308`.

tests/ui/rfcs/rfc-0000-never_patterns/diverges.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// check-pass
2+
// edition: 2018
23
#![feature(never_patterns)]
34
#![allow(incomplete_features)]
45
#![deny(unreachable_patterns)]
@@ -30,3 +31,8 @@ fn never_match() -> ! {
3031
// Ensures this typechecks because of divergence and not the type of the match expression.
3132
println!();
3233
}
34+
35+
// Note: divergence is not detected for async fns when the `!` is in the argument (#120240).
36+
async fn async_let(x: Void) -> ! {
37+
let ! = x;
38+
}

0 commit comments

Comments
 (0)