Closed
Description
Hi,
Let's consider following code:
fn foo() -> usize {
0
}
fn bar(i: usize) {
}
fn main() {
bar(foo);
}
Right now it fails with the expected usize, found fn item
message - I think it would be helpful if compiler bragged about missing parentheses when function's return type matches expected type:
fn main() {
bar(foo);
// ^^^ expected usize, found fn item
// hint: try invoking the function: foo()
}
It may even help a little bit when dealing with async
functions - recently I've written:
async fn foo() {
}
fn bar(f: impl Future<Output=()>) {
}
fn main() {
bar(foo);
}
... and it took me a few minutes to notice that what I actually wanted was bar(foo())
.