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

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

Closed
bluss opened this issue Aug 8, 2013 · 6 comments · Fixed by #14187
Closed

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

bluss opened this issue Aug 8, 2013 · 6 comments · Fixed by #14187
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.

Comments

@bluss
Copy link
Member

bluss commented Aug 8, 2013

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.

@catamorphism
Copy link
Contributor

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

@edwardw
Copy link
Contributor

edwardw commented Mar 23, 2014

Not an issue any more. The following compiles happily:

pub fn main() {
  let _x = match Some(1) {
    _y @ Some(_) => 1,
    None => 2,
  };
}

@alexcrichton
Copy link
Member

Flagging as needstest

@chris-morgan
Copy link
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?

@huonw
Copy link
Member

huonw commented May 12, 2014

Test case:

pub fn main() {
  let _x = match Some(1) {
    ref _y @ Some(_) => 1,
    None => 2,
  };
}

@huonw huonw reopened this May 12, 2014
@edwardw
Copy link
Contributor

edwardw commented May 13, 2014

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

edwardw added a commit to edwardw/rust that referenced this issue May 13, 2014
@edwardw edwardw mentioned this issue May 13, 2014
alexcrichton pushed a commit to alexcrichton/rust that referenced this issue May 14, 2014
bors added a commit that referenced this issue May 14, 2014
Closes #14184 (std: Move the owned module from core to std)
Closes #14183 (Allow blocks in const expressions)
Closes #14176 (Add tests for from_bits.)
Closes #14175 (Replaced ~T by Box<T> in manual)
Closes #14173 (Implements Default trait for BigInt and BigUint)
Closes #14171 (Fix #8391)
Closes #14159 (Clean up unicode code in libstd)
Closes #14126 (docs: Add a not found page)
Closes #14123 (add a line to the example to clarify semantics)
Closes #14106 (Pretty printer improvements)
Closes #14083 (rustllvm: Add LLVMRustArrayType)
Closes #13957 (io: Implement process wait timeouts)
flip1995 pushed a commit to flip1995/rust that referenced this issue Feb 24, 2022
Don't lint `needless_borrow` in method receiver positions

fixes rust-lang#8408
fixes rust-lang#8407
fixes rust-lang#8391
fixes rust-lang#8367
fixes rust-lang#8380

This is a temporary fix for `needless_borrow`. The proper fix is included in rust-lang#8355.

This should probably be merged into rustc before beta branches on Friday. This issue has been reported six or seven times in the past couple of weeks.

changelog: Fix various issues with `needless_borrow` n´. Note to changelog writer: those issues might have been introduced in this release cycle, so this might not matter in the changelog.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
Projects
None yet
6 participants