Code:
fn func1<T: Into<String>>(x: i32) {}
fn main() {
func1(42);
}
Error:
error[E0283]: type annotations required: cannot resolve `_: std::convert::Into<std::string::String>`
--> src/main.rs:6:5
|
6 | func1(42);
| ^^^^^
|
= note: required by `func1`
error: aborting due to previous error
The error is actually caused by the function declaration (it was not supposed to have generic parameters), but without looking at the function it's impossible to understand the message. The error message should show signature of func1 and say that type annotation is required for T argument of func1.
By the way, is there a reason func1 doesn't trigger a warning by itself? I imagine there may be cases where you want functions with unbound type parameters, but I'm not sure about that.
Code:
Error:
The error is actually caused by the function declaration (it was not supposed to have generic parameters), but without looking at the function it's impossible to understand the message. The error message should show signature of
func1and say that type annotation is required forTargument offunc1.By the way, is there a reason
func1doesn't trigger a warning by itself? I imagine there may be cases where you want functions with unbound type parameters, but I'm not sure about that.