Skip to content

Commit 2f15dcd

Browse files
committed
auto merge of #17584 : pcwalton/rust/range-patterns-dotdotdot, r=nick29581
This breaks code that looks like: match foo { 1..3 => { ... } } Instead, write: match foo { 1...3 => { ... } } Closes #17295. r? @nick29581
2 parents 57a05cf + 416144b commit 2f15dcd

File tree

35 files changed

+161
-164
lines changed

35 files changed

+161
-164
lines changed

src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1512,7 +1512,7 @@ fn _arm_exec_compiled_test(config: &Config,
15121512
for c in exitcode_out.as_slice().chars() {
15131513
if !c.is_digit() { break; }
15141514
exitcode = exitcode * 10 + match c {
1515-
'0' .. '9' => c as int - ('0' as int),
1515+
'0' ... '9' => c as int - ('0' as int),
15161516
_ => 101,
15171517
}
15181518
}

src/doc/guide.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3757,27 +3757,27 @@ match x {
37573757
}
37583758
```
37593759

3760-
You can match a range of values with `..`:
3760+
You can match a range of values with `...`:
37613761

37623762
```{rust}
37633763
let x = 1i;
37643764
37653765
match x {
3766-
1 .. 5 => println!("one through five"),
3766+
1 ... 5 => println!("one through five"),
37673767
_ => println!("anything"),
37683768
}
37693769
```
37703770

37713771
Ranges are mostly used with integers and single characters.
37723772

3773-
If you're matching multiple things, via a `|` or a `..`, you can bind
3773+
If you're matching multiple things, via a `|` or a `...`, you can bind
37743774
the value to a name with `@`:
37753775

37763776
```{rust}
37773777
let x = 1i;
37783778
37793779
match x {
3780-
x @ 1 .. 5 => println!("got {}", x),
3780+
x @ 1 ... 5 => println!("got {}", x),
37813781
_ => println!("anything"),
37823782
}
37833783
```

src/doc/reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3410,7 +3410,7 @@ may be specified with `..`. For example:
34103410
34113411
let message = match x {
34123412
0 | 1 => "not many",
3413-
2 .. 9 => "a few",
3413+
2 ... 9 => "a few",
34143414
_ => "lots"
34153415
};
34163416
```

src/libcollections/string.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,10 @@ impl String {
199199
}
200200
3 => {
201201
match (byte, safe_get(v, i, total)) {
202-
(0xE0 , 0xA0 .. 0xBF) => (),
203-
(0xE1 .. 0xEC, 0x80 .. 0xBF) => (),
204-
(0xED , 0x80 .. 0x9F) => (),
205-
(0xEE .. 0xEF, 0x80 .. 0xBF) => (),
202+
(0xE0 , 0xA0 ... 0xBF) => (),
203+
(0xE1 ... 0xEC, 0x80 ... 0xBF) => (),
204+
(0xED , 0x80 ... 0x9F) => (),
205+
(0xEE ... 0xEF, 0x80 ... 0xBF) => (),
206206
_ => {
207207
error!();
208208
continue;
@@ -217,9 +217,9 @@ impl String {
217217
}
218218
4 => {
219219
match (byte, safe_get(v, i, total)) {
220-
(0xF0 , 0x90 .. 0xBF) => (),
221-
(0xF1 .. 0xF3, 0x80 .. 0xBF) => (),
222-
(0xF4 , 0x80 .. 0x8F) => (),
220+
(0xF0 , 0x90 ... 0xBF) => (),
221+
(0xF1 ... 0xF3, 0x80 ... 0xBF) => (),
222+
(0xF4 , 0x80 ... 0x8F) => (),
223223
_ => {
224224
error!();
225225
continue;

src/libcore/char.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ pub fn to_digit(c: char, radix: uint) -> Option<uint> {
123123
fail!("to_digit: radix is too high (maximum 36)");
124124
}
125125
let val = match c {
126-
'0' .. '9' => c as uint - ('0' as uint),
127-
'a' .. 'z' => c as uint + 10u - ('a' as uint),
128-
'A' .. 'Z' => c as uint + 10u - ('A' as uint),
126+
'0' ... '9' => c as uint - ('0' as uint),
127+
'a' ... 'z' => c as uint + 10u - ('a' as uint),
128+
'A' ... 'Z' => c as uint + 10u - ('A' as uint),
129129
_ => return None,
130130
};
131131
if val < radix { Some(val) }
@@ -184,7 +184,7 @@ pub fn escape_unicode(c: char, f: |char|) {
184184
let offset = offset as uint;
185185
unsafe {
186186
match ((c as i32) >> offset) & 0xf {
187-
i @ 0 .. 9 => { f(transmute('0' as i32 + i)); }
187+
i @ 0 ... 9 => { f(transmute('0' as i32 + i)); }
188188
i => { f(transmute('a' as i32 + (i - 10))); }
189189
}
190190
}
@@ -211,7 +211,7 @@ pub fn escape_default(c: char, f: |char|) {
211211
'\\' => { f('\\'); f('\\'); }
212212
'\'' => { f('\\'); f('\''); }
213213
'"' => { f('\\'); f('"'); }
214-
'\x20' .. '\x7e' => { f(c); }
214+
'\x20' ... '\x7e' => { f(c); }
215215
_ => c.escape_unicode(f),
216216
}
217217
}

src/libcore/fmt/num.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ macro_rules! radix {
9999
}
100100
}
101101

102-
radix!(Binary, 2, "0b", x @ 0 .. 2 => b'0' + x)
103-
radix!(Octal, 8, "0o", x @ 0 .. 7 => b'0' + x)
104-
radix!(Decimal, 10, "", x @ 0 .. 9 => b'0' + x)
105-
radix!(LowerHex, 16, "0x", x @ 0 .. 9 => b'0' + x,
106-
x @ 10 ..15 => b'a' + (x - 10))
107-
radix!(UpperHex, 16, "0x", x @ 0 .. 9 => b'0' + x,
108-
x @ 10 ..15 => b'A' + (x - 10))
102+
radix!(Binary, 2, "0b", x @ 0 ... 2 => b'0' + x)
103+
radix!(Octal, 8, "0o", x @ 0 ... 7 => b'0' + x)
104+
radix!(Decimal, 10, "", x @ 0 ... 9 => b'0' + x)
105+
radix!(LowerHex, 16, "0x", x @ 0 ... 9 => b'0' + x,
106+
x @ 10 ... 15 => b'a' + (x - 10))
107+
radix!(UpperHex, 16, "0x", x @ 0 ... 9 => b'0' + x,
108+
x @ 10 ... 15 => b'A' + (x - 10))
109109

110110
/// A radix with in the range of `2..36`.
111111
#[deriving(Clone, PartialEq)]
@@ -124,7 +124,7 @@ impl GenericRadix for Radix {
124124
fn base(&self) -> u8 { self.base }
125125
fn digit(&self, x: u8) -> u8 {
126126
match x {
127-
x @ 0 ..9 => b'0' + x,
127+
x @ 0 ... 9 => b'0' + x,
128128
x if x < self.base() => b'a' + (x - 10),
129129
x => fail!("number not in the range 0..{}: {}", self.base() - 1, x),
130130
}

src/libcore/str.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -843,18 +843,18 @@ fn run_utf8_validation_iterator(iter: &mut slice::Items<u8>) -> bool {
843843
2 => if second & !CONT_MASK != TAG_CONT_U8 {err!()},
844844
3 => {
845845
match (first, second, next!() & !CONT_MASK) {
846-
(0xE0 , 0xA0 .. 0xBF, TAG_CONT_U8) |
847-
(0xE1 .. 0xEC, 0x80 .. 0xBF, TAG_CONT_U8) |
848-
(0xED , 0x80 .. 0x9F, TAG_CONT_U8) |
849-
(0xEE .. 0xEF, 0x80 .. 0xBF, TAG_CONT_U8) => {}
846+
(0xE0 , 0xA0 ... 0xBF, TAG_CONT_U8) |
847+
(0xE1 ... 0xEC, 0x80 ... 0xBF, TAG_CONT_U8) |
848+
(0xED , 0x80 ... 0x9F, TAG_CONT_U8) |
849+
(0xEE ... 0xEF, 0x80 ... 0xBF, TAG_CONT_U8) => {}
850850
_ => err!()
851851
}
852852
}
853853
4 => {
854854
match (first, second, next!() & !CONT_MASK, next!() & !CONT_MASK) {
855-
(0xF0 , 0x90 .. 0xBF, TAG_CONT_U8, TAG_CONT_U8) |
856-
(0xF1 .. 0xF3, 0x80 .. 0xBF, TAG_CONT_U8, TAG_CONT_U8) |
857-
(0xF4 , 0x80 .. 0x8F, TAG_CONT_U8, TAG_CONT_U8) => {}
855+
(0xF0 , 0x90 ... 0xBF, TAG_CONT_U8, TAG_CONT_U8) |
856+
(0xF1 ... 0xF3, 0x80 ... 0xBF, TAG_CONT_U8, TAG_CONT_U8) |
857+
(0xF4 , 0x80 ... 0x8F, TAG_CONT_U8, TAG_CONT_U8) => {}
858858
_ => err!()
859859
}
860860
}

src/libdebug/repr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ impl<'a> ReprVisitor<'a> {
227227
self.writer.write("\"".as_bytes())
228228
}
229229
}
230-
'\x20'..'\x7e' => self.writer.write([ch as u8]),
230+
'\x20'...'\x7e' => self.writer.write([ch as u8]),
231231
_ => {
232232
char::escape_unicode(ch, |c| {
233233
let _ = self.writer.write([c as u8]);

src/libnative/io/tty_windows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl WindowsTTY {
6767
// If the file descriptor is one of stdin, stderr, or stdout
6868
// then it should not be closed by us
6969
let closeme = match fd {
70-
0..2 => false,
70+
0...2 => false,
7171
_ => true,
7272
};
7373
let handle = unsafe { get_osfhandle(fd) as HANDLE };

src/librand/distributions/gamma.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ impl Gamma {
9898
assert!(scale > 0.0, "Gamma::new called with scale <= 0");
9999

100100
let repr = match shape {
101-
1.0 => One(Exp::new(1.0 / scale)),
102-
0.0 .. 1.0 => Small(GammaSmallShape::new_raw(shape, scale)),
103-
_ => Large(GammaLargeShape::new_raw(shape, scale))
101+
1.0 => One(Exp::new(1.0 / scale)),
102+
0.0 ... 1.0 => Small(GammaSmallShape::new_raw(shape, scale)),
103+
_ => Large(GammaLargeShape::new_raw(shape, scale))
104104
};
105105
Gamma { repr: repr }
106106
}

0 commit comments

Comments
 (0)