Skip to content

Commit

Permalink
test derived from #74961
Browse files Browse the repository at this point in the history
  • Loading branch information
dingxiangfei2009 committed Oct 13, 2020
1 parent 7f5721c commit 323f079
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/test/ui/generator/yielding-in-match-guards.rs
@@ -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() {}

0 comments on commit 323f079

Please sign in to comment.