-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-inferenceArea: Type inferenceArea: Type inferenceC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Given the following code (playground):
struct Foo<T>(T);
fn main() {
|| {
if false {
return Foo(0);
}
Foo(())
};
}
The current output is:
error[E0308]: mismatched types
--> src/main.rs:9:13
|
9 | Foo(())
| ^^ expected integer, found `()`
Ideally the output should look like:
error[E0308]: mismatched types
--> src/main.rs:9:13
|
9 | Foo(())
| ^^ expected integer, found `()`
|
note: return type inferred to be `Foo<{integer}>` here
--> src/main.rs:6:20
|
6 | return Foo(0);
| ^^^^^^
Since #78235, notes have been provided when the returned types are entirely different—but they do not appear when they are the same base type with different generic type parameters. cc @Aaron1011
@rustbot label: A-closures A-diagnostics A-inference C-enhancement D-papercut
khrjkhrj
Metadata
Metadata
Assignees
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-inferenceArea: Type inferenceArea: Type inferenceC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.