Skip to content

Mismatched type errors have become useless #39343

Closed
@nagisa

Description

@nagisa

A minimal test case. My actual case is much more complex, involves functions/callbacks with multiple params and several layers of typedefs.

fn takes_cb(f: fn(i8)) {}

fn main() {
    fn callback(x: i32) {}
    takes_cb(callback)
}

The error reported on 1.11.0 is this:

test.rs:5:14: 5:22 error: mismatched types [E0308]
test.rs:5     takes_cb(callback)
                       ^~~~~~~~
test.rs:5:14: 5:22 help: run `rustc --explain E0308` to see a detailed explanation
test.rs:5:14: 5:22 note: expected type `fn(i8)`
test.rs:5:14: 5:22 note:    found type `fn(i32) {main::callback}`

Useful and obvious. What error looks like now (stable (1.14.0)/beta/nightly (1.16.0))?

error[E0308]: mismatched types
 --> test.rs:5:14
  |
5 |     takes_cb(callback)
  |              ^^^^^^^^ expected i8, found i32

Cute but is as worthless and confusing as it gets.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsP-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions