You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that this should be feasible to implement, if the exact structure is constrained enough. Specifically the addition would be useful even if the match expression had to be a single bitwise and between an unsigned integer literal/constant and an expression, and even if the constant had to be exactly one less than a power of two. In the compiler, this should then be a matter of recognizing the pattern and using an adjusted upper bound for the exhaustive match instead of std::{u8, u16, ...}::MAX.
I've been finding this exact pattern coming up frequently in a crate I've been working on.
The text was updated successfully, but these errors were encountered:
I think this should be moved to the RFCs repository. I certainly wouldn't feel comfortable special-casing certain forms of expression like this, and even a limited form of value analysis is a complex feature. This has come up in the past, but I can't find references to other issues right now.
oli-obk
added
the
needs-rfc
This change is large or controversial enough that it should have an RFC accepted before doing it.
label
Mar 3, 2019
I agree, this needs an RFC. I think the relation to generic value arguments and thus integer subtypes is something that should be part of this discussion, too.
During the implementation/stabilization process for exhaustive integer matching, there was a request to support matches of the form:
It seems that this should be feasible to implement, if the exact structure is constrained enough. Specifically the addition would be useful even if the match expression had to be a single bitwise and between an unsigned integer literal/constant and an expression, and even if the constant had to be exactly one less than a power of two. In the compiler, this should then be a matter of recognizing the pattern and using an adjusted upper bound for the exhaustive match instead of std::{u8, u16, ...}::MAX.
I've been finding this exact pattern coming up frequently in a crate I've been working on.
The text was updated successfully, but these errors were encountered: