]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #8350 : dim-an/rust/fix-struct-match, r=pcwalton
authorbors <bors@rust-lang.org>
Fri, 9 Aug 2013 04:41:05 +0000 (21:41 -0700)
committerbors <bors@rust-lang.org>
Fri, 9 Aug 2013 04:41:05 +0000 (21:41 -0700)
Code that collects fields in struct-like patterns used to ignore
wildcard patterns like `Foo{_}`. But `enter_defaults` considered
struct-like patterns as default in order to overcome this
(accoring to my understanding of situation).

However such behaviour caused code like this:
```
enum E {
    Foo{f: int},
    Bar
}
let e = Bar;
match e {
    Foo{f: _f} => { /* do something (1) */ }
    _ => { /* do something (2) */ }
}
```
consider pattern `Foo{f: _f}` as default. That caused inproper behaviour
and even segfaults while trying to destruct `Bar` as `Foo{f: _f}`.
Issues: #5625 , #5530.

This patch fixes `collect_record_or_struct_fields` to split cases of
single wildcard struct-like pattern and no struct-like pattern at all.
Former case resolved with `enter_rec_or_struct` (and not with
`enter_defaults`).

Closes #5625.
Closes #5530.

1  2 
src/librustc/driver/driver.rs

Simple merge