1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // We used to ICE if you had a single match arm with multiple
12 // candidate patterns with `ref mut` identifiers used in the arm's
15 // Also, this test expands on the original bug's example by actually
16 // trying to double check that we are matching against the right part
17 // of the input data based on which candidate pattern actually fired.
23 fn foo(x: &mut Result<(u32, u32), (u32, u32)>) -> u32 {
25 Ok((ref mut v, _)) | Err((_, ref mut v)) if *v > 0 => { *v }
31 assert_eq!(foo(&mut Ok((3, 4))), 3);
32 assert_eq!(foo(&mut Err((3, 4))), 4);