Skip to content

Commit 4e9e843

Browse files
committed
Restrict sublist bindings in tuple and tuple struct patterns
1 parent 2cd24ce commit 4e9e843

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

text/0000-dotdot-in-patterns.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ S(.., subpatN-1, subpatN)
7979
S(subpat1, .., subpatN)
8080
// **NEW**: Tuple struct patterns, any position with a sublist binding.
8181
// The binding has a tuple type.
82+
// By ref bindings are not allowed, because layouts of S(A, B, C, D) and (B, C) are not necessarily
83+
// compatible (e.g. field reordering is possible).
8284
S(subpat1, binding.., subpatN)
8385
8486
// **NEW**: Tuple patterns, any position.
@@ -87,6 +89,8 @@ S(subpat1, binding.., subpatN)
8789
(subpat1, .., subpatN)
8890
// **NEW**: Tuple patterns, any position with a sublist binding.
8991
// The binding has a tuple type.
92+
// By ref bindings are not allowed, because layouts of (A, B, C, D) and (B, C) are not necessarily
93+
// compatible (e.g. field reordering is possible).
9094
(subpat1, binding.., subpatN)
9195
9296
// Slice patterns, the last position.
@@ -96,6 +100,7 @@ S(subpat1, binding.., subpatN)
96100
// Slice patterns, any other position.
97101
[subpat1, .., subpatN]
98102
// Slice patterns, any of the above with a subslice binding.
103+
// By ref bindings are allowed, slices and subslices always have compatible layouts.
99104
[subpat1, binding.., subpatN]
100105
```
101106

@@ -113,7 +118,7 @@ None.
113118
# Alternatives
114119
[alternatives]: #alternatives
115120

116-
None.
121+
Do not permit sublist bindings in tuples and tuple structs at all.
117122

118123
# Unresolved questions
119124
[unresolved]: #unresolved-questions

0 commit comments

Comments
 (0)