Skip to content

Commit e685cad

Browse files
committed
---
yaml --- r: 102335 b: refs/heads/master c: 062e950 h: refs/heads/master i: 102333: 27077e3 102331: 1140b55 102327: c00abca 102319: c970c1a 102303: e0dbb90 102271: 9aa51b1 v: v3
1 parent ac6ca58 commit e685cad

File tree

6 files changed

+77
-21
lines changed

6 files changed

+77
-21
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 47cff94ab9b80d09753bc18bd305ee87493add2b
2+
refs/heads/master: 062e950ae82e60a36833255b48b5e7b124179634
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6e7f170fedd3c526a643c0b2d13863acd982be02
55
refs/heads/try: a97642026c18a624ff6ea01075dd9550f8ed07ff

trunk/src/librustc/front/test.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,6 @@ fn mk_std(cx: &TestCtxt) -> ast::ViewItem {
313313
}
314314
}
315315

316-
#[cfg(stage0)]
317-
fn mk_test_module(_: &TestCtxt) -> @ast::Item {
318-
fail!("test disabled in this stage due to quasiquoter")
319-
}
320-
321-
#[cfg(not(stage0))]
322316
fn mk_test_module(cx: &TestCtxt) -> @ast::Item {
323317
// Link to test crate
324318
let view_items = vec!(mk_std(cx));
@@ -388,12 +382,6 @@ fn path_node_global(ids: ~[ast::Ident]) -> ast::Path {
388382
}
389383
}
390384

391-
#[cfg(stage0)]
392-
fn mk_tests(_: &TestCtxt) -> @ast::Item {
393-
fail!("tests disabled in this stage due to quasiquoter")
394-
}
395-
396-
#[cfg(not(stage0))]
397385
fn mk_tests(cx: &TestCtxt) -> @ast::Item {
398386
// The vector of test_descs for this crate
399387
let test_descs = mk_test_descs(cx);
@@ -435,12 +423,6 @@ fn mk_test_descs(cx: &TestCtxt) -> @ast::Expr {
435423
}
436424
}
437425

438-
#[cfg(stage0)]
439-
fn mk_test_desc_and_fn_rec(_: &TestCtxt, _: &Test) -> @ast::Expr {
440-
fail!("tests disabled in this stage due to quasiquoter")
441-
}
442-
443-
#[cfg(not(stage0))]
444426
fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::Expr {
445427
let span = test.span;
446428
let path = test.path.clone();

trunk/src/libstd/vec_ng.rs

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ use cmp::{Eq, Ordering, TotalEq, TotalOrd};
1717
use container::Container;
1818
use default::Default;
1919
use fmt;
20-
use iter::{DoubleEndedIterator, FromIterator, Iterator};
20+
use iter::{DoubleEndedIterator, FromIterator, Extendable, Iterator};
2121
use libc::{free, c_void};
2222
use mem::{size_of, move_val_init};
2323
use num;
24-
use num::CheckedMul;
24+
use num::{CheckedMul, CheckedAdd};
2525
use ops::Drop;
2626
use option::{None, Option, Some};
2727
use ptr::RawPtr;
@@ -126,6 +126,16 @@ impl<T> FromIterator<T> for Vec<T> {
126126
}
127127
}
128128

129+
impl<T> Extendable<T> for Vec<T> {
130+
fn extend<I: Iterator<T>>(&mut self, iterator: &mut I) {
131+
let (lower, _) = iterator.size_hint();
132+
self.reserve_additional(lower);
133+
for element in *iterator {
134+
self.push(element)
135+
}
136+
}
137+
}
138+
129139
impl<T:Eq> Eq for Vec<T> {
130140
#[inline]
131141
fn eq(&self, other: &Vec<T>) -> bool {
@@ -160,6 +170,15 @@ impl<T> Vec<T> {
160170
self.cap
161171
}
162172

173+
pub fn reserve_additional(&mut self, extra: uint) {
174+
if self.cap - self.len < extra {
175+
match self.len.checked_add(&extra) {
176+
None => fail!("Vec::reserve_additional: `uint` overflow"),
177+
Some(new_cap) => self.reserve(new_cap)
178+
}
179+
}
180+
}
181+
163182
pub fn reserve(&mut self, capacity: uint) {
164183
if capacity >= self.len {
165184
self.reserve_exact(num::next_power_of_two(capacity))
@@ -453,3 +472,48 @@ impl<T> Drop for MoveItems<T> {
453472
}
454473
}
455474
}
475+
476+
#[cfg(test)]
477+
mod tests {
478+
use super::Vec;
479+
use iter::{Iterator, range, Extendable};
480+
use option::{Some, None};
481+
482+
#[test]
483+
fn test_reserve_additional() {
484+
let mut v = Vec::new();
485+
assert_eq!(v.capacity(), 0);
486+
487+
v.reserve_additional(2);
488+
assert!(v.capacity() >= 2);
489+
490+
for i in range(0, 16) {
491+
v.push(i);
492+
}
493+
494+
assert!(v.capacity() >= 16);
495+
v.reserve_additional(16);
496+
assert!(v.capacity() >= 32);
497+
498+
v.push(16);
499+
500+
v.reserve_additional(16);
501+
assert!(v.capacity() >= 33)
502+
}
503+
504+
#[test]
505+
fn test_extend() {
506+
let mut v = Vec::new();
507+
let mut w = Vec::new();
508+
509+
v.extend(&mut range(0, 3));
510+
for i in range(0, 3) { w.push(i) }
511+
512+
assert_eq!(v, w);
513+
514+
v.extend(&mut range(3, 10));
515+
for i in range(3, 10) { w.push(i) }
516+
517+
assert_eq!(v, w);
518+
}
519+
}

trunk/src/snapshots.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
S 2014-03-03 6e7f170
2+
freebsd-x86_64 1afdfbb838af95cea5d5037018f220356da954f6
3+
linux-i386 edd73d291614907ad502a9f726cd9facb1f2f49f
4+
linux-x86_64 6b4d38bde52db482e5d41cc3fe06f777646930dd
5+
macos-i386 ac4e833996a92f94bff8955035ff4cea92bb11de
6+
macos-x86_64 2ba2903243c7dc31c80305af0b9f9a30b159797a
7+
winnt-i386 e64d3d670f11f48b487024bd3a6838c1d23a7483
8+
19
S 2014-02-22 4995a85
210
freebsd-x86_64 0d8e2577d4b626cd8a5d9c29f0f91a4452bc1621
311
linux-i386 afadce8cba1098b1b9ae1e53a649c1515cd26e3c

trunk/src/test/run-pass-fulldeps/macro-crate-outlive-expansion-phase.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// ignore-stage1
1313
// ignore-fast
1414
// ignore-android
15+
// ignore-cross-compile #12102
1516

1617
#[feature(phase)];
1718

trunk/src/test/run-pass-fulldeps/macro-crate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// ignore-stage1
1313
// ignore-fast
1414
// ignore-android
15+
// ignore-cross-compile #12102
1516

1617
#[feature(phase)];
1718

0 commit comments

Comments
 (0)