-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
3 changed files
with
35 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0fadfc5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from pcwalton
at https://github.com/dim-an/rust/commit/0fadfc5fb7de47f0ffcb55a8bbfe0a75c2a4dbee
0fadfc5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging dim-an/rust/fix-struct-match = 0fadfc5 into auto
0fadfc5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dim-an/rust/fix-struct-match = 0fadfc5 merged ok, testing candidate = a931e04
0fadfc5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/840
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/843
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt/builds/844
success: http://buildbot.rust-lang.org/builders/auto-mac-all-opt/builds/840
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/858
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt/builds/860
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/858
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt/builds/862
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt-vg/builds/867
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android/builds/31
success: http://buildbot.rust-lang.org/builders/auto-linux-all-opt/builds/860
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/843
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt/builds/857
success: http://buildbot.rust-lang.org/builders/auto-bsd-64-opt/builds/630
0fadfc5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = a931e04