File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
compiler/rustc_ast_lowering/src
src/test/ui/destructuring-assignment Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff 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.
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments