Skip to content

Commit ecec92d

Browse files
committed
---
yaml --- r: 62787 b: refs/heads/snap-stage3 c: 9ab2921 h: refs/heads/master i: 62785: 0c284af 62783: 302d5cf v: v3
1 parent 10c0403 commit ecec92d

File tree

123 files changed

+487
-378
lines changed

Some content is hidden

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

123 files changed

+487
-378
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: b4a3fe25c6fa35d5b243d6dfaee59306c4bcfda9
4+
refs/heads/snap-stage3: 9ab2921300788b1f7a1f4fdd2c7b8148658f512c
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/mk/tests.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ define TEST_RUNNER
284284
# If NO_REBUILD is set then break the dependencies on extra so we can
285285
# test crates without rebuilding std and extra first
286286
ifeq ($(NO_REBUILD),)
287-
STDTESTDEP_$(1)_$(2)_$(3) = $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_STDLIB_$(2))
287+
STDTESTDEP_$(1)_$(2)_$(3) = $$(TLIB$(1)_T_$(2)_H_$(3))/$$(CFG_EXTRALIB_$(2))
288288
else
289289
STDTESTDEP_$(1)_$(2)_$(3) =
290290
endif

branches/snap-stage3/src/etc/vim/after/ftplugin/rust.vim

Lines changed: 0 additions & 5 deletions
This file was deleted.

branches/snap-stage3/src/libextra/arc.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* In this example, a large vector of floats is shared between several tasks.
1818
* With simple pipes, without ARC, a copy would have to be made for each task.
1919
*
20-
* ~~~
20+
* ~~~ {.rust}
2121
* extern mod std;
2222
* use std::arc;
2323
* let numbers=vec::from_fn(100, |ind| (ind as float)*rand::random());
@@ -370,7 +370,10 @@ pub impl<T:Const + Owned> RWARC<T> {
370370
* See sync::rwlock.write_downgrade(). The RWWriteMode token must be used
371371
* to obtain the &mut T, and can be transformed into a RWReadMode token by
372372
* calling downgrade(), after which a &T can be obtained instead.
373-
* ~~~
373+
*
374+
* # Example
375+
*
376+
* ~~~ {.rust}
374377
* do arc.write_downgrade |write_mode| {
375378
* do (&write_mode).write_cond |state, condvar| {
376379
* ... exclusive access with mutable state ...
@@ -507,7 +510,6 @@ mod tests {
507510
use core::prelude::*;
508511
use core::cell::Cell;
509512
use arc::*;
510-
use arc;
511513

512514
#[test]
513515
fn manually_share_arc() {

branches/snap-stage3/src/libextra/base64.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ impl<'self> ToBase64 for &'self [u8] {
2828
/**
2929
* Turn a vector of `u8` bytes into a base64 string.
3030
*
31-
* *Example*:
31+
* # Example
3232
*
33-
* ~~~~
33+
* ~~~ {.rust}
3434
* extern mod std;
3535
* use std::base64::ToBase64;
3636
*
3737
* fn main () {
3838
* let str = [52,32].to_base64();
3939
* println(fmt!("%s", str));
4040
* }
41-
* ~~~~
41+
* ~~~
4242
*/
4343
fn to_base64(&self) -> ~str {
4444
let mut s = ~"";
@@ -91,17 +91,17 @@ impl<'self> ToBase64 for &'self str {
9191
* Convert any string (literal, `@`, `&`, or `~`) to base64 encoding.
9292
*
9393
*
94-
* *Example*:
94+
* # Example
9595
*
96-
* ~~~~
96+
* ~~~ {.rust}
9797
* extern mod std;
9898
* use std::base64::ToBase64;
9999
*
100100
* fn main () {
101101
* let str = "Hello, World".to_base64();
102102
* println(fmt!("%s",str));
103103
* }
104-
* ~~~~
104+
* ~~~
105105
*
106106
*/
107107
fn to_base64(&self) -> ~str {
@@ -118,9 +118,9 @@ impl FromBase64 for ~[u8] {
118118
* Convert base64 `u8` vector into u8 byte values.
119119
* Every 4 encoded characters is converted into 3 octets, modulo padding.
120120
*
121-
* *Example*:
121+
* # Example
122122
*
123-
* ~~~~
123+
* ~~~ {.rust}
124124
* extern mod std;
125125
* use std::base64::ToBase64;
126126
* use std::base64::FromBase64;
@@ -131,7 +131,7 @@ impl FromBase64 for ~[u8] {
131131
* let bytes = str.from_base64();
132132
* println(fmt!("%?",bytes));
133133
* }
134-
* ~~~~
134+
* ~~~
135135
*/
136136
fn from_base64(&self) -> ~[u8] {
137137
if self.len() % 4u != 0u { fail!("invalid base64 length"); }
@@ -196,11 +196,11 @@ impl FromBase64 for ~str {
196196
* You can use the `from_bytes` function in `core::str`
197197
* to turn a `[u8]` into a string with characters corresponding to those values.
198198
*
199-
* *Example*:
199+
* # Example
200200
*
201201
* This converts a string literal to base64 and back.
202202
*
203-
* ~~~~
203+
* ~~~ {.rust}
204204
* extern mod std;
205205
* use std::base64::ToBase64;
206206
* use std::base64::FromBase64;
@@ -214,7 +214,7 @@ impl FromBase64 for ~str {
214214
* let result_str = str::from_bytes(bytes);
215215
* println(fmt!("%s",result_str));
216216
* }
217-
* ~~~~
217+
* ~~~
218218
*/
219219
fn from_base64(&self) -> ~[u8] {
220220
str::to_bytes(*self).from_base64()

branches/snap-stage3/src/libextra/bitv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ mod tests {
11971197
#[test]
11981198
fn test_from_bytes() {
11991199
let bitv = from_bytes([0b10110110, 0b00000000, 0b11111111]);
1200-
let str = ~"10110110" + ~"00000000" + ~"11111111";
1200+
let str = ~"10110110" + "00000000" + "11111111";
12011201
assert_eq!(bitv.to_str(), str);
12021202
}
12031203

branches/snap-stage3/src/libextra/deque.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,31 @@ pub impl<T> Deque<T> {
125125
self.hi = (self.hi + 1u) % self.elts.len();
126126
self.nelts += 1u;
127127
}
128+
129+
/// Reserve capacity for exactly `n` elements in the given deque,
130+
/// doing nothing if `self`'s capacity is already equal to or greater
131+
/// than the requested capacity
132+
///
133+
/// # Arguments
134+
///
135+
/// * n - The number of elements to reserve space for
136+
fn reserve(&mut self, n: uint) {
137+
vec::reserve(&mut self.elts, n);
138+
}
139+
140+
/// Reserve capacity for at least `n` elements in the given deque,
141+
/// over-allocating in case the caller needs to reserve additional
142+
/// space.
143+
///
144+
/// Do nothing if `self`'s capacity is already equal to or greater
145+
/// than the requested capacity.
146+
///
147+
/// # Arguments
148+
///
149+
/// * n - The number of elements to reserve space for
150+
fn reserve_at_least(&mut self, n: uint) {
151+
vec::reserve_at_least(&mut self.elts, n);
152+
}
128153
}
129154

130155
/// Grow is only called on full elts, so nelts is also len(elts), unlike
@@ -149,6 +174,7 @@ mod tests {
149174
use super::*;
150175
use core::cmp::Eq;
151176
use core::kinds::Copy;
177+
use core::vec::capacity;
152178

153179
#[test]
154180
fn test_simple() {
@@ -328,4 +354,29 @@ mod tests {
328354
}
329355

330356
}
357+
358+
#[test]
359+
fn test_reserve() {
360+
let mut d = Deque::new();
361+
d.add_back(0u64);
362+
d.reserve(50);
363+
assert_eq!(capacity(&mut d.elts), 50);
364+
let mut d = Deque::new();
365+
d.add_back(0u32);
366+
d.reserve(50);
367+
assert_eq!(capacity(&mut d.elts), 50);
368+
}
369+
370+
#[test]
371+
fn test_reserve_at_least() {
372+
let mut d = Deque::new();
373+
d.add_back(0u64);
374+
d.reserve_at_least(50);
375+
assert_eq!(capacity(&mut d.elts), 64);
376+
let mut d = Deque::new();
377+
d.add_back(0u32);
378+
d.reserve_at_least(50);
379+
assert_eq!(capacity(&mut d.elts), 64);
380+
}
381+
331382
}

branches/snap-stage3/src/libextra/flatpipes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ports and channels.
2525
2626
This example sends boxed integers across tasks using serialization.
2727
28-
~~~
28+
~~~ {.rust}
2929
let (port, chan) = serial::pipe_stream();
3030
3131
do task::spawn || {
@@ -927,7 +927,7 @@ mod test {
927927
fn test_try_recv_none3<P:BytePort>(loader: PortLoader<P>) {
928928
static CONTINUE: [u8, ..4] = [0xAA, 0xBB, 0xCC, 0xDD];
929929
// The control word is followed by garbage
930-
let bytes = CONTINUE.to_vec() + ~[0];
930+
let bytes = CONTINUE.to_vec() + [0];
931931
let port = loader(bytes);
932932
let res: Option<int> = port.try_recv();
933933
assert!(res.is_none());
@@ -951,7 +951,7 @@ mod test {
951951
1, sys::size_of::<u64>()) |len_bytes| {
952952
len_bytes.to_vec()
953953
};
954-
let bytes = CONTINUE.to_vec() + len_bytes + ~[0, 0, 0, 0];
954+
let bytes = CONTINUE.to_vec() + len_bytes + [0, 0, 0, 0];
955955

956956
let port = loader(bytes);
957957

branches/snap-stage3/src/libextra/future.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
* # Example
1616
*
17-
* ~~~
17+
* ~~~ {.rust}
1818
* # fn fib(n: uint) -> uint {42};
1919
* # fn make_a_sandwich() {};
2020
* let mut delayed_fib = std::future::spawn (|| fib(5000) );

branches/snap-stage3/src/libextra/json.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1880,13 +1880,13 @@ mod tests {
18801880
]));
18811881
assert_eq!(result::unwrap(from_str(
18821882
~"{" +
1883-
~"\"a\": 1.0, " +
1884-
~"\"b\": [" +
1885-
~"true," +
1886-
~"\"foo\\nbar\", " +
1887-
~"{ \"c\": {\"d\": null} } " +
1888-
~"]" +
1889-
~"}")),
1883+
"\"a\": 1.0, " +
1884+
"\"b\": [" +
1885+
"true," +
1886+
"\"foo\\nbar\", " +
1887+
"{ \"c\": {\"d\": null} } " +
1888+
"]" +
1889+
"}")),
18901890
mk_object([
18911891
(~"a", Number(1.0f)),
18921892
(~"b", List(~[

branches/snap-stage3/src/libextra/net_ip.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,6 @@ mod test {
375375
use uv;
376376

377377
use core::result;
378-
use core::vec;
379378

380379
#[test]
381380
fn test_ip_ipv4_parse_and_format_ip() {

branches/snap-stage3/src/libextra/net_tcp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ fn read_future(sock: &TcpSocket, timeout_msecs: uint)
466466
* Here, the `new_conn` is used in conjunction with `accept` from within
467467
* a task spawned by the `new_connect_cb` passed into `listen`
468468
*
469-
* ~~~~~~~~~~~
469+
* ~~~ {.rust}
470470
* do net::tcp::listen(remote_ip, remote_port, backlog, iotask,
471471
* // this callback is ran once after the connection is successfully
472472
* // set up
@@ -497,7 +497,7 @@ fn read_future(sock: &TcpSocket, timeout_msecs: uint)
497497
* None => ()
498498
* }
499499
* };
500-
* ~~~~~~~~~~~
500+
* ~~~
501501
*
502502
* # Arguments
503503
*

branches/snap-stage3/src/libextra/sha1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ mod tests {
317317
Test {
318318
input:
319319
~"abcdbcdecdefdefgefghfghighij" +
320-
~"hijkijkljklmklmnlmnomnopnopq",
320+
"hijkijkljklmklmnlmnomnopnopq",
321321
output: ~[
322322
0x84u8, 0x98u8, 0x3Eu8, 0x44u8,
323323
0x1Cu8, 0x3Bu8, 0xD2u8, 0x6Eu8,

branches/snap-stage3/src/libextra/sort.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,6 @@ fn shift_vec<T:Copy>(dest: &mut [T],
746746

747747
#[cfg(test)]
748748
mod test_qsort3 {
749-
use core::prelude::*;
750-
751749
use sort::*;
752750

753751
use core::vec;

branches/snap-stage3/src/libextra/sync.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,10 @@ pub impl RWlock {
545545
* the meantime (such as unlocking and then re-locking as a reader would
546546
* do). The block takes a "write mode token" argument, which can be
547547
* transformed into a "read mode token" by calling downgrade(). Example:
548-
* ~~~
548+
*
549+
* # Example
550+
*
551+
* ~~~ {.rust}
549552
* do lock.write_downgrade |write_mode| {
550553
* do (&write_mode).write_cond |condvar| {
551554
* ... exclusive access ...
@@ -717,7 +720,6 @@ mod tests {
717720

718721
use core::cast;
719722
use core::cell::Cell;
720-
use core::ptr;
721723
use core::result;
722724
use core::task;
723725
use core::vec;

branches/snap-stage3/src/libextra/tempfile.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ mod tests {
3030
use core::prelude::*;
3131

3232
use tempfile::mkdtemp;
33-
use tempfile;
3433
use core::os;
3534

3635
#[test]

branches/snap-stage3/src/libextra/time.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -22,11 +22,11 @@ pub mod rustrt {
2222
pub unsafe fn precise_time_ns(ns: &mut u64);
2323

2424
pub unsafe fn rust_tzset();
25-
// FIXME: The i64 values can be passed by-val when #2064 is fixed.
25+
2626
pub unsafe fn rust_gmtime(sec: i64, nsec: i32, result: &mut Tm);
2727
pub unsafe fn rust_localtime(sec: i64, nsec: i32, result: &mut Tm);
28-
pub unsafe fn rust_timegm(tm: &Tm, sec: &mut i64);
29-
pub unsafe fn rust_mktime(tm: &Tm, sec: &mut i64);
28+
pub unsafe fn rust_timegm(tm: &Tm) -> i64;
29+
pub unsafe fn rust_mktime(tm: &Tm) -> i64;
3030
}
3131
}
3232

@@ -177,12 +177,11 @@ pub impl Tm {
177177
/// Convert time to the seconds from January 1, 1970
178178
fn to_timespec(&self) -> Timespec {
179179
unsafe {
180-
let mut sec = 0i64;
181-
if self.tm_gmtoff == 0_i32 {
182-
rustrt::rust_timegm(self, &mut sec);
183-
} else {
184-
rustrt::rust_mktime(self, &mut sec);
185-
}
180+
let sec = match self.tm_gmtoff {
181+
0_i32 => rustrt::rust_timegm(self),
182+
_ => rustrt::rust_mktime(self)
183+
};
184+
186185
Timespec::new(sec, self.tm_nsec)
187186
}
188187
}
@@ -1206,8 +1205,8 @@ mod tests {
12061205
// abbreviation.
12071206
let rfc822 = local.rfc822();
12081207
let prefix = ~"Fri, 13 Feb 2009 15:31:30 ";
1209-
assert!(rfc822 == prefix + ~"PST" ||
1210-
rfc822 == prefix + ~"Pacific Standard Time");
1208+
assert!(rfc822 == prefix + "PST" ||
1209+
rfc822 == prefix + "Pacific Standard Time");
12111210
12121211
assert_eq!(local.ctime(), ~"Fri Feb 13 15:31:30 2009");
12131212
assert_eq!(local.rfc822z(), ~"Fri, 13 Feb 2009 15:31:30 -0800");

0 commit comments

Comments
 (0)