test derived from #74961

This commit is contained in:
Ding Xiang Fei 2020-08-06 16:18:46 +08:00
parent 7f5721c3f4
commit 323f0794c0
No known key found for this signature in database
GPG Key ID: 3CD748647EEF6359
1 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,29 @@
// check-pass
// edition:2018
// This test is derived from
// https://github.com/rust-lang/rust/issues/74961#issuecomment-666893845
// by @SNCPlay42
// This test demonstrates that, in `async fn g()`,
// indeed a temporary borrow `y` from `x` is live
// while `f().await` is being evaluated.
// Thus, `&'_ A` should be included in type signature
// of the underlying generator.
#[derive(PartialEq, Eq)]
struct A;
async fn f() -> A {
A
}
async fn g() {
let x = A;
match x {
y if f().await == y => {}
_ => {}
}
}
fn main() {}