Suggests changing slice-like type instead of index for invalid SliceIndex
#139424
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Following #138381,
ByteStr
now indexes withSliceIndex
instead ofIndex
/IndexMut
. This worsened some diagnostics for indexing other types.Since
SliceIndex
is “backwards”, this leads it to suggest other slice-like types (the LHS), instead of suggesting other index/range types which work for the LHS. When the LHS already indexes withSliceIndex
, it's unhelpful to suggest other slice-like types. Furthermore, this leaksByteStr
into stable diagnostics (confirmed with eitherrust.channel = "stable"
in bootstrap.toml orRUSTC_BOOTSTRAP=-1
)The affected diagnostics are shown in commit 9d379e1.
Code
Current output
Desired output
This was the output before that PR:
Rust Version
The text was updated successfully, but these errors were encountered: