-
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
E0004 lists incorrect secondary witnesses #36410
Comments
Duplicate of / related to #35609, I think. |
Ok, so I tried to "fix" this issue to dirty my hands a little with the rust compiler, thinking that it would be easy, cause it was probably a very simple issue to fix. How wrong I was. This is simply not a bug of my level, I'm sorry; but I'll try to explain what I've understood while investigating. This issue is actually quite messed up, here is some code that might make you understand : https://play.rust-lang.org/?gist=5ca5977ed3c44048518e808e8d821bb8&version=nightly&backtrace=0 So what would we expect in that case ? Certainly not This problem comes actually from here : https://github.com/rust-lang/rust/blob/master/src/librustc_const_eval/check_match.rs#L726-L735 Number of patterns left and arity are mixed together, in this code. Guess what happens If you have an enum where the number of fields possible is greater than the number of variants in the enum ? That's right, it just displays "_" for the fields that can't be "bound" to a variant. Now you might be wondering, but if the arity and the number of patterns left are mixed together, what happens if you mix different enums in the patterns ? I'll show you what happens 👍 https://play.rust-lang.org/?gist=3175b98130b9ba03bd9f2f6d85631a16&version=nightly&backtrace=0 We should at least see a mention of the other enum in this code, but we don't. Again, this makes absolutely no sense at all, but I'd say this behavior is "expected" from the bug. Now I think I'm going to leave this issue as it is, cause this is probably way out of my league for newcomer like myself :( . |
duplicate of #35609. |
#31020 added display of multiple witnesses to the error message for non-exhaustive match patterns. However, witnesses beyond the first one may have inappropriate types. For example:
Output:
Here, "
South
andWest
not covered" should read "Some(South)
andSome(West)
not covered".The text was updated successfully, but these errors were encountered: