Skip to content

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

Closed
@estebank

Description

@estebank

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.

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

    Development

    No branches or pull requests

    Issue actions