Auto merge of #84244 - ABouttefeux:closure-return-conflict-suggest, r=estebank

fix incomplete diagnostic notes when closure returns conflicting for genric type

fixes #84128
Correctly report the span on for conflicting return type in closures
This commit is contained in:
bors 2021-04-17 07:17:31 +00:00
commit 080d30235f
4 changed files with 60 additions and 22 deletions

View file

@ -0,0 +1,16 @@
// test for issue 84128
// missing suggestion for similar ADT type with diffetent generic paramenter
// on closure ReturnNoExpression
struct Foo<T>(T);
fn main() {
|| {
if false {
return Foo(0);
}
Foo(())
//~^ ERROR mismatched types [E0308]
};
}

View file

@ -0,0 +1,15 @@
error[E0308]: mismatched types
--> $DIR/issue-84128.rs:13:13
|
LL | Foo(())
| ^^ expected integer, found `()`
|
note: return type inferred to be `{integer}` here
--> $DIR/issue-84128.rs:10:20
|
LL | return Foo(0);
| ^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.