Skip to content

Commit 9b489f6

Browse files
committed
Don't refute "()" in let-bindings (fixes #3104).
1 parent 8694ef6 commit 9b489f6

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/rustc/middle/check_alt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ fn is_refutable(tcx: ty::ctxt, pat: @pat) -> bool {
420420
is_refutable(tcx, sub)
421421
}
422422
pat_wild | pat_ident(_, _, none) => { false }
423+
pat_lit(@{node: expr_lit(@{node: lit_nil, _}), _}) => { false } // "()"
423424
pat_lit(_) | pat_range(_, _) => { true }
424425
pat_rec(fields, _) => {
425426
for fields.each |it| {

src/test/run-pass/irrefutable-unit.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
let ((),()) = ((),());
3+
}

0 commit comments

Comments
 (0)