Skip to content

Incorrect "non-exhaustive patterns" using @-binding in match #8391

Closed

Description

@bluss

Binding a match arm using "as-patterns" ref x @ or ref mut x @ will emit an incorrect error message.

rusti:  match Some(1) { ref x@Some(*) => 1, None => 0 }
<anon>:5:10: 5:57 error: non-exhaustive patterns
<anon>:5           match Some(1) { ref x@Some(*) => 1, None => 0 }
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

rustc will be silent and happy if a third case _ => fail!() is provided.

Activity

  1. catamorphism commented on Oct 29, 2013

    @catamorphism
    Contributor

    Reproduced with 16b8a41 . Unfortunate, but not a milestone blocker IMO.

  2. edwardw commented on Mar 23, 2014

    @edwardw
    Contributor

    Not an issue any more. The following compiles happily:

    pub fn main() {
      let _x = match Some(1) {
        _y @ Some(_) => 1,
        None => 2,
      };
    }
  3. alexcrichton commented on Mar 24, 2014

    @alexcrichton
    Member

    Flagging as needstest

  4. added a commit that references this issue on Apr 28, 2014
    35f295d
  5. added a commit that references this issue on Apr 28, 2014
    7a19a82
  6. chris-morgan commented on May 12, 2014

    @chris-morgan
    Member

    I just hit this, and it is an issue which still fails. @edwardw, you missed the key fact in the initial report: the usage of ref as well as @. @ without ref or ref mut is fine.

    Can we please reopen this issue?

  7. huonw commented on May 12, 2014

    @huonw
    Contributor

    Test case:

    pub fn main() {
      let _x = match Some(1) {
        ref _y @ Some(_) => 1,
        None => 2,
      };
    }
  8. reopened this on May 12, 2014
  9. edwardw commented on May 13, 2014

    @edwardw
    Contributor

    Ah, my bad to misread the original ticket. Obliged to fix it then :)

  10. added a commit that references this issue on May 13, 2014
    ef6beb3
  11. added a commit that references this issue on May 14, 2014
    5bf268d
  12. added a commit that references this issue on Feb 24, 2022
    7ee2081
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 lintsE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions