Skip to content

bound inconsistently across alternatives separated by | #77358

Closed as not planned
@zyfjeff

Description

@zyfjeff
        let x = &Some((3, 3));
        
        match x {
            Some((x, 3)) | &Some((ref x, 5)) => {

            }
            _ => {
                
            }
        }

error[E0409]: variable `x` is bound inconsistently across alternatives separated by `|`
   --> src/bin/chapter4.rs:111:39
    |
111 |             Some((x, 3)) | &Some((ref x, 5)) => {
    |                   - first binding     ^ bound in different ways

error: aborting due to previous error

For more information about this error, try `rustc --explain E0409`.

The x type in both patterns is &u32, but the compiler will report inconsistency in the types in both patterns.

Ref: https://github.com/rust-lang/rfcs/blob/master/text/2005-match-ergonomics.md#examples

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-patternsRelating to patterns and pattern matchingC-bugCategory: This is a bug.T-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