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> {
896
896
true
897
897
}
898
898
}
899
+ // `(..)`.
900
+ ExprKind :: Paren ( e) => {
901
+ if let ExprKind :: Range ( None , None , RangeLimits :: HalfOpen ) = e. kind {
902
+ false
903
+ } else {
904
+ true
905
+ }
906
+ }
899
907
_ => true ,
900
908
} ;
901
909
if is_ordinary {
@@ -1032,6 +1040,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
1032
1040
let tuple_pat = hir:: PatKind :: Tuple ( pats, rest. map ( |r| r. 0 ) ) ;
1033
1041
return self . pat ( lhs. span , tuple_pat) ;
1034
1042
}
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
+ }
1035
1050
_ => { }
1036
1051
}
1037
1052
// Treat all other cases as normal lvalue.
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ fn main() {
12
12
assert_eq ! ( ( a, b) , ( 1 , 2 ) ) ;
13
13
( _, a) = ( 1 , 2 ) ;
14
14
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 ) ) ;
18
17
}
You can’t perform that action at this time.
0 commit comments