Closed
Description
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=0a9a81dc70d5d9e9873ad7b65a6975d9
fn foo<T, U>(_: U) {}
fn bar() {
foo(|| {});
}
The current output is:
error[[E0282]](https://doc.rust-lang.org/stable/error-index.html#E0282): type annotations needed
--> src/lib.rs:4:5
|
4 | foo(|| {});
| ^^^ cannot infer type of the type parameter `T` declared on the function `foo`
|
help: consider specifying the generic arguments
|
4 | foo::<T, [closure@src/lib.rs:4:9: 4:11]>(|| {});
| +++++++++++++++++++++++++++++++++++++
For more information about this error, try `rustc --explain E0282`.
error: could not compile `playground` due to previous error
Ideally the output should look like:
error[[E0282]](https://doc.rust-lang.org/stable/error-index.html#E0282): type annotations needed
--> src/lib.rs:4:5
|
4 | foo(|| {});
| ^^^ cannot infer type of the type parameter `T` declared on the function `foo`
|
help: consider specifying the generic arguments
|
4 | foo::<T, _>(|| {});
| ++++++++
For more information about this error, try `rustc --explain E0282`.
error: could not compile `playground` due to previous error
Or alternatively shouldn’t contain the suggestion at all.