Skip to content

Commit

Permalink
switch the test to an actual MCVE
Browse files Browse the repository at this point in the history
  • Loading branch information
dingxiangfei2009 committed Oct 13, 2020
1 parent 66345d9 commit df127b8
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/test/ui/generator/yielding-in-match-guards.rs
Expand Up @@ -2,28 +2,23 @@
// edition:2018

// This test is derived from
// https://github.com/rust-lang/rust/issues/74961#issuecomment-666893845
// by @SNCPlay42
// https://github.com/rust-lang/rust/issues/72651#issuecomment-668720468

// 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
// Thus, `&'_ u8` should be included in type signature
// of the underlying generator.

#[derive(PartialEq, Eq)]
struct A;
async fn f() -> u8 { 1 }

async fn f() -> A {
A
}

async fn g() {
let x = A;
pub async fn g(x: u8) {
match x {
y if f().await == y => {}
_ => {}
y if f().await == y => (),
_ => (),
}
}

fn main() {}
fn main() {
let _ = g(10);
}

0 comments on commit df127b8

Please sign in to comment.