-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suggest syntax when finding method on array #44970
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
Suggest syntax when finding method on array On a file like the following: ```rust fn main() { let a = [1, 2, 3]; let _ = [i32; 3]::clone(&a); } ``` it is a fair assumption that what was meant was to use an associated type on an array, so we suggest the correct syntax: ``` error: expected one of `.`, `;`, `?`, or an operator, found `::` --> file.rs:3:21 | 3 | let _ = [i32; 3]::clone(&a); | --------^^ | | | | | expected one of `.`, `;`, `?`, or an operator here | help: did you mean to use an associated type?: `<[i32; 3]>::` ``` Fix #42187.
78e7fa0
to
e339d38
Compare
On a file like the following: ```rust fn main() { let a = [1, 2, 3]; let _ = [i32; 3]::clone(&a); } ``` it is a fair assumption that what was meant was to use an associated type on an array, so we suggest the correct syntax: ``` error: expected one of `.`, `;`, `?`, or an operator, found `::` --> file.rs:3:21 | 3 | let _ = [i32; 3]::clone(&a); | --------^^ | | | | | expected one of `.`, `;`, `?`, or an operator here | help: did you mean to use an associated type?: `<[i32; 3]>::` ```
e339d38
to
ae6d470
Compare
Current error is unrelated to this PR:
|
There's much more potential for diagnostics/recovery here than just I'd actually test for You can omit recovery for a start and just report extra help in those cases. |
| --------^^ | ||
| | | | ||
| | expected one of `.`, `;`, `?`, or an operator here | ||
| help: did you mean to use an associated type?: `<[i32; 3]>::` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clone
is not an associated type.
"associated item" maybe?
☔ The latest upstream changes (presumably #45100) made this pull request unmergeable. Please resolve the merge conflicts. |
Hi @estebank, I can see there are some merge conflicts that need to be resolved! |
Triage again! I'm going to close this for now to help clear out the queue, but of course feel free to resubmit with a rebase! |
On a file like the following:
it is a fair assumption that what was meant was to use an associated
type on an array, so we suggest the correct syntax:
Fix #42187.