]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/issue-51348-multi-ref-mut-in-guard.rs
Rollup merge of #106441 - mllken:abstract-socket-noref, r=joshtriplett
[rust.git] / tests / ui / borrowck / issue-51348-multi-ref-mut-in-guard.rs
1 // We used to ICE if you had a single match arm with multiple
2 // candidate patterns with `ref mut` identifiers used in the arm's
3 // guard.
4 //
5 // Also, this test expands on the original bug's example by actually
6 // trying to double check that we are matching against the right part
7 // of the input data based on which candidate pattern actually fired.
8
9 // run-pass
10
11 fn foo(x: &mut Result<(u32, u32), (u32, u32)>) -> u32 {
12     match *x {
13         Ok((ref mut v, _)) | Err((_, ref mut v)) if *v > 0 => { *v }
14         _ => { 0 }
15     }
16 }
17
18 fn main() {
19     assert_eq!(foo(&mut Ok((3, 4))), 3);
20     assert_eq!(foo(&mut Err((3, 4))), 4);
21 }