-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Bad advice given for arr[0i32.into()] #107292
Copy link
Copy link
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.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.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Code
Current output
Desired output
I'm too new to Rust to say exactly, but:
idx.into()expression, not the outer expression it is highlighting::<T>, which is not syntactically valid hereRationale and extra context
Naively, one one expect that the requirement of array access being
usizemeans aninto()would work here. Clearly, that's not the case but I'm still not sure why.Other cases
still gives bad advice, although less catastrophically:
Only when you take that bad advice, but with an explicit type instead of _, do you get a useful message:
Anything else?
No response