A couple of confusing diagnostics with &str slices #26319
Labels
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.
WG-diagnostics
Working group: Diagnostics
https://play.rust-lang.org/?gist=089ca2d7214f6761051c&version=stable
These are four attempts to take a slice of a
&str
, in two pairs. They are all wrong because indexing a&str
returns astr
, so you need an extra&
. That's not the point. The point is without type annotations, the error diagnostics seem like they could use some improvement.Especially the first one -- it sounds like it is saying my expression ought to be a
str
, but it already is. I think it's actually saying the associated typeIndex::Output
ought to be astr
, but the way the diagnostic is written, it sounds backwards.Can either of these diagnostics be improved?
The text was updated successfully, but these errors were encountered: