Skip to content

Commit 720e3ad

Browse files
committed
Add RFC to feature gate some slice patterns
1 parent 293a882 commit 720e3ad

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
- Start Date: 2014-07-14
2+
- RFC PR #: (leave this empty)
3+
- Rust Issue #: (leave this empty)
4+
5+
# Summary
6+
7+
Rust's support for pattern matching on sices has grown steadily and incrementally without a lot of oversight,
8+
and we have concern that Rust is doing too much here, that the complexity is not worth it. This RFC proposes
9+
to feature gate multiple-element slice matches in the head and middle positions (`[..xs, 0, 0]` and `[0, ..xs, 0]`.
10+
11+
# Motivation
12+
13+
Some general reasons and one specific: first, the implementation of Rust's match machinery is notoriously complex, and not well-loved. Remove features is seen as a valid way to reduce complexity. Second, slice matching in particular, is difficult to implement, while also being of only moderate utility (there are many types of collections - slices just happen to be built into the language). Finally, the exhaustiveness check is not correct for slice patterns - because of their complexity; it's not known that it
14+
can be done correctly, nor whether it is worth the effort even if.
15+
16+
# Detailed design
17+
18+
The `advanced_slice_patterns` feature gate will be added. When the compiler encounters slice pattern matches in head or middle position it will emit a warning or error accourding to the current settings.
19+
20+
# Drawbacks
21+
22+
It removes two features that some people like.
23+
24+
# Alternatives
25+
26+
Fixing the exhaustiveness check would allow the feature to remain.
27+
28+
# Unresolved questions
29+
30+
N/A

0 commit comments

Comments
 (0)