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

bound inconsistently across alternatives separated by | #77358

Closed
zyfjeff opened this issue Sep 30, 2020 · 1 comment
Closed

bound inconsistently across alternatives separated by | #77358

zyfjeff opened this issue Sep 30, 2020 · 1 comment
Labels
A-patterns Relating to patterns and pattern matching C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@zyfjeff
Copy link

zyfjeff commented Sep 30, 2020

        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

@LeSeulArtichaut LeSeulArtichaut added A-patterns Relating to patterns and pattern matching T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Oct 12, 2020
@Nadrieril
Copy link
Member

Closing as a duplicate of #105778 (feel free to reopen if I misunderstood)

@Nadrieril Nadrieril closed this as not planned Won't fix, can't repro, duplicate, stale Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-patterns Relating to patterns and pattern matching C-bug Category: This is a bug. 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