-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
A couple of confusing diagnostics with &str slices #26319
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.WG-diagnosticsWorking group: DiagnosticsWorking group: Diagnostics
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.WG-diagnosticsWorking group: DiagnosticsWorking group: Diagnostics
Type
Fields
Give feedbackNo fields configured for issues without a type.
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&strreturns 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::Outputought to be astr, but the way the diagnostic is written, it sounds backwards.Can either of these diagnostics be improved?