Misleading message for mismatch of associated type
#58092
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
D-incorrect
Diagnostics: A diagnostic that is giving misleading or incorrect information.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
In the compiler message for type mismatching error of associated type, "expected A, found B" should be reversed ("expected B, found A").
The above example shows the error below:
Especially, compiler says "expected i32, found f64". However "expected f64, found i32" is more natural since the mismatching here is that the function
foo()
requiresX::Item
to bef64
butX::Item
is actuallyi32
.Another example is below:
It causes an error like:
The error here is that
Iterator::cloned()
requiresIterator::Item
to be a reference but the supplied iterator here (vec![1, 2, 3].into_iter()
) is a iterator generating integers. However error message is shown as ifIterator::cloned()
required something to be an integer but that was reference. The message should be "expected reference, found integer".Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: