diff options
| author | bors <bors@rust-lang.org> | 2017-01-25 02:17:33 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-01-25 02:17:33 +0000 |
| commit | c0d0e68be4f8bb9d8522bd72a7a1b8ef95b84c6c (patch) | |
| tree | 2df7197e1d4cbf264e68bf7e9ce2df67b60f574a /src/libsyntax/fold.rs | |
| parent | 83c2d95238e3545e7ae9af4873c48b1e3651c164 (diff) | |
| parent | 98fef41d63a91759790f5bbe4ac746b5c1a670ba (diff) | |
| download | rust-c0d0e68be4f8bb9d8522bd72a7a1b8ef95b84c6c.tar.gz rust-c0d0e68be4f8bb9d8522bd72a7a1b8ef95b84c6c.zip | |
Auto merge of #35712 - oli-obk:exclusive_range_patterns, r=nikomatsakis
exclusive range patterns
adds `..` patterns to the language under a feature gate (`exclusive_range_pattern`).
This allows turning
``` rust
match i {
0...9 => {},
10...19 => {},
20...29 => {},
_ => {}
}
```
into
``` rust
match i {
0..10 => {},
10..20 => {},
20..30 => {},
_ => {}
}
```
Diffstat (limited to 'src/libsyntax/fold.rs')
| -rw-r--r-- | src/libsyntax/fold.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index c42bf24578f..1ee070cb92d 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -112,6 +112,10 @@ pub trait Folder : Sized { e.map(|e| noop_fold_expr(e, self)) } + fn fold_range_end(&mut self, re: RangeEnd) -> RangeEnd { + noop_fold_range_end(re, self) + } + fn fold_opt_expr(&mut self, e: P<Expr>) -> Option<P<Expr>> { noop_fold_opt_expr(e, self) } @@ -1093,8 +1097,10 @@ pub fn noop_fold_pat<T: Folder>(p: P<Pat>, folder: &mut T) -> P<Pat> { } PatKind::Box(inner) => PatKind::Box(folder.fold_pat(inner)), PatKind::Ref(inner, mutbl) => PatKind::Ref(folder.fold_pat(inner), mutbl), - PatKind::Range(e1, e2) => { - PatKind::Range(folder.fold_expr(e1), folder.fold_expr(e2)) + PatKind::Range(e1, e2, end) => { + PatKind::Range(folder.fold_expr(e1), + folder.fold_expr(e2), + folder.fold_range_end(end)) }, PatKind::Slice(before, slice, after) => { PatKind::Slice(before.move_map(|x| folder.fold_pat(x)), @@ -1107,6 +1113,10 @@ pub fn noop_fold_pat<T: Folder>(p: P<Pat>, folder: &mut T) -> P<Pat> { }) } +pub fn noop_fold_range_end<T: Folder>(end: RangeEnd, _folder: &mut T) -> RangeEnd { + end +} + pub fn noop_fold_expr<T: Folder>(Expr {id, node, span, attrs}: Expr, folder: &mut T) -> Expr { Expr { node: match node { |
