about summary refs log tree commit diff
path: root/src/libsyntax/print
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-01-25 02:17:33 +0000
committerbors <bors@rust-lang.org>2017-01-25 02:17:33 +0000
commitc0d0e68be4f8bb9d8522bd72a7a1b8ef95b84c6c (patch)
tree2df7197e1d4cbf264e68bf7e9ce2df67b60f574a /src/libsyntax/print
parent83c2d95238e3545e7ae9af4873c48b1e3651c164 (diff)
parent98fef41d63a91759790f5bbe4ac746b5c1a670ba (diff)
downloadrust-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/print')
-rw-r--r--src/libsyntax/print/pprust.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 061e871fe52..e75671d27aa 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -11,7 +11,7 @@
 pub use self::AnnNode::*;
 
 use abi::{self, Abi};
-use ast::{self, BlockCheckMode, PatKind};
+use ast::{self, BlockCheckMode, PatKind, RangeEnd};
 use ast::{SelfKind, RegionTyParamBound, TraitTyParamBound, TraitBoundModifier};
 use ast::Attribute;
 use util::parser::AssocOp;
@@ -2544,10 +2544,13 @@ impl<'a> State<'a> {
                 self.print_pat(&inner)?;
             }
             PatKind::Lit(ref e) => self.print_expr(&**e)?,
-            PatKind::Range(ref begin, ref end) => {
+            PatKind::Range(ref begin, ref end, ref end_kind) => {
                 self.print_expr(&begin)?;
                 space(&mut self.s)?;
-                word(&mut self.s, "...")?;
+                match *end_kind {
+                    RangeEnd::Included => word(&mut self.s, "...")?,
+                    RangeEnd::Excluded => word(&mut self.s, "..")?,
+                }
                 self.print_expr(&end)?;
             }
             PatKind::Slice(ref before, ref slice, ref after) => {