-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor match checking to use HAIR #36695
Conversation
b085797
to
771f81f
Compare
@@ -28,6 +26,8 @@ use self::cx::Cx; | |||
|
|||
pub mod cx; | |||
|
|||
pub use rustc_const_eval::pattern::{BindingMode, Pattern, PatternKind, FieldPattern}; |
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.
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.
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.
Another idea would be to move it to rustc_typeck
(and maybe have HAIR definitions in rustc
).
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.
match checking uses a completely different algorithm than match building. HAIR patterns are basically independent of the rest of HAIR.
ty::TySlice(_) => match *ctor { | ||
Slice(length) => length, | ||
ConstantValue(_) => { | ||
// TODO: this is utterly wrong, but required for byte arrays |
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.
/build/src/librustc_const_eval/_match.rs:477: TODO is deprecated; use FIXME
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.
The TODO is the entire point of this PR. It will be removed before the merge.
2200ac4
to
81fb5cf
Compare
☔ The latest upstream changes (presumably #36857) made this pull request unmergeable. Please resolve the merge conflicts. |
d03f2d5
to
879cf61
Compare
☔ The latest upstream changes (presumably #36814) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably #37002) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably #37039) made this pull request unmergeable. Please resolve the merge conflicts. |
0a402c9
to
b5d943d
Compare
`check_match` is now left with its grab bag of random checks.
no intended functional changes
NaN checking was a lint for a deprecated feature. It can go away.
b5d943d
to
5cec1c3
Compare
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.
5cec1c3
to
8d3e89b
Compare
nested slice patterns have the same functionality as non-nested ones, so flatten them in HAIR construction. Fixes rust-lang#26158.
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.
r=me with an explanation for the missing diagnostics, or a revert of their removal.
|
||
|
||
E0003: r##" | ||
/*E0003: r##" |
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.
What's with these two commented diagnostics?
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.
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 |
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.
Why are the NaN warnings gone?
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.
Because you can't have floating-point patterns anymore.
@bors r=eddyb |
📌 Commit 4157850 has been approved by |
📌 Commit 3f9ebb4 has been approved by |
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
Refactor match checking to use HAIR instead of HIR, fixing quite a few bugs in the process.
r? @eddyb