-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
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-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.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.
Description
Code
fn main() {
let v = vec![1,2,3,4];
for pair in v.chunk(2) {
println!("{}, {}", pair[0], pair[1]);
}
}
Current output
error[E0599]: no method named `chunk` found for struct `Vec<{integer}>` in the current scope
--> src/main.rs:3:19
|
3 | for pair in v.chunk(2) {
| ^^^^^ help: there is a method with a similar name: `as_chunks`
For more information about this error, try `rustc --explain E0599`.
Desired output
error[E0599]: no method named `chunk` found for struct `Vec<{integer}>` in the current scope
--> src/main.rs:3:19
|
3 | for pair in v.chunk(2) {
| ^^^^^ help: there is a method with a similar name: `chunks`
For more information about this error, try `rustc --explain E0599`.
Rationale and extra context
It would be more helpful to suggest the chunks
method for the typo rather than a nightly-only symbol which isn't actually available.
- Following the suggestion doesn't work.
- The
chunks()
method is actually available on astd::slice
. - The
chunks()
method has been stable since 1.0.0. - I had trouble noticing the difference between
.chunk()
and.chuncks()
and could have used the compiler's help.
Other cases
No response
Anything else?
Reproduced with 1.68.0 stable and 1.70 nightly.
estebank and antonok-edm
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-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.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.