-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
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.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.