Skip to content

Strange extra type error after missing semicolon error #103425

Closed
@jruderman

Description

@jruderman

Given the following code (playground):

fn f() -> f32 {
    3
    5.0
}

fn main() {
}

The current output is:

error: expected `;`, found `5.0`
 --> epp.rs:2:6
  |
2 |     3
  |      ^ help: add `;` here
3 |     5.0
  |     --- unexpected token

error[E0308]: mismatched types
 --> epp.rs:2:5
  |
2 |     3
  |     ^ expected `()`, found integer

What is this second error trying to tell me? What did it expect to be unit type and why? Does it make sense for this error to be emitted despite the first error correctly identifying my problem?

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-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