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

Specialize the "match arms have incompatible types" error for if let #29398

Merged
merged 1 commit into from
Oct 28, 2015
Merged

Specialize the "match arms have incompatible types" error for if let #29398

merged 1 commit into from
Oct 28, 2015

Conversation

jonas-schievink
Copy link
Contributor

Closes #29314

The code from #29314:

fn main() {
    if let Some(b) = None {
        ()
    } else {
        1
    };
}

now prints this:

test.rs:2:5: 6:6 error: `if let` arms have incompatible types: expected `()`, found `_` (expected (), found integral variable) [E0308]
test.rs:2     if let Some(b) = None {
test.rs:3         ()
test.rs:4     } else {
test.rs:5         1
test.rs:6     };
test.rs:2:5: 6:6 help: run `rustc --explain E0308` to see a detailed explanation
test.rs:4:12: 6:6 note: `if let` arm with an incompatible type
test.rs:4     } else {
test.rs:5         1
test.rs:6     };
error: aborting due to previous error

@rust-highfive
Copy link
Collaborator

r? @jroesch

(rust_highfive has picked a reviewer for you, use r? to override)

@arielb1
Copy link
Contributor

arielb1 commented Oct 27, 2015

@bors r+ 2560646

@jonas-schievink
Copy link
Contributor Author

@arielb1 Looks like bors didn't catch that

@arielb1
Copy link
Contributor

arielb1 commented Oct 27, 2015

@bors r+

@bors
Copy link
Contributor

bors commented Oct 27, 2015

📌 Commit 2560646 has been approved by arielb1

@bors
Copy link
Contributor

bors commented Oct 28, 2015

⌛ Testing commit 2560646 with merge 88fade5...

bors added a commit that referenced this pull request Oct 28, 2015
Closes #29314

The code from #29314:
```rust
fn main() {
    if let Some(b) = None {
        ()
    } else {
        1
    };
}
```
now prints this:
```
test.rs:2:5: 6:6 error: `if let` arms have incompatible types: expected `()`, found `_` (expected (), found integral variable) [E0308]
test.rs:2     if let Some(b) = None {
test.rs:3         ()
test.rs:4     } else {
test.rs:5         1
test.rs:6     };
test.rs:2:5: 6:6 help: run `rustc --explain E0308` to see a detailed explanation
test.rs:4:12: 6:6 note: `if let` arm with an incompatible type
test.rs:4     } else {
test.rs:5         1
test.rs:6     };
error: aborting due to previous error
```
@bors bors merged commit 2560646 into rust-lang:master Oct 28, 2015
@jonas-schievink jonas-schievink deleted the if-let-arms branch October 28, 2015 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants