mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Test async fn
This commit is contained in:
parent
c5a4e074f0
commit
3ff10242fe
@ -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;
|
||||
}
|
@ -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`.
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user