Skip to content

Commit 76bcd89

Browse files
varkorfanzier
authored andcommitted
Support (..)
1 parent 1841f2d commit 76bcd89

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
896896
true
897897
}
898898
}
899+
// `(..)`.
900+
ExprKind::Paren(e) => {
901+
if let ExprKind::Range(None, None, RangeLimits::HalfOpen) = e.kind {
902+
false
903+
} else {
904+
true
905+
}
906+
}
899907
_ => true,
900908
};
901909
if is_ordinary {
@@ -1032,6 +1040,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
10321040
let tuple_pat = hir::PatKind::Tuple(pats, rest.map(|r| r.0));
10331041
return self.pat(lhs.span, tuple_pat);
10341042
}
1043+
// `(..)`. We special-case this for consistency with declarations.
1044+
ExprKind::Paren(e) => {
1045+
if let ExprKind::Range(None, None, RangeLimits::HalfOpen) = e.kind {
1046+
let tuple_pat = hir::PatKind::Tuple(&[], Some(0));
1047+
return self.pat(lhs.span, tuple_pat);
1048+
}
1049+
}
10351050
_ => {}
10361051
}
10371052
// Treat all other cases as normal lvalue.

src/test/ui/destructuring-assignment/tuple_destructure.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ fn main() {
1212
assert_eq!((a, b), (1, 2));
1313
(_, a) = (1, 2);
1414
assert_eq!((a, b), (2, 2));
15-
// The following currently does not work, but should.
16-
// (..) = (3, 4);
17-
// assert_eq!((a, b), (2, 2));
15+
(..) = (3, 4);
16+
assert_eq!((a, b), (2, 2));
1817
}

0 commit comments

Comments
 (0)