Diagnostic for E0596 points at the wrong borrow? #68786
Labels
A-borrow-checker
Area: The borrow checker
A-diagnostics
Area: Messages for errors, warnings, and lints
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I was writing the following function but forgot to put
.as_mut_slice()
rather than.as_slice()
:This produced a
E0596
, with a message that I had trouble with as someone new to Rust:When trying to figure out what the compiler was taking issue with, I thought that it meant that it wanted the elements in the Vec to be themselves mutable, which didn't make any sense to me.
I think the diagnostic is referring to the borrow done by the
.sort_unstable_by(F)
, but it is not pointing at it and the current message can be misread as meaning that the.as_slice()
is borrowing something improperly itself, which it is not.The diagnostic would be more helpful if it was something like this:
The text was updated successfully, but these errors were encountered: