Skip to content

Commit 420d177

Browse files
committed
Add if let tests
1 parent 8021192 commit 420d177

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

tests/ui/nll/match-cfg-fake-edges.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,34 @@ fn all_patterns_are_tested() {
88
// Even though `x` is never actually moved out of, we don't want borrowck results to be based on
99
// whether MIR lowering reveals which patterns are unreachable.
1010
let x = String::new();
11-
let _ = match true {
11+
match true {
1212
_ => {},
1313
_ => drop(x),
14-
};
14+
}
1515
// Borrowck must not know the second arm is never run.
1616
drop(x); //~ ERROR use of moved value
1717

18+
let x = String::new();
19+
if let _ = true {
20+
} else {
21+
drop(x)
22+
}
23+
// Borrowck must not know the else branch is never run.
24+
drop(x); //~ ERROR use of moved value
25+
1826
let x = (String::new(), String::new());
1927
match x {
2028
(y, _) | (_, y) => (),
2129
}
2230
&x.0; //~ ERROR borrow of moved value
2331
// Borrowck must not know the second pattern never matches.
2432
&x.1; //~ ERROR borrow of moved value
33+
34+
let x = (String::new(), String::new());
35+
let (y, _) | (_, y) = x;
36+
&x.0; //~ ERROR borrow of moved value
37+
// Borrowck must not know the second pattern never matches.
38+
&x.1; //~ ERROR borrow of moved value
2539
}
2640

2741
#[rustfmt::skip]

0 commit comments

Comments
 (0)