Skip to content

Compiler gives odd context in error that isn't relevant to the actual issue #51752

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

Closed
repnop opened this issue Jun 24, 2018 · 1 comment
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@repnop
Copy link
Contributor

repnop commented Jun 24, 2018

Playground link: https://play.rust-lang.org/?gist=41596a413b9d567407a84423bd63174a&version=stable&mode=debug

Error:

error[E0308]: mismatched types
 --> src/main.rs:7:39
  |
1 | fn main() {
  |           - expected `()` because of default return type
...
7 |         thingy(if let Some(r) = opt { r } else { None });
  |                                       ^ expected enum `std::option::Option`, found mutable reference
  |
  = note: expected type `std::option::Option<&mut i32>`
             found type `&mut {integer}`

For some reason rustc appears to include the return type of main as if it was important here, even though the expression is passing the return value to the thingy function.

@estebank
Copy link
Contributor

Duplicate of #46302.

@estebank estebank added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 25, 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
Projects
None yet
Development

No branches or pull requests

2 participants