Diagnostics show different expected and found types #68220
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
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.
Found a case where the diagnostics show an incorrect type (missing
&
), when calling slice methods taking&T
, if the slice is e.g.[&T]
,[&&T]
, etc.Thus the diagnostics are incorrect for e.g.
[&str]
,[&i32]
,[&&bool]
, but are correct for e.g.[i32]
.Unexpected - Example 1
Calling
contains
on[&str]
incorrectly with a&str
(instead of&&str
). Then the highlighted line saysexpected &str
(wrong) and the note after saysexpected type &&str
(correct).Diagnostics
Unexpected - Example 2
Second example using a
const
[&i32]
and callingbinary_search
incorrectly.Diagnostics
Unexpected - Example 3
Diagnostics
Expected - Example 1
Just to reiterate, using
[i32]
instead of[&i32]
results in the expected error.Diagnostics
The text was updated successfully, but these errors were encountered: