Skip to content

Missing suggestion "remove semicolon" for mismatched types compile error #75759

Closed
@PrototypeNM1

Description

@PrototypeNM1

I tried this code:

fn return_tuple() -> (f32) {
    (3.1415);
}

I expected to see this happen:

A error message suggesting to "consider removing this semicolon" with the relevant code highlighted as in prior releases.

Instead, this happened:

error[E0308]: mismatched types
 --> src/lib.rs:1:23
  |
1 | fn return_tuple() -> (i32) {
  |    ------------       ^^^ expected `i32`, found `()`
  |    |
  |    implicitly returns `()` as its body has no tail or `return` expression

Meta

rustc --version --verbose:

1.45.2
1.47.0-nightly (2020-08-19 32c654a9795b0d88541e)

Issue likely relates to issue #67971 and PR #71894.

This is a significant issue as it's a repeat stumbling block for new users of Rust. See https://www.reddit.com/r/rust/comments/i6yqng/hey_rustaceans_got_an_easy_question_ask_here/g28ambz.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions