Skip to content
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

missing type in match arms have incompatible types diagnostic #58695

Closed
bjorn3 opened this issue Feb 24, 2019 · 0 comments · Fixed by #60455
Closed

missing type in match arms have incompatible types diagnostic #58695

bjorn3 opened this issue Feb 24, 2019 · 0 comments · Fixed by #60455
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@bjorn3
Copy link
Member

bjorn3 commented Feb 24, 2019

fn main() {
    match Some(0u32) {
        Some(x) => {
            x
        },
        None => {}
    };
}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
error[E0308]: match arms have incompatible types
 --> src/main.rs:6:17
  |
2 | /     match Some(0u32) {
3 | |         Some(x) => {
4 | |             x
  | |             - this is found to be of type `_` <----------- this should be `u32`, removing the {} around x fixes it.
5 | |         },
6 | |         None => {}
  | |                 ^^ expected u32, found ()
7 | |     };
  | |_____- `match` arms have incompatible types
  |
  = note: expected type `u32`
             found type `()`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
error: Could not compile `playground`.

To learn more, run the command again with --verbose.

@jonas-schievink jonas-schievink added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Feb 24, 2019
Centril added a commit to Centril/rust that referenced this issue May 2, 2019
…vidtwco

Resolve match arm ty when arms diverge

Fix rust-lang#58695.
Centril added a commit to Centril/rust that referenced this issue May 3, 2019
…vidtwco

Resolve match arm ty when arms diverge

Fix rust-lang#58695.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants