Skip to content

Commit 97ea808

Browse files
committed
---
yaml --- r: 47071 b: refs/heads/try c: 612553c h: refs/heads/master i: 47069: e05efde 47067: 35a177e 47063: 32339d8 47055: 62770f1 47039: 38a02ee v: v3
1 parent 0b57277 commit 97ea808

25 files changed

+65
-28
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3bbcac322669cff3abde5be937cc4ec3860f3985
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
5-
refs/heads/try: 9939d88e8d76b16a3ca9f6cb567bf363af04ef66
5+
refs/heads/try: 612553cb3921f428668602afda1b106e0fd54d73
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libsyntax/parse/parser.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,9 @@ pub impl Parser {
10611061

10621062
if self.token == token::LPAREN {
10631063
self.bump();
1064+
// (e) is parenthesized e
1065+
// (e,) is a tuple with only one field, e
1066+
let mut one_tuple = false;
10641067
if self.token == token::RPAREN {
10651068
hi = self.span.hi;
10661069
self.bump();
@@ -1069,12 +1072,18 @@ pub impl Parser {
10691072
}
10701073
let mut es = ~[self.parse_expr()];
10711074
while self.token == token::COMMA {
1072-
self.bump(); es.push(self.parse_expr());
1075+
self.bump();
1076+
if self.token != token::RPAREN {
1077+
es.push(self.parse_expr());
1078+
}
1079+
else {
1080+
one_tuple = true;
1081+
}
10731082
}
10741083
hi = self.span.hi;
10751084
self.expect(token::RPAREN);
10761085

1077-
return if es.len() == 1 {
1086+
return if es.len() == 1 && !one_tuple {
10781087
self.mk_expr(lo, self.span.hi, expr_paren(es[0]))
10791088
}
10801089
else {
@@ -2158,11 +2167,13 @@ pub impl Parser {
21582167
pat = pat_lit(expr);
21592168
} else {
21602169
let mut fields = ~[self.parse_pat(refutable)];
2161-
while self.token == token::COMMA {
2162-
self.bump();
2163-
fields.push(self.parse_pat(refutable));
2170+
if self.look_ahead(1) != token::RPAREN {
2171+
while self.token == token::COMMA {
2172+
self.bump();
2173+
fields.push(self.parse_pat(refutable));
2174+
}
21642175
}
2165-
if vec::len(fields) == 1u { self.expect(token::COMMA); }
2176+
if fields.len() == 1 { self.expect(token::COMMA); }
21662177
hi = self.span.hi;
21672178
self.expect(token::RPAREN);
21682179
pat = pat_tup(fields);

branches/try/src/libsyntax/print/pprust.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,9 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
11991199
ast::expr_tup(exprs) => {
12001200
popen(s);
12011201
commasep_exprs(s, inconsistent, exprs);
1202+
if exprs.len() == 1 {
1203+
word(s.s, ~",");
1204+
}
12021205
pclose(s);
12031206
}
12041207
ast::expr_call(func, args, sugar) => {
@@ -1634,6 +1637,9 @@ pub fn print_pat(s: @ps, &&pat: @ast::pat, refutable: bool) {
16341637
ast::pat_tup(elts) => {
16351638
popen(s);
16361639
commasep(s, inconsistent, elts, |s, p| print_pat(s, p, refutable));
1640+
if elts.len() == 1 {
1641+
word(s.s, ~",");
1642+
}
16371643
pclose(s);
16381644
}
16391645
ast::pat_box(inner) => {

branches/try/src/test/run-pass/class-impl-very-parameterized-trait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ priv impl<T> cat<T> {
127127
}
128128
}
129129
130-
pub fn main() {
130+
fn main() {
131131
let mut nyan: cat<~str> = cat::new(0, 2, ~"nyan");
132132
for uint::range(1, 5) |_| { nyan.speak(); }
133133
assert(*nyan.find(&1).unwrap() == ~"nyan");

branches/try/src/test/run-pass/const-enum-ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
enum E { V0, V1(int) }
1212
const C: &static/E = &V0;
1313

14-
pub fn main() {
14+
fn main() {
1515
match *C {
1616
V0 => (),
1717
_ => fail!()

branches/try/src/test/run-pass/const-enum-struct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ enum E { V16(u16), V32(u32) }
1212
struct S { a: E, b: u16, c: u16 }
1313
const C: S = S { a: V16(0xDEAD), b: 0x600D, c: 0xBAD };
1414

15-
pub fn main() {
15+
fn main() {
1616
let n = C.b;
1717
assert n != 0xBAD;
1818
assert n == 0x600D;

branches/try/src/test/run-pass/const-enum-struct2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ enum E { V0, V16(u16) }
1212
struct S { a: E, b: u16, c: u16 }
1313
const C: S = S { a: V0, b: 0x600D, c: 0xBAD };
1414

15-
pub fn main() {
15+
fn main() {
1616
let n = C.b;
1717
assert n != 0xBAD;
1818
assert n == 0x600D;

branches/try/src/test/run-pass/const-enum-tuple.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
enum E { V16(u16), V32(u32) }
1212
const C: (E, u16, u16) = (V16(0xDEAD), 0x600D, 0xBAD);
1313

14-
pub fn main() {
14+
fn main() {
1515
let (_, n, _) = C;
1616
assert n != 0xBAD;
1717
assert n == 0x600D;

branches/try/src/test/run-pass/const-enum-tuple2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
enum E { V0, V16(u16) }
1212
const C: (E, u16, u16) = (V0, 0x600D, 0xBAD);
1313

14-
pub fn main() {
14+
fn main() {
1515
let (_, n, _) = C;
1616
assert n != 0xBAD;
1717
assert n == 0x600D;

branches/try/src/test/run-pass/const-enum-tuplestruct.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ enum E { V16(u16), V32(u32) }
1212
struct S(E, u16, u16);
1313
const C: S = S(V16(0xDEAD), 0x600D, 0xBAD);
1414

15-
pub fn main() {
15+
fn main() {
1616
let S(_, n, _) = C;
1717
assert n != 0xBAD;
1818
assert n == 0x600D;

branches/try/src/test/run-pass/const-enum-tuplestruct2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ enum E { V0, V16(u16) }
1212
struct S(E, u16, u16);
1313
const C: S = S(V0, 0x600D, 0xBAD);
1414

15-
pub fn main() {
15+
fn main() {
1616
let S(_, n, _) = C;
1717
assert n != 0xBAD;
1818
assert n == 0x600D;

branches/try/src/test/run-pass/const-enum-vec-index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const C: &[E] = &[V0, V1(0xDEADBEE)];
1313
const C0: E = C[0];
1414
const C1: E = C[1];
1515

16-
pub fn main() {
16+
fn main() {
1717
match C0 {
1818
V0 => (),
1919
_ => fail!()

branches/try/src/test/run-pass/const-enum-vec-ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
enum E { V1(int), V0 }
1212
const C: &static/[E] = &[V0, V1(0xDEADBEE), V0];
1313

14-
pub fn main() {
14+
fn main() {
1515
match C[1] {
1616
V1(n) => assert(n == 0xDEADBEE),
1717
_ => fail!()

branches/try/src/test/run-pass/const-enum-vector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
enum E { V1(int), V0 }
1212
const C: [E * 3] = [V0, V1(0xDEADBEE), V0];
1313

14-
pub fn main() {
14+
fn main() {
1515
match C[1] {
1616
V1(n) => assert(n == 0xDEADBEE),
1717
_ => fail!()

branches/try/src/test/run-pass/impl-privacy-xc-1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
extern mod impl_privacy_xc_1;
55

6-
pub fn main() {
6+
fn main() {
77
let fish = impl_privacy_xc_1::Fish { x: 1 };
88
fish.swim();
99
}

branches/try/src/test/run-pass/impl-privacy-xc-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
extern mod impl_privacy_xc_2;
55

6-
pub fn main() {
6+
fn main() {
77
let fish1 = impl_privacy_xc_2::Fish { x: 1 };
88
let fish2 = impl_privacy_xc_2::Fish { x: 2 };
99
io::println(if fish1.eq(&fish2) { "yes" } else { "no " });

branches/try/src/test/run-pass/issue-1257.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
pub fn main () {
11+
fn main () {
1212
let mut line = ~"";
1313
let mut i = 0;
1414
while line != ~"exit" {

branches/try/src/test/run-pass/newtype-struct-xc-2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ fn f() -> Au {
88
Au(2)
99
}
1010

11-
pub fn main() {
11+
fn main() {
1212
let _ = f();
1313
}
1414

branches/try/src/test/run-pass/newtype-struct-xc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
extern mod newtype_struct_xc;
55

6-
pub fn main() {
6+
fn main() {
77
let _ = newtype_struct_xc::Au(2);
88
}
99

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Why one-tuples? Because macros.
12+
13+
fn main() {
14+
match ('c',) {
15+
(x,) => {
16+
assert x == 'c';
17+
}
18+
}
19+
}
20+

branches/try/src/test/run-pass/trait-default-method-bound-subst.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ fn f<T, U, V: A<T>>(i: V, j: T, k: U) -> (T, U) {
2020
i.g(j, k)
2121
}
2222

23-
pub fn main () {
23+
fn main () {
2424
assert f(0, 1, 2) == (1, 2);
2525
}

branches/try/src/test/run-pass/trait-default-method-bound-subst2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ fn f<T, V: A<T>>(i: V, j: T) -> T {
2020
i.g(j)
2121
}
2222

23-
pub fn main () {
23+
fn main () {
2424
assert f(0, 2) == 2;
2525
}

branches/try/src/test/run-pass/trait-default-method-bound-subst3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn f<T, V: A>(i: V, j: T, k: T) -> (T, T) {
2020
i.g(j, k)
2121
}
2222

23-
pub fn main () {
23+
fn main () {
2424
assert f(0, 1, 2) == (1, 2);
2525
assert f(0, 1u8, 2u8) == (1u8, 2u8);
2626
}

branches/try/src/test/run-pass/trait-default-method-bound-subst4.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn f<T, V: A<T>>(i: V, j: uint) -> uint {
2020
i.g(j)
2121
}
2222

23-
pub fn main () {
23+
fn main () {
2424
assert f::<float, int>(0, 2u) == 2u;
2525
assert f::<uint, int>(0, 2u) == 2u;
2626
}

branches/try/src/test/run-pass/trait-default-method-bound.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ fn f<T: A>(i: T) {
2020
assert i.g() == 10;
2121
}
2222

23-
pub fn main () {
23+
fn main () {
2424
f(0);
2525
}

0 commit comments

Comments
 (0)