Skip to content

Give a better error message for => in a return type #77019

Closed
@jyn514

Description

@jyn514

Spot the difference (playground):

fn f() -> usize {
    0
}

fn g() => usize {
    0
}
error: expected `;` or `{`, found `=>`
 --> src/lib.rs:5:8
  |
5 | fn g() => usize {
  |        ^^ expected `;` or `{`

Notice how this gives a hard parse error and doesn't even mention return types. Instead, it should suggest g() -> usize.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions