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

Incorrect type mismatch label pointing at return type #46302

Closed
estebank opened this issue Nov 27, 2017 · 0 comments
Closed

Incorrect type mismatch label pointing at return type #46302

estebank opened this issue Nov 27, 2017 · 0 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. WG-diagnostics Working group: Diagnostics

Comments

@estebank
Copy link
Contributor

The following code:

fn main() { //~ NOTE expected `()` because of default return type
  let s = "abc";
  let u: &str = if true { s[..2] } else { s };
}

has an incorrect label:

error[E0308]: mismatched types
 --> src/main.rs:3:27
  |
1 | fn main() { //~ NOTE expected `()` because of default return type
  |           - expected `()` because of default return type
2 |   let s = "abc";
3 |   let u: &str = if true { s[..2] } else { s };
  |                           ^^^^^^ expected &str, found str
  |
  = note: expected type `&str`
             found type `str`
@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. E-needs-mentor WG-diagnostics Working group: Diagnostics labels Nov 27, 2017
bors added a commit that referenced this issue Jun 28, 2018
Fix incorrect type mismatch label pointing at return type

CC #46302.
bors added a commit that referenced this issue Jun 29, 2018
Fix incorrect type mismatch label pointing at return type

CC #46302.
@estebank estebank closed this as completed Oct 9, 2018
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. WG-diagnostics Working group: Diagnostics
Projects
None yet
Development

No branches or pull requests

1 participant