Auto merge of #78393 - SNCPlay42:match-if-guard, r=tmandry
Always record reference to binding in match if guards When encountering a binding from a `match` pattern in its `if` guard when computing a generator's interior types, we must always record the type of a reference to the binding because of how `if` guards are lowered to MIR. This was missed in #75213 because the binding in that test case was autorefed and we recorded that adjusted type anyway. Fixes #78366
This commit is contained in:
commit
8df58ae03a
2 changed files with 32 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
|||
// check-pass
|
||||
// build-pass
|
||||
// edition:2018
|
||||
|
||||
// This test is derived from
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
// of the underlying generator.
|
||||
|
||||
async fn f() -> u8 { 1 }
|
||||
async fn foo() -> [bool; 10] { [false; 10] }
|
||||
|
||||
pub async fn g(x: u8) {
|
||||
match x {
|
||||
|
|
@ -19,6 +20,24 @@ pub async fn g(x: u8) {
|
|||
}
|
||||
}
|
||||
|
||||
// #78366: check the reference to the binding is recorded even if the binding is not autorefed
|
||||
|
||||
async fn h(x: usize) {
|
||||
match x {
|
||||
y if foo().await[y] => (),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
async fn i(x: u8) {
|
||||
match x {
|
||||
y if f().await == y + 1 => (),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _ = g(10);
|
||||
let _ = h(9);
|
||||
let _ = i(8);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue