-
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
Poor diagnostics on missing semicolon after match statement #72634
Comments
The |
Suggest `;` after bare `match` expression E0308 Fix rust-lang#72634.
Rollup merge of rust-lang#106601 - estebank:match-semi, r=cjgillot Suggest `;` after bare `match` expression E0308 Fix rust-lang#72634.
@estebank: As far as I can tell, #106601 didn't fix this issue (you didn't add a test for it either), and the two UI tests that the PR did touch, the suggestion didn't do anything useful -- it only fires when one of the arms is actually evaluated to be type |
Actually, we do suggest using a semicolon, but not via #106601. I'm just gonna revert that, and add this as a test. |
…rms, r=estebank Only point out non-diverging arms for match suggestions Fixes rust-lang#121144 There is no reason to point at diverging arms, which will always coerce to whatever is the match block's evaluated type. This also removes the suggestion from rust-lang#106601, since as I pointed out in rust-lang#72634 (comment) the added suggestion is not firing in the right cases, but instead only when one of the match arms already *actually* evaluates to `()`. r? estebank
…rms, r=estebank Only point out non-diverging arms for match suggestions Fixes rust-lang#121144 There is no reason to point at diverging arms, which will always coerce to whatever is the match block's evaluated type. This also removes the suggestion from rust-lang#106601, since as I pointed out in rust-lang#72634 (comment) the added suggestion is not firing in the right cases, but instead only when one of the match arms already *actually* evaluates to `()`. r? estebank
…rms, r=estebank Only point out non-diverging arms for match suggestions Fixes rust-lang#121144 There is no reason to point at diverging arms, which will always coerce to whatever is the match block's evaluated type. This also removes the suggestion from rust-lang#106601, since as I pointed out in rust-lang#72634 (comment) the added suggestion is not firing in the right cases, but instead only when one of the match arms already *actually* evaluates to `()`. r? estebank
Rollup merge of rust-lang#121146 - compiler-errors:ignore-diverging-arms, r=estebank Only point out non-diverging arms for match suggestions Fixes rust-lang#121144 There is no reason to point at diverging arms, which will always coerce to whatever is the match block's evaluated type. This also removes the suggestion from rust-lang#106601, since as I pointed out in rust-lang#72634 (comment) the added suggestion is not firing in the right cases, but instead only when one of the match arms already *actually* evaluates to `()`. r? estebank
I tried this code (playground):
I expected to see this happen:
A compiler error about missing
;
between}
and4i32
Instead, this happened:
This is very confusing, because I "know" that
panic!()
return type is!
which is coercible to anything else (or whatever is the technical explanation for "we can really ignore the return type ofpanic!
"), so it should not ever be present in error messages about mistyping stuff.Meta
rustc --version --verbose
:This issue is also present in 1.34.2 (from a year ago), and in two-week-old nightly (rustc 1.45.0-nightly (99cb9cc 2020-05-11))
p.s.: When deminimizing the issue, i realized that it's even more confusing when match is the last statement in a for loop (as it was in my real code), i.e.:
gives the same error message about incompatible match arms.
The text was updated successfully, but these errors were encountered: