Support parentheses in patterns under feature gate

Improve recovery for trailing comma after `..`
This commit is contained in:
Vadim Petrochenkov
2018-02-24 15:27:06 +03:00
parent 0ff9872b22
commit c9aff92e6d
12 changed files with 166 additions and 107 deletions

View File

@@ -562,7 +562,7 @@ impl Pat {
PatKind::TupleStruct(_, ref s, _) | PatKind::Tuple(ref s, _) => {
s.iter().all(|p| p.walk(it))
}
PatKind::Box(ref s) | PatKind::Ref(ref s, _) => {
PatKind::Box(ref s) | PatKind::Ref(ref s, _) | PatKind::Paren(ref s) => {
s.walk(it)
}
PatKind::Slice(ref before, ref slice, ref after) => {
@@ -656,6 +656,8 @@ pub enum PatKind {
/// `[a, b, ..i, y, z]` is represented as:
/// `PatKind::Slice(box [a, b], Some(i), box [y, z])`
Slice(Vec<P<Pat>>, Option<P<Pat>>, Vec<P<Pat>>),
/// Parentheses in patters used for grouping, i.e. `(PAT)`.
Paren(P<Pat>),
/// A macro pattern; pre-expansion
Mac(Mac),
}