Skip to content

Incorrect error message location #70082

Closed
@s3bk

Description

@s3bk

I tried this code:

// the error is reported here
let em = |v: f64| -> f64 { v };

let x: f64 = em(1i16.into());

// but originates here
let y: f64 = 0.01f64 * 1i16.into();

(playground)

The error message:

error[E0284]: type annotations needed for `f64`
 --> src/main.rs:3:15
  |
3 |     let em = |v: f64| -> f64 { v };
  |               ^ consider giving this closure parameter a type
  |
  = note: cannot resolve `<f64 as std::ops::Mul<_>>::Output == f64`

I expected to see this happen: The error is reported on the line for y.

Instead, this happened: The error is reported for the closure…

Meta

Nighty, Beta and Stable affected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.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