Skip to content

When trying to destructure a Vec as a slice provide a suggestion #87017

@estebank

Description

@estebank
Contributor

We currently emit the following:

error[E0529]: expected an array or slice, found `Vec<types::GenericBound>`
   --> src/librustdoc/clean/mod.rs:593:28
    |
593 |                     if let [] | [GenericBound::TraitBound(_, hir::TraitBoundModifier::Maybe)] = &bounds {
    |                            ^^ pattern cannot match with input type `Vec<types::GenericBound>`

error[E0529]: expected an array or slice, found `Vec<types::GenericBound>`
   --> src/librustdoc/clean/mod.rs:593:33
    |
593 |                     if let [] | [GenericBound::TraitBound(_, hir::TraitBoundModifier::Maybe)] = &bounds {
    |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern cannot match with input type `Vec<types::GenericBound>`

Ideally we should mention the appropriate solution, to use &bounds[..] instead.

Activity

added
A-diagnosticsArea: Messages for errors, warnings, and lints
P-lowLow priority
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`
D-papercutDiagnostics: An error or lint that needs small tweaks.
D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.
on Jul 10, 2021
added a commit that references this issue on Aug 3, 2021
3354a44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.D-papercutDiagnostics: An error or lint that needs small tweaks.P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @estebank

      Issue actions

        When trying to destructure a `Vec` as a slice provide a suggestion · Issue #87017 · rust-lang/rust