Skip to content

Commit 786797d

Browse files
committed
Adjust feature gating of subslice patterns accordingly.
1 parent aa945e3 commit 786797d

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/libsyntax/feature_gate.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2235,11 +2235,23 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
22352235
}
22362236

22372237
fn visit_pat(&mut self, pattern: &'a ast::Pat) {
2238-
match pattern.node {
2239-
PatKind::Slice(_, Some(ref subslice), _) => {
2240-
gate_feature_post!(&self, slice_patterns,
2241-
subslice.span,
2242-
"syntax for subslices in slice patterns is not yet stabilized");
2238+
match &pattern.node {
2239+
PatKind::Slice(pats) => {
2240+
for pat in &*pats {
2241+
let span = pat.span;
2242+
let inner_pat = match &pat.node {
2243+
PatKind::Ident(.., Some(pat)) => pat,
2244+
_ => pat,
2245+
};
2246+
if inner_pat.is_rest() {
2247+
gate_feature_post!(
2248+
&self,
2249+
slice_patterns,
2250+
span,
2251+
"subslice patterns are unstable"
2252+
);
2253+
}
2254+
}
22432255
}
22442256
PatKind::Box(..) => {
22452257
gate_feature_post!(&self, box_patterns,

0 commit comments

Comments
 (0)