Skip to content

Commit

Permalink
Test async fn
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadrieril committed Jan 22, 2024
1 parent c5a4e07 commit 3ff1024
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/ui/rfcs/rfc-0000-never_patterns/120240-async-fn-never-arg.rs
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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`.
6 changes: 6 additions & 0 deletions tests/ui/rfcs/rfc-0000-never_patterns/diverges.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// check-pass
// edition: 2018
#![feature(never_patterns)]
#![allow(incomplete_features)]
#![deny(unreachable_patterns)]
Expand Down Expand Up @@ -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;
}

0 comments on commit 3ff1024

Please sign in to comment.