2018-08-30 12:18:55 +00:00
|
|
|
// run-pass
|
|
|
|
|
Fix incorrect non-exhaustive matching for fixed length vecs
Code like this is fixed now:
```
fn foo(p: [u8, ..4]) {
match p {
[a, b, c, d] => {}
};
}
```
Invalid constructors are not reported as errors yet:
```
fn foo(p: [u8, ..4]) {
match p {
[_, _, _] => {} // this should be error
[_, _, _, _, _, .._] => {} // and this
_ => {}
}
}
```
Issue #8311 is partially fixed by this commit. Fixed-length arrays in
let statement are not yet allowed:
```
let [a, b, c] = [1, 2, 3]; // still fails
```
2013-08-07 18:07:24 +00:00
|
|
|
fn a() {
|
2015-01-25 21:05:03 +00:00
|
|
|
let x = [1, 2, 3];
|
Fix incorrect non-exhaustive matching for fixed length vecs
Code like this is fixed now:
```
fn foo(p: [u8, ..4]) {
match p {
[a, b, c, d] => {}
};
}
```
Invalid constructors are not reported as errors yet:
```
fn foo(p: [u8, ..4]) {
match p {
[_, _, _] => {} // this should be error
[_, _, _, _, _, .._] => {} // and this
_ => {}
}
}
```
Issue #8311 is partially fixed by this commit. Fixed-length arrays in
let statement are not yet allowed:
```
let [a, b, c] = [1, 2, 3]; // still fails
```
2013-08-07 18:07:24 +00:00
|
|
|
match x {
|
2013-09-19 05:04:03 +00:00
|
|
|
[1, 2, 4] => unreachable!(),
|
2013-11-28 20:22:53 +00:00
|
|
|
[0, 2, 3, ..] => unreachable!(),
|
|
|
|
[0, .., 3] => unreachable!(),
|
|
|
|
[0, ..] => unreachable!(),
|
Fix incorrect non-exhaustive matching for fixed length vecs
Code like this is fixed now:
```
fn foo(p: [u8, ..4]) {
match p {
[a, b, c, d] => {}
};
}
```
Invalid constructors are not reported as errors yet:
```
fn foo(p: [u8, ..4]) {
match p {
[_, _, _] => {} // this should be error
[_, _, _, _, _, .._] => {} // and this
_ => {}
}
}
```
Issue #8311 is partially fixed by this commit. Fixed-length arrays in
let statement are not yet allowed:
```
let [a, b, c] = [1, 2, 3]; // still fails
```
2013-08-07 18:07:24 +00:00
|
|
|
[1, 2, 3] => (),
|
2013-09-19 05:04:03 +00:00
|
|
|
[_, _, _] => unreachable!(),
|
Fix incorrect non-exhaustive matching for fixed length vecs
Code like this is fixed now:
```
fn foo(p: [u8, ..4]) {
match p {
[a, b, c, d] => {}
};
}
```
Invalid constructors are not reported as errors yet:
```
fn foo(p: [u8, ..4]) {
match p {
[_, _, _] => {} // this should be error
[_, _, _, _, _, .._] => {} // and this
_ => {}
}
}
```
Issue #8311 is partially fixed by this commit. Fixed-length arrays in
let statement are not yet allowed:
```
let [a, b, c] = [1, 2, 3]; // still fails
```
2013-08-07 18:07:24 +00:00
|
|
|
}
|
|
|
|
match x {
|
2013-11-28 20:22:53 +00:00
|
|
|
[..] => (),
|
Fix incorrect non-exhaustive matching for fixed length vecs
Code like this is fixed now:
```
fn foo(p: [u8, ..4]) {
match p {
[a, b, c, d] => {}
};
}
```
Invalid constructors are not reported as errors yet:
```
fn foo(p: [u8, ..4]) {
match p {
[_, _, _] => {} // this should be error
[_, _, _, _, _, .._] => {} // and this
_ => {}
}
}
```
Issue #8311 is partially fixed by this commit. Fixed-length arrays in
let statement are not yet allowed:
```
let [a, b, c] = [1, 2, 3]; // still fails
```
2013-08-07 18:07:24 +00:00
|
|
|
}
|
|
|
|
match x {
|
2013-11-28 20:22:53 +00:00
|
|
|
[_, _, _, ..] => (),
|
Fix incorrect non-exhaustive matching for fixed length vecs
Code like this is fixed now:
```
fn foo(p: [u8, ..4]) {
match p {
[a, b, c, d] => {}
};
}
```
Invalid constructors are not reported as errors yet:
```
fn foo(p: [u8, ..4]) {
match p {
[_, _, _] => {} // this should be error
[_, _, _, _, _, .._] => {} // and this
_ => {}
}
}
```
Issue #8311 is partially fixed by this commit. Fixed-length arrays in
let statement are not yet allowed:
```
let [a, b, c] = [1, 2, 3]; // still fails
```
2013-08-07 18:07:24 +00:00
|
|
|
}
|
|
|
|
match x {
|
|
|
|
[a, b, c] => {
|
|
|
|
assert_eq!(1, a);
|
|
|
|
assert_eq!(2, b);
|
|
|
|
assert_eq!(3, c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
a();
|
|
|
|
}
|