Skip to content
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

E0529 should suggest turning the matched Vec into a slice #63414

Closed
estebank opened this issue Aug 9, 2019 · 2 comments
Closed

E0529 should suggest turning the matched Vec into a slice #63414

estebank opened this issue Aug 9, 2019 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-enhancement Category: An issue proposing an enhancement or a PR with one. D-newcomer-roadblock Diagnostics: Confusing error or lint; hard to understand for new users. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@estebank
Copy link
Contributor

estebank commented Aug 9, 2019

error[E0529]: expected an array or slice, found `std::vec::Vec<{integer}>`
  --> src/test/ui/suggestions/vec-macro-in-pattern.fixed:4:14
   |
LL |         Some([x]) => ()
   |              ^^^ pattern cannot match with input type `std::vec::Vec<{integer}>`

error: aborting due to previous error

CC #63399

@estebank estebank added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` labels Aug 9, 2019
@Centril Centril added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Aug 9, 2019
@gregberns
Copy link

Just ran into this. Would be helpful to explain how to turn it into a slice in the explanation. In my case: match &rows[..] { [value1] ...., I had to &rows[..]. As some one relatively new, I'd have to google how to transform Some([x]) into a slice. When the suggestion on what to try is in the error it saves so much time :)
Thanks for a great language!!

@estebank estebank added the D-newcomer-roadblock Diagnostics: Confusing error or lint; hard to understand for new users. label Oct 5, 2019
@estebank
Copy link
Contributor Author

estebank commented Feb 3, 2023

Current output for the base case

error[E0529]: expected an array or slice, found `Vec<{integer}>`
 --> src/main.rs:4:9
  |
3 |     match x {
  |           - help: consider slicing here: `x[..]`
4 |         [..] => {}
  |         ^^^^ pattern cannot match with input type `Vec<{integer}>`

and for the option wrapped case:

error[E0529]: expected an array or slice, found `Vec<{integer}>`
 --> src/main.rs:4:14
  |
3 |     match Some(x) {
  |           ------- help: consider using `as_deref` here: `Some(x).as_deref()`
4 |         Some([..]) => {}
  |              ^^^^ pattern cannot match with input type `Vec<{integer}>`

@estebank estebank closed this as completed Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-enhancement Category: An issue proposing an enhancement or a PR with one. D-newcomer-roadblock Diagnostics: Confusing error or lint; hard to understand for new users. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants