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:
commit
080d30235f
4 changed files with 60 additions and 22 deletions
16
src/test/ui/closures/issue-84128.rs
Normal file
16
src/test/ui/closures/issue-84128.rs
Normal 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]
|
||||
};
|
||||
}
|
||||
15
src/test/ui/closures/issue-84128.stderr
Normal file
15
src/test/ui/closures/issue-84128.stderr
Normal 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`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue