Skip to content

Commit 74d1263

Browse files
committed
---
yaml --- r: 155559 b: refs/heads/try2 c: 60e7317 h: refs/heads/master i: 155557: 64d8b58 155555: ba98683 155551: a71f871 v: v3
1 parent d04bff5 commit 74d1263

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+570
-208
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 496cc4c0d4a06047c4f78965c8bc6e2c812c7812
8+
refs/heads/try2: 60e7317345f246a8169bbfe721473f693d54cade
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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
}

branches/try2/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
```

branches/try2/src/doc/reference.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2441,6 +2441,8 @@ The currently implemented features of the reference compiler are:
24412441
* `default_type_params` - Allows use of default type parameters. The future of
24422442
this feature is uncertain.
24432443

2444+
* `if_let` - Allows use of the `if let` syntax.
2445+
24442446
* `intrinsics` - Allows use of the "rust-intrinsics" ABI. Compiler intrinsics
24452447
are inherently unstable and no promise about them is made.
24462448

@@ -3229,7 +3231,7 @@ for i in range(0u, 256) {
32293231
if_expr : "if" no_struct_literal_expr '{' block '}'
32303232
else_tail ? ;
32313233
3232-
else_tail : "else" [ if_expr
3234+
else_tail : "else" [ if_expr | if_let_expr
32333235
| '{' block '}' ] ;
32343236
```
32353237

@@ -3408,7 +3410,7 @@ may be specified with `..`. For example:
34083410
34093411
let message = match x {
34103412
0 | 1 => "not many",
3411-
2 .. 9 => "a few",
3413+
2 ... 9 => "a few",
34123414
_ => "lots"
34133415
};
34143416
```
@@ -3434,6 +3436,19 @@ let message = match maybe_digit {
34343436
};
34353437
```
34363438

3439+
### If let expressions
3440+
3441+
```{.ebnf .gram}
3442+
if_let_expr : "if" "let" pat '=' expr '{' block '}'
3443+
else_tail ? ;
3444+
else_tail : "else" [ if_expr | if_let_expr | '{' block '}' ] ;
3445+
```
3446+
3447+
An `if let` expression is semantically identical to an `if` expression but in place
3448+
of a condition expression it expects a refutable let statement. If the value of the
3449+
expression on the right hand side of the let statement matches the pattern, the corresponding
3450+
block will execute, otherwise flow proceeds to the first `else` block that follows.
3451+
34373452
### Return expressions
34383453

34393454
```{.ebnf .gram}

branches/try2/src/etc/emacs/rust-mode-tests.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ Convert the line-column information from that list into a buffer position value.
623623
(move-to-column column)
624624
(point))))
625625

626-
;;; TODO: Maybe add an ERT explainer function (something that shows the
626+
;;; FIXME: Maybe add an ERT explainer function (something that shows the
627627
;;; surrounding code of the final point, not just the position).
628628
(defun rust-test-motion (source-code init-pos final-pos manip-func &optional &rest args)
629629
"Test that MANIP-FUNC moves point from INIT-POS to FINAL-POS.

branches/try2/src/etc/kate/rust.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE language SYSTEM "language.dtd"
33
[
4-
<!-- TODO: Kate's regex engine has very limited support for
4+
<!-- FIXME: Kate's regex engine has very limited support for
55
predefined char classes, so making rustIdent consistent with actual
66
Rust identifiers will be a bit difficult -->
77
<!ENTITY rustIdent "[a-zA-Z_][a-zA-Z_0-9]*">

branches/try2/src/etc/vim/syntax/rust.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ syn keyword rustTodo contained TODO FIXME XXX NB NOTE
216216

217217
" Folding rules {{{2
218218
" Trivial folding rules to begin with.
219-
" TODO: use the AST to make really good folding
219+
" FIXME: use the AST to make really good folding
220220
syn region rustFoldBraces start="{" end="}" transparent fold
221221

222222
" Default highlighting {{{1

branches/try2/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;

branches/try2/src/libcore/any.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub enum Void { }
9191
/// Every type with no non-`'static` references implements `Any`, so `Any` can
9292
/// be used as a trait object to emulate the effects dynamic typing.
9393
#[stable]
94-
pub trait Any: AnyPrivate {}
94+
pub trait Any: AnyPrivate + 'static {}
9595

9696
/// An inner trait to ensure that only this module can call `get_type_id()`.
9797
pub trait AnyPrivate {
@@ -132,7 +132,7 @@ pub trait AnyRefExt<'a> {
132132
}
133133

134134
#[stable]
135-
impl<'a> AnyRefExt<'a> for &'a Any+'a {
135+
impl<'a> AnyRefExt<'a> for &'a Any {
136136
#[inline]
137137
#[stable]
138138
fn is<T: 'static>(self) -> bool {
@@ -181,7 +181,7 @@ pub trait AnyMutRefExt<'a> {
181181
}
182182

183183
#[stable]
184-
impl<'a> AnyMutRefExt<'a> for &'a mut Any+'a {
184+
impl<'a> AnyMutRefExt<'a> for &'a mut Any {
185185
#[inline]
186186
#[unstable = "naming conventions around acquiring references may change"]
187187
fn downcast_mut<T: 'static>(self) -> Option<&'a mut T> {

branches/try2/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
}

branches/try2/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
}

branches/try2/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
}

branches/try2/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]);

branches/try2/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 };

branches/try2/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
}

branches/try2/src/libregex/vm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ pub fn is_word(c: Option<char>) -> bool {
512512
};
513513
// Try the common ASCII case before invoking binary search.
514514
match c {
515-
'_' | '0' .. '9' | 'a' .. 'z' | 'A' .. 'Z' => true,
515+
'_' | '0' ... '9' | 'a' ... 'z' | 'A' ... 'Z' => true,
516516
_ => PERLW.binary_search(|&(start, end)| {
517517
if c >= start && c <= end {
518518
Equal

branches/try2/src/librustc/back/link.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,9 @@ pub fn sanitize(s: &str) -> String {
277277
'-' | ':' => result.push_char('.'),
278278

279279
// These are legal symbols
280-
'a' .. 'z'
281-
| 'A' .. 'Z'
282-
| '0' .. '9'
280+
'a' ... 'z'
281+
| 'A' ... 'Z'
282+
| '0' ... '9'
283283
| '_' | '.' | '$' => result.push_char(c),
284284

285285
_ => {

branches/try2/src/librustc/diagnostics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,6 @@ register_diagnostics!(
151151
E0157,
152152
E0158,
153153
E0159,
154-
E0161
154+
E0161,
155+
E0162
155156
)

branches/try2/src/librustc/lint/builtin.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,10 @@ impl LintPass for UnnecessaryParens {
10921092
let (value, msg, struct_lit_needs_parens) = match e.node {
10931093
ast::ExprIf(ref cond, _, _) => (cond, "`if` condition", true),
10941094
ast::ExprWhile(ref cond, _, _) => (cond, "`while` condition", true),
1095-
ast::ExprMatch(ref head, _) => (head, "`match` head expression", true),
1095+
ast::ExprMatch(ref head, _, source) => match source {
1096+
ast::MatchNormal => (head, "`match` head expression", true),
1097+
ast::MatchIfLetDesugar => (head, "`if let` head expression", true)
1098+
},
10961099
ast::ExprRet(Some(ref value)) => (value, "`return` value", false),
10971100
ast::ExprAssign(_, ref value) => (value, "assigned value", false),
10981101
ast::ExprAssignOp(_, _, ref value) => (value, "assigned value", false),
@@ -1242,7 +1245,7 @@ impl LintPass for UnusedMut {
12421245

12431246
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
12441247
match e.node {
1245-
ast::ExprMatch(_, ref arms) => {
1248+
ast::ExprMatch(_, ref arms, _) => {
12461249
for a in arms.iter() {
12471250
self.check_unused_mut_pat(cx, a.pats.as_slice())
12481251
}

branches/try2/src/librustc/middle/cfg/construct.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
222222
self.add_node(expr.id, [then_exit, else_exit]) // 4, 5
223223
}
224224

225+
ast::ExprIfLet(..) => {
226+
self.tcx.sess.span_bug(expr.span, "non-desugared ExprIfLet");
227+
}
228+
225229
ast::ExprWhile(ref cond, ref body, _) => {
226230
//
227231
// [pred]
@@ -322,7 +326,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
322326
expr_exit
323327
}
324328

325-
ast::ExprMatch(ref discr, ref arms) => {
329+
ast::ExprMatch(ref discr, ref arms, _) => {
326330
//
327331
// [pred]
328332
// |

0 commit comments

Comments
 (0)