Skip to content

Commit d34ffaf

Browse files
committed
---
yaml --- r: 46391 b: refs/heads/auto c: f683351 h: refs/heads/master i: 46389: 8d1035a 46387: 6852f83 46383: 31f8526 v: v3
1 parent e5df4ca commit d34ffaf

File tree

10 files changed

+81
-24
lines changed

10 files changed

+81
-24
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: f684a8a56be054997c1df8807eac9d5cad221979
17+
refs/heads/auto: f68335113bf277f171494abb62a31293311f80c8

branches/auto/doc/tutorial.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,8 @@ for more information on them.
114114

115115
When complete, `make install` will place several programs into
116116
`/usr/local/bin`: `rustc`, the Rust compiler; `rustdoc`, the
117-
API-documentation tool; `rustpkg`, the Rust package manager;
118-
`rusti`, the Rust REPL; and `rust`, a tool which acts as a unified way to
119-
call them, either directly or with common command line arguments.
117+
API-documentation tool; `cargo`, the Rust package manager;
118+
and `rusti`, the Rust REPL.
120119

121120
[wiki-start]: https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust
122121
[tarball]: http://static.rust-lang.org/dist/rust-0.5.tar.gz
@@ -2185,7 +2184,7 @@ impl Circle for CircleStruct {
21852184
}
21862185
impl Shape for CircleStruct {
21872186
fn area(&self) -> float { pi * square(self.radius) }
2188-
}
2187+
}
21892188
~~~~
21902189

21912190
Notice that methods of `Circle` can call methods on `Shape`, as our

branches/auto/src/libcore/to_str.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ impl ToStr for @str {
4343
pure fn to_str(&self) -> ~str { ::str::from_slice(*self) }
4444
}
4545

46+
// FIXME #4898: impl for one-tuples
47+
4648
impl<A: ToStr, B: ToStr> ToStr for (A, B) {
4749
#[inline(always)]
4850
pure fn to_str(&self) -> ~str {

branches/auto/src/libcore/tuple.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ impl<A: Copy, B: Copy> ExtendedTupleOps<A,B> for (~[A], ~[B]) {
111111
}
112112
}
113113

114+
// FIXME #4898: impl for one-tuples
115+
114116
#[cfg(notest)]
115117
impl<A: Eq, B: Eq> Eq for (A, B) {
116118
#[inline(always)]

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

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -576,12 +576,21 @@ pub impl Parser {
576576
self.bump();
577577
ty_nil
578578
} else {
579+
// (t) is a parenthesized ty
580+
// (t,) is the type of a tuple with only one field,
581+
// of type t
579582
let mut ts = ~[self.parse_ty(false)];
583+
let mut one_tuple = false;
580584
while self.token == token::COMMA {
581585
self.bump();
582-
ts.push(self.parse_ty(false));
586+
if self.token != token::RPAREN {
587+
ts.push(self.parse_ty(false));
588+
}
589+
else {
590+
one_tuple = true;
591+
}
583592
}
584-
let t = if vec::len(ts) == 1u { ts[0].node }
593+
let t = if ts.len() == 1 && !one_tuple { ts[0].node }
585594
else { ty_tup(ts) };
586595
self.expect(token::RPAREN);
587596
t
@@ -1061,6 +1070,9 @@ pub impl Parser {
10611070

10621071
if self.token == token::LPAREN {
10631072
self.bump();
1073+
// (e) is parenthesized e
1074+
// (e,) is a tuple with only one field, e
1075+
let mut one_tuple = false;
10641076
if self.token == token::RPAREN {
10651077
hi = self.span.hi;
10661078
self.bump();
@@ -1069,12 +1081,18 @@ pub impl Parser {
10691081
}
10701082
let mut es = ~[self.parse_expr()];
10711083
while self.token == token::COMMA {
1072-
self.bump(); es.push(self.parse_expr());
1084+
self.bump();
1085+
if self.token != token::RPAREN {
1086+
es.push(self.parse_expr());
1087+
}
1088+
else {
1089+
one_tuple = true;
1090+
}
10731091
}
10741092
hi = self.span.hi;
10751093
self.expect(token::RPAREN);
10761094

1077-
return if es.len() == 1 {
1095+
return if es.len() == 1 && !one_tuple {
10781096
self.mk_expr(lo, self.span.hi, expr_paren(es[0]))
10791097
}
10801098
else {
@@ -2158,11 +2176,13 @@ pub impl Parser {
21582176
pat = pat_lit(expr);
21592177
} else {
21602178
let mut fields = ~[self.parse_pat(refutable)];
2161-
while self.token == token::COMMA {
2162-
self.bump();
2163-
fields.push(self.parse_pat(refutable));
2179+
if self.look_ahead(1) != token::RPAREN {
2180+
while self.token == token::COMMA {
2181+
self.bump();
2182+
fields.push(self.parse_pat(refutable));
2183+
}
21642184
}
2165-
if vec::len(fields) == 1u { self.expect(token::COMMA); }
2185+
if fields.len() == 1 { self.expect(token::COMMA); }
21662186
hi = self.span.hi;
21672187
self.expect(token::RPAREN);
21682188
pat = pat_tup(fields);

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,9 @@ pub fn print_type_ex(s: @ps, &&ty: @ast::Ty, print_colons: bool) {
414414
ast::ty_tup(elts) => {
415415
popen(s);
416416
commasep(s, inconsistent, elts, print_type);
417+
if elts.len() == 1 {
418+
word(s.s, ~",");
419+
}
417420
pclose(s);
418421
}
419422
ast::ty_bare_fn(f) => {
@@ -1199,6 +1202,9 @@ pub fn print_expr(s: @ps, &&expr: @ast::expr) {
11991202
ast::expr_tup(exprs) => {
12001203
popen(s);
12011204
commasep_exprs(s, inconsistent, exprs);
1205+
if exprs.len() == 1 {
1206+
word(s.s, ~",");
1207+
}
12021208
pclose(s);
12031209
}
12041210
ast::expr_call(func, args, sugar) => {
@@ -1634,6 +1640,9 @@ pub fn print_pat(s: @ps, &&pat: @ast::pat, refutable: bool) {
16341640
ast::pat_tup(elts) => {
16351641
popen(s);
16361642
commasep(s, inconsistent, elts, |s, p| print_pat(s, p, refutable));
1643+
if elts.len() == 1 {
1644+
word(s.s, ~",");
1645+
}
16371646
pclose(s);
16381647
}
16391648
ast::pat_box(inner) => {

branches/auto/src/test/bench/core-map.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,26 +302,26 @@ fn main() {
302302
}
303303
};
304304

305-
let seed = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
305+
let seed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
306306

307307
{
308-
let rng = rand::seeded_rng(&seed);
308+
let rng = rand::seeded_rng(seed);
309309
let mut results = empty_results();
310310
old_int_benchmarks(rng, num_keys, &mut results);
311311
old_str_benchmarks(rng, num_keys, &mut results);
312312
write_results("std::oldmap::HashMap", &results);
313313
}
314314

315315
{
316-
let rng = rand::seeded_rng(&seed);
316+
let rng = rand::seeded_rng(seed);
317317
let mut results = empty_results();
318318
linear_int_benchmarks(rng, num_keys, &mut results);
319319
linear_str_benchmarks(rng, num_keys, &mut results);
320320
write_results("core::hashmap::linear::LinearMap", &results);
321321
}
322322

323323
{
324-
let rng = rand::seeded_rng(&seed);
324+
let rng = rand::seeded_rng(seed);
325325
let mut results = empty_results();
326326
tree_int_benchmarks(rng, num_keys, &mut results);
327327
tree_str_benchmarks(rng, num_keys, &mut results);

branches/auto/src/test/bench/core-set.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,27 +152,27 @@ fn main() {
152152
}
153153
};
154154

155-
let seed = ~[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
155+
let seed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
156156
let max = 200000;
157157

158158
{
159-
let rng = rand::seeded_rng(&seed);
159+
let rng = rand::seeded_rng(seed);
160160
let mut results = empty_results();
161161
results.bench_int(rng, num_keys, max, || LinearSet::new::<uint>());
162162
results.bench_str(rng, num_keys, || LinearSet::new::<~str>());
163163
write_results("core::hashmap::LinearSet", &results);
164164
}
165165

166166
{
167-
let rng = rand::seeded_rng(&seed);
167+
let rng = rand::seeded_rng(seed);
168168
let mut results = empty_results();
169169
results.bench_int(rng, num_keys, max, || TreeSet::new::<uint>());
170170
results.bench_str(rng, num_keys, || TreeSet::new::<~str>());
171171
write_results("std::treemap::TreeSet", &results);
172172
}
173173

174174
{
175-
let rng = rand::seeded_rng(&seed);
175+
let rng = rand::seeded_rng(seed);
176176
let mut results = empty_results();
177177
results.bench_int(rng, num_keys, max, || BitvSet::new());
178178
write_results("std::bitv::BitvSet", &results);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
// test the 1-tuple type too
20+
let x: (char,) = ('d',);
21+
let (y,) = x;
22+
assert y == 'd';
23+
}
24+

branches/auto/src/test/run-pass/reflect-visit-data.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,11 +636,12 @@ struct Triple { x: int, y: int, z: int }
636636

637637
pub fn main() {
638638
unsafe {
639-
let r = (1,2,3,true,false, Triple {x:5,y:4,z:3});
639+
let r = (1,2,3,true,false, Triple {x:5,y:4,z:3}, (12,));
640640
let p = ptr::addr_of(&r) as *c_void;
641641
let u = my_visitor(@Stuff {mut ptr1: p,
642642
mut ptr2: p,
643-
mut vals: ~[]});
643+
mut vals: ~[]
644+
});
644645
let v = ptr_visit_adaptor(Inner {inner: u});
645646
let td = get_tydesc_for(r);
646647
unsafe { error!("tydesc sz: %u, align: %u",
@@ -653,7 +654,7 @@ pub fn main() {
653654
}
654655
error!("%?", copy u.vals);
655656
assert u.vals == ~[
656-
~"1", ~"2", ~"3", ~"true", ~"false", ~"5", ~"4", ~"3"
657+
~"1", ~"2", ~"3", ~"true", ~"false", ~"5", ~"4", ~"3", ~"12"
657658
];
658659
}
659660
}

0 commit comments

Comments
 (0)