-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Fix an invalid error for a suggestion to add a slice in pattern-matching #96122
Fix an invalid error for a suggestion to add a slice in pattern-matching #96122
Conversation
r? @nagisa (rust-highfive has picked a reviewer for you, use r? to override) |
if any_target_ty { | ||
err.span_suggestion( | ||
span, | ||
"consider slicing here", | ||
format!("{snippet}[..]"), | ||
Applicability::MachineApplicable, | ||
); |
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.
Won't this suggestion still be wrong for some custom defined type that has Deref<Target=[*]>
but not Index<RangeFull, Output=[*]>
?
Maybe we should be suggesting borrowing here instead of slicing?
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.
I fixed this problem.
Thanks, this looks like a definite improvement! @bors r+ |
📌 Commit efe438b has been approved by |
Rollup of 6 pull requests Successful merges: - rust-lang#94493 (Improved diagnostic on failure to meet send bound on future in a foreign crate) - rust-lang#95809 (Fix typo in bootstrap.py) - rust-lang#96086 (Remove `--extern-location` and all associated code) - rust-lang#96089 (`alloc`: make `vec!` unavailable under `no_global_oom_handling`) - rust-lang#96122 (Fix an invalid error for a suggestion to add a slice in pattern-matching) - rust-lang#96142 (Stop using CRATE_DEF_INDEX outside of metadata encoding.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
closes #96103