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

"mismatched types" error after recovering parse error in bock that should return #44753

Closed
estebank opened this issue Sep 21, 2017 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints P-low Low priority

Comments

@estebank
Copy link
Contributor

fn main(){ 
    let x: usize = {
        Some<7>
    };
}

outputs the following errors:

error: chained comparison operators require parentheses
 --> src/main.rs:3:13
  |
3 |           Some<7>
  |  _____________^
4 | |     };
  | |_____^
  |
  = help: use `::<...>` instead of `<...>` if you meant to specify type arguments

error: expected expression, found `}`
 --> src/main.rs:4:5
  |
4 |     };
  |     ^

error[E0308]: mismatched types
 --> src/main.rs:2:20
  |
2 |       let x: usize = {
  |  ____________________^
3 | |         Some<7>
4 | |     };
  | |_____^ expected usize, found ()
  |
  = note: expected type `usize`
             found type `()`

error: aborting due to 3 previous errors

The first two are reasonable, but the third one should probably either be silenced for blocks that failed parsing, or at the very least made shorter with a message along the lines of:

error[E0XXX]: unknown type due to parse error
 --> src/main.rs:2:20
  |
2 |       let x: usize = {
  |  ____________________^
3 | |         Some<7>
4 | |     };
  | |_____^ expected usize, found unknown type due to parse error
@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints P-low Low priority labels Sep 21, 2017
@estebank
Copy link
Contributor Author

Closing as duplicate of #44579.

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 P-low Low priority
Projects
None yet
Development

No branches or pull requests

1 participant