Skip to content

Commit a0ac188

Browse files
committed
Regression test for the bug.
1 parent 97f3d21 commit a0ac188

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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.
4+
//
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.
10+
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
13+
// guard.
14+
//
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.
18+
19+
// run-pass
20+
21+
#![feature(nll)]
22+
23+
fn foo(x: &mut Result<(u32, u32), (u32, u32)>) -> u32 {
24+
match *x {
25+
Ok((ref mut v, _)) | Err((_, ref mut v)) if *v > 0 => { *v }
26+
_ => { 0 }
27+
}
28+
}
29+
30+
fn main() {
31+
assert_eq!(foo(&mut Ok((3, 4))), 3);
32+
assert_eq!(foo(&mut Err((3, 4))), 4);
33+
}

0 commit comments

Comments
 (0)