Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upExhaustive integer patterns tracking issue #50907
Comments
This comment was marked as resolved.
This comment was marked as resolved.
leonardo-m
commented
May 19, 2018
|
Some common use cases, you don't need to support them all at once, but eventually Rust should handle them all:
|
This comment was marked as resolved.
This comment was marked as resolved.
|
@leonardo-m: I'm focusing on exhaustive matching over the entire type right now. Eventually, it'd be nice to be able to handle cases like modulo too, but that involves some significant changes if it's to work well and I'm not sure how plausible it really is (without a huge memory footprint). |
This was referenced May 20, 2018
This comment was marked as resolved.
This comment was marked as resolved.
|
To range the result of arithmetic I think we have to implement it as something like type system contracts, which needs a full RFC. |
kennytm
added
T-lang
B-unstable
C-tracking-issue
labels
May 20, 2018
This comment was marked as resolved.
This comment was marked as resolved.
leonardo-m
commented
May 20, 2018
•
|
The example with mod_euc could require some kind of contracts, but my second example with "
I think Rust match{} could become equally smart. I also think the same Value Range Analysis should allow code like this in Rust (note this uses into() instead of TryInto()): |
This comment was marked as resolved.
This comment was marked as resolved.
|
I'd say that range analysis should be solely an optimization, as it's very inflexible. And on the optimization side, LLVM should be already able to eliminate the dead path. |
This comment was marked as resolved.
This comment was marked as resolved.
leonardo-m
commented
May 20, 2018
That misses the main point of using into() instead of TryInto(): the first one is statically proved to be correct by the compiler, unlike the second. The optimization is not the important thing here. |
This comment was marked as resolved.
This comment was marked as resolved.
samlh
commented
May 20, 2018
|
@leonardo-m: I think supporting such a feature would be interesting, but concur it would need a separate RFC with more details. |
This comment was marked as resolved.
This comment was marked as resolved.
leonardo-m
commented
May 20, 2018
|
I concur it's for other pull requests and another RFC. |
bors
added a commit
that referenced
this issue
Aug 22, 2018
This comment has been minimized.
This comment has been minimized.
|
This will be usable on the next Nightly under |
This comment has been minimized.
This comment has been minimized.
|
N.B: Before we stabilize this, I would like to see an RFC accepted that details and motivates (shouldn't be too hard) the changes. |
This comment has been minimized.
This comment has been minimized.
|
In #50912 (comment) it was proposed that this extension was filling in a gap in the existing exhaustiveness checks and underwent a T-lang FCP, so an RFC probably isn't necessary here. |
This comment has been minimized.
This comment has been minimized.
|
@varkor So, I had not read #50912 (comment). However, I do not view exhaustive integer matching as a bugfix or a trivial change. The feature was seen an addition to the language (as opposed to bug-fixes) in previous RFCs and were postponed then since they were not a priority leading up to 1.0. @nikomatsakis said as much in their move to FCP in the linked comment. Therefore, I do not think that the proper process was followed and I will insist that an RFC is written prior to stabilization because I want to avoid the precedent of allowing larger and larger language changes to be accepted with no RFC. I want to emphasize that this is not about this particular feature, which I think is an excellent idea and I have no doubt we would merge the RFC; but I do want to see the bits and pieces of text and reasoning that the RFC document provides (and I know that you're capable of writing excellent RFCs). Think of it as a stabilization report. Once we have that RFC merged, we can skip the extra FCP after it. |
hcpl
added a commit
to hcpl/serde_mtproto
that referenced
this issue
Oct 9, 2018
hcpl
pushed a commit
to hcpl/serde_mtproto
that referenced
this issue
Oct 9, 2018
This comment has been minimized.
This comment has been minimized.
|
This has been in the nightly compiler for ~80 days which approximates 12 weeks; |
This comment has been minimized.
This comment has been minimized.
|
@Centril should this also be tagged with |
This comment has been minimized.
This comment has been minimized.
|
@jonhoo we tag the PR that stabilizes it with |
This comment has been minimized.
This comment has been minimized.
|
Stabilization proposal filed in rust-lang/rfcs#2591. |
Centril
referenced this issue
Nov 10, 2018
Merged
Stabilise exhaustive integer pattern matching #2591
bors
added a commit
that referenced
this issue
Dec 4, 2018
bors
closed this
in
e57ed0d
Dec 6, 2018
This comment has been minimized.
This comment has been minimized.
|
This has been stabilised in #56557. |
varkor commentedMay 19, 2018
•
edited
Tentative tracking issue for the
exhaustive_integer_patternsfeature, in which integer types may be exhaustively matched over their values. Original RFC thread: rust-lang/rfcs#1550.