Skip to content

E0308 source of expectation isn't shown for closures #106821

Open
@estebank

Description

@estebank

fn main() {
|| {
if false {
return Foo(0);
}
Foo(())
//~^ ERROR mismatched types [E0308]
};
}

currently emits

error[E0308]: mismatched types
--> $DIR/issue-84128.rs:13:13
|
LL | Foo(())
| --- ^^ expected integer, found `()`
| |
| arguments to this struct are incorrect
|
note: tuple struct defined here
--> $DIR/issue-84128.rs:5:8
|
LL | struct Foo<T>(T);
| ^^^

It should include the source of the expectation (the return statement earlier in the closure).

Noticed here https://github.com/rust-lang/rust/pull/106752/files#r1069781007

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsD-papercutDiagnostics: An error or lint that needs small tweaks.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.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