Skip to content

"error: cannot bind by-move with sub-bindings" when sub-binding is _ #8271

@lilyball

Description

@lilyball

The x@foo construct cannot be used in a match arm if foo contains sub-bindings. This is not surprising. However, when the sub-bindings are actually _, this should be allowed as _ is not a real binding.

Example:

match a {
    x@Some(_) => x,
    None => None
}

Result:

foo.rs:3:8: 3:17 error: cannot bind by-move with sub-bindings
foo.rs:3         x@Some(_) => x,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions