mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 01:34:21 +00:00
test derived from #74961
This commit is contained in:
parent
7f5721c3f4
commit
323f0794c0
29
src/test/ui/generator/yielding-in-match-guards.rs
Normal file
29
src/test/ui/generator/yielding-in-match-guards.rs
Normal 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() {}
|
Loading…
Reference in New Issue
Block a user