-
Notifications
You must be signed in to change notification settings - Fork 13k
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
static exhaustiveness checking #352
Comments
This seems like a reasonable way learn my way around the rustc codebase. If I have a chance in the next week or so I'll look at this. |
Taking this. If someone else is dying to do it, let me know... |
Yeah, I sadly don't have time for this, even though it looked interesting. Have fun. |
I want this. |
Working on it right now! |
I have the code finished, which entailed making every non-exhaustive case in rustc and libraries exhaustive. I won't check it in just yet because there were objections to it in a different issue discussion. With hope, we can discuss this tomorrow. My opinion: it's really important to be able to distinguish, immediately, between "I left out this case because I believe I can prove it's statically impossible to reach it" and "I forgot to include this case". If we don't have that, it's going to get really embarrassing. Just look at some of the experience reports from the darcs people about how many of the errors involved use of |
(also, when I was making alts exhaustive, it was almost never obvious to me why the omitted cases were unreachable. IMO, it's only excusable to omit cases if one either documents why, if the invariant that makes it safe is so obvious that someone can tell from glancing at the code that it's true.) |
"I left out this case because I believe I can prove it's statically impossible to reach it": I think "impossible" situations could be documented with an assertion and an explanation quite nicely like: |
@Lenny222 That's at least the minimum we could strive for, again IMO. Ideally, the type system will eventually be precise enough that we can get rid of all but a few of "assert(false)"s. (Hopefully at least a 'fail "helpful message"' instead of assert(false).) |
Agreed. |
General attribute docs improvements
….0.88 Bump serde from 1.0.87 to 1.0.88
Fix #[inline(always)] attribute and support unsigned comparison for signed integers
…t-lang#352) Use vtable index passed at call site to resolve functions Co-authored-by: Daniel Schwartz-Narbonne <danielsn@users.noreply.github.com>
Currently a non-exhaustive match is silently compiled and turns into a runtime fault if it hits the not-handled case. It'd be nice to at least have a warning, or perhaps strict checking, on non-exhaustive matches.
The text was updated successfully, but these errors were encountered: