Skip to content

Refactor match checking to use HAIR#36695

Merged
bors merged 13 commits into
rust-lang:masterfrom
arielb1:literal-match
Oct 27, 2016
Merged

Refactor match checking to use HAIR#36695
bors merged 13 commits into
rust-lang:masterfrom
arielb1:literal-match

Conversation

@arielb1

@arielb1 arielb1 commented Sep 24, 2016

Copy link
Copy Markdown
Contributor

Refactor match checking to use HAIR instead of HIR, fixing quite a few bugs in the process.

r? @eddyb

Comment thread src/librustc_mir/hair/mod.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is moving parts of HAIR to rustc_const_eval a good idea? What about doing the opposite?
That is, move match checking to rustc_mir and perhaps even integrate it with MIR match building.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another idea would be to move it to rustc_typeck (and maybe have HAIR definitions in rustc).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

match checking uses a completely different algorithm than match building. HAIR patterns are basically independent of the rest of HAIR.

Comment thread src/librustc_const_eval/_match.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/build/src/librustc_const_eval/_match.rs:477: TODO is deprecated; use FIXME

@arielb1 arielb1 Sep 24, 2016

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TODO is the entire point of this PR. It will be removed before the merge.

@arielb1 arielb1 force-pushed the literal-match branch 2 times, most recently from 2200ac4 to 81fb5cf Compare September 29, 2016 22:33
@bors

bors commented Oct 1, 2016

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #36857) made this pull request unmergeable. Please resolve the merge conflicts.

@arielb1 arielb1 force-pushed the literal-match branch 4 times, most recently from d03f2d5 to 879cf61 Compare October 4, 2016 16:22
@bors

bors commented Oct 5, 2016

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #36814) made this pull request unmergeable. Please resolve the merge conflicts.

@bors

bors commented Oct 6, 2016

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #37002) made this pull request unmergeable. Please resolve the merge conflicts.

@bors

bors commented Oct 8, 2016

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #37039) made this pull request unmergeable. Please resolve the merge conflicts.

Convert byte literal pattern to byte array patterns when they are both
used together. so matching them is properly handled. I could've done the
conversion eagerly, but that could have caused a bad worst-case for
massive byte-array matches.

Fixes rust-lang#18027.
Fixes rust-lang#25051.
Fixes rust-lang#26510.
nested slice patterns have the same functionality as non-nested
ones, so flatten them in HAIR construction.

Fixes rust-lang#26158.
@arielb1 arielb1 changed the title [WIP] Refactor match checking to use HAIR Refactor match checking to use HAIR Oct 26, 2016

@eddyb eddyb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me with an explanation for the missing diagnostics, or a revert of their removal.



E0003: r##"
/*E0003: r##"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's with these two commented diagnostics?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E0002 was merged into E0004, and E0003 refers to a feature that does not exist anymore.

[NAN, _] => {},
_ => {},
};
//~^^^ WARNING unmatchable NaN in pattern, use the is_nan method in a guard instead

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the NaN warnings gone?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because you can't have floating-point patterns anymore.

@arielb1

arielb1 commented Oct 26, 2016

Copy link
Copy Markdown
Contributor Author

@bors r=eddyb

@bors

bors commented Oct 26, 2016

Copy link
Copy Markdown
Collaborator

📌 Commit 4157850 has been approved by eddyb

@arielb1

arielb1 commented Oct 26, 2016

Copy link
Copy Markdown
Contributor Author

added back the test for #6804

@bors r=eddyb

@bors

bors commented Oct 26, 2016

Copy link
Copy Markdown
Collaborator

📌 Commit 3f9ebb4 has been approved by eddyb

@bors

bors commented Oct 27, 2016

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 3f9ebb4 with merge 4a58463...

bors added a commit that referenced this pull request Oct 27, 2016
Refactor match checking to use HAIR

Refactor match checking to use HAIR instead of HIR, fixing quite a few bugs in the process.

r? @eddyb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants