Test async fn

This commit is contained in:
Nadrieril 2024-01-18 21:14:16 +01:00
parent c5a4e074f0
commit 3ff10242fe
3 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,16 @@
// edition: 2018
// known-bug: #120240
#![feature(never_patterns)]
#![allow(incomplete_features)]
fn main() {}
enum Void {}
// Divergence is not detected.
async fn async_never(!: Void) -> ! {} // gives an error
// Divergence is detected
async fn async_let(x: Void) -> ! {
let ! = x;
}

View File

@ -0,0 +1,12 @@
error[E0308]: mismatched types
--> $DIR/120240-async-fn-never-arg.rs:11:36
|
LL | async fn async_never(!: Void) -> ! {} // gives an error
| ^^ expected `!`, found `()`
|
= note: expected type `!`
found unit type `()`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.

View File

@ -1,4 +1,5 @@
// check-pass
// edition: 2018
#![feature(never_patterns)]
#![allow(incomplete_features)]
#![deny(unreachable_patterns)]
@ -30,3 +31,8 @@ fn never_match() -> ! {
// Ensures this typechecks because of divergence and not the type of the match expression.
println!();
}
// Note: divergence is not detected for async fns when the `!` is in the argument (#120240).
async fn async_let(x: Void) -> ! {
let ! = x;
}