Skip to content

Commit d6a36cf

Browse files
committed
---
yaml --- r: 151503 b: refs/heads/try2 c: e3c62a2 h: refs/heads/master i: 151501: 6a3f289 151499: 878a154 151495: 0d500af 151487: 5d28b88 v: v3
1 parent 91e1492 commit d6a36cf

File tree

121 files changed

+1446
-1176
lines changed

Some content is hidden

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

121 files changed

+1446
-1176
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: 33cc0efa3d342b292418ac9884cbb77aee882a15
8+
refs/heads/try2: e3c62a20c3a41f98361f4d092720227f4946b39e
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ fn make_lib_name(config: &config, auxfile: &Path, testfile: &Path) -> Path {
997997
fn make_exe_name(config: &config, testfile: &Path) -> Path {
998998
let mut f = output_base_name(config, testfile);
999999
if !os::consts::EXE_SUFFIX.is_empty() {
1000-
match f.filename().map(|s| s + os::consts::EXE_SUFFIX.as_bytes()) {
1000+
match f.filename().map(|s| Vec::from_slice(s).append(os::consts::EXE_SUFFIX.as_bytes())) {
10011001
Some(v) => f.set_filename(v),
10021002
None => ()
10031003
}
@@ -1091,7 +1091,7 @@ fn make_out_name(config: &config, testfile: &Path, extension: &str) -> Path {
10911091

10921092
fn aux_output_dir_name(config: &config, testfile: &Path) -> Path {
10931093
let mut f = output_base_name(config, testfile);
1094-
match f.filename().map(|s| s + bytes!(".libaux")) {
1094+
match f.filename().map(|s| Vec::from_slice(s).append(bytes!(".libaux"))) {
10951095
Some(v) => f.set_filename(v),
10961096
None => ()
10971097
}
@@ -1273,7 +1273,7 @@ fn append_suffix_to_stem(p: &Path, suffix: &str) -> Path {
12731273
(*p).clone()
12741274
} else {
12751275
let stem = p.filestem().unwrap();
1276-
p.with_filename(stem + bytes!("-") + suffix.as_bytes())
1276+
p.with_filename(Vec::from_slice(stem).append(bytes!("-")).append(suffix.as_bytes()))
12771277
}
12781278
}
12791279

branches/try2/src/doc/guide-container.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ Iterators offer generic conversion to containers with the `collect` adaptor:
266266

267267
~~~
268268
let xs = [0, 1, 1, 2, 3, 5, 8];
269-
let ys = xs.iter().rev().skip(1).map(|&x| x * 2).collect::<~[int]>();
270-
assert_eq!(ys, ~[10, 6, 4, 2, 2, 0]);
269+
let ys = xs.iter().rev().skip(1).map(|&x| x * 2).collect::<Vec<int>>();
270+
assert_eq!(ys, vec![10, 6, 4, 2, 2, 0]);
271271
~~~
272272

273273
The method requires a type hint for the container type, if the surrounding code
@@ -278,14 +278,14 @@ implementing the `FromIterator` trait. For example, the implementation for
278278
vectors is as follows:
279279

280280
~~~ {.ignore}
281-
impl<A> FromIterator<A> for ~[A] {
282-
pub fn from_iter<T: Iterator<A>>(iterator: &mut T) -> ~[A] {
281+
impl<T> FromIterator<T> for Vec<T> {
282+
fn from_iter<I:Iterator<A>>(mut iterator: I) -> Vec<T> {
283283
let (lower, _) = iterator.size_hint();
284-
let mut xs = with_capacity(lower);
285-
for x in iterator {
286-
xs.push(x);
284+
let mut vector = Vec::with_capacity(lower);
285+
for element in iterator {
286+
vector.push(element);
287287
}
288-
xs
288+
vector
289289
}
290290
}
291291
~~~

branches/try2/src/doc/rust.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,10 +1741,10 @@ import public items from their destination, not private items.
17411741
## Attributes
17421742

17431743
~~~~ {.notrust .ebnf .gram}
1744-
attribute : '#' '!' ? '[' attr_list ']' ;
1745-
attr_list : attr [ ',' attr_list ]* ;
1746-
attr : ident [ '=' literal
1747-
| '(' attr_list ')' ] ? ;
1744+
attribute : '#' '!' ? '[' meta_item ']' ;
1745+
meta_item : ident [ '=' literal
1746+
| '(' meta_seq ')' ] ? ;
1747+
meta_seq : meta_item [ ',' meta_seq ]* ;
17481748
~~~~
17491749

17501750
Static entities in Rust &mdash; crates, modules and items &mdash; may have _attributes_
@@ -3598,18 +3598,18 @@ and the cast expression in `main`.
35983598
Within the body of an item that has type parameter declarations, the names of its type parameters are types:
35993599

36003600
~~~~
3601-
fn map<A: Clone, B: Clone>(f: |A| -> B, xs: &[A]) -> ~[B] {
3601+
fn map<A: Clone, B: Clone>(f: |A| -> B, xs: &[A]) -> Vec<B> {
36023602
if xs.len() == 0 {
3603-
return ~[];
3603+
return vec![];
36043604
}
36053605
let first: B = f(xs[0].clone());
3606-
let rest: ~[B] = map(f, xs.slice(1, xs.len()));
3607-
return ~[first] + rest;
3606+
let rest: Vec<B> = map(f, xs.slice(1, xs.len()));
3607+
return vec![first].append(rest.as_slice());
36083608
}
36093609
~~~~
36103610

36113611
Here, `first` has type `B`, referring to `map`'s `B` type parameter;
3612-
and `rest` has type `~[B]`, a vector type with element type `B`.
3612+
and `rest` has type `Vec<B>`, a vector type with element type `B`.
36133613

36143614
### Self types
36153615

branches/try2/src/doc/tutorial.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,8 +1588,8 @@ let mut numbers = vec![1, 2, 3];
15881588
numbers.push(4);
15891589
numbers.push(5);
15901590
1591-
// The type of a unique vector is written as `~[int]`
1592-
let more_numbers: ~[int] = numbers.move_iter().collect();
1591+
// The type of a unique vector is written as `Vec<int>`
1592+
let more_numbers: Vec<int> = numbers.move_iter().map(|i| i+1).collect();
15931593
15941594
// The original `numbers` value can no longer be used, due to move semantics.
15951595
@@ -1633,7 +1633,7 @@ view[0] = 5;
16331633
let ys: &mut [int] = &mut [1, 2, 3];
16341634
~~~
16351635

1636-
Square brackets denote indexing into a vector:
1636+
Square brackets denote indexing into a slice or fixed-size vector:
16371637

16381638
~~~~
16391639
# enum Crayon { Almond, AntiqueBrass, Apricot,
@@ -1647,7 +1647,7 @@ match crayons[0] {
16471647
}
16481648
~~~~
16491649

1650-
A vector can be destructured using pattern matching:
1650+
A slice or fixed-size vector can be destructured using pattern matching:
16511651

16521652
~~~~
16531653
let numbers: &[int] = &[1, 2, 3];
@@ -1660,9 +1660,10 @@ let score = match numbers {
16601660
~~~~
16611661

16621662
Both vectors and strings support a number of useful [methods](#methods),
1663-
defined in [`std::vec`] and [`std::str`].
1663+
defined in [`std::vec`], [`std::slice`], and [`std::str`].
16641664

16651665
[`std::vec`]: std/vec/index.html
1666+
[`std::slice`]: std/slice/index.html
16661667
[`std::str`]: std/str/index.html
16671668

16681669
# Ownership escape hatches

branches/try2/src/libcore/cast.rs

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,6 @@ use mem;
1414
use intrinsics;
1515
use ptr::copy_nonoverlapping_memory;
1616

17-
/// Casts the value at `src` to U. The two types must have the same length.
18-
#[inline]
19-
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
20-
let mut dest: U = mem::uninit();
21-
let dest_ptr: *mut u8 = transmute(&mut dest);
22-
let src_ptr: *u8 = transmute(src);
23-
copy_nonoverlapping_memory(dest_ptr, src_ptr, mem::size_of::<U>());
24-
dest
25-
}
26-
27-
/**
28-
* Move a thing into the void
29-
*
30-
* The forget function will take ownership of the provided value but neglect
31-
* to run any required cleanup or memory-management operations on it.
32-
*/
33-
#[inline]
34-
pub unsafe fn forget<T>(thing: T) { intrinsics::forget(thing); }
35-
36-
/**
37-
* Force-increment the reference count on a shared box. If used
38-
* carelessly, this can leak the box.
39-
*/
40-
#[inline]
41-
pub unsafe fn bump_box_refcount<T>(t: @T) { forget(t); }
42-
4317
/**
4418
* Transform a value of one type into a value of another type.
4519
* Both types must have the same size and alignment.
@@ -54,10 +28,29 @@ pub unsafe fn bump_box_refcount<T>(t: @T) { forget(t); }
5428
* ```
5529
*/
5630
#[inline]
57-
pub unsafe fn transmute<L, G>(thing: L) -> G {
31+
pub unsafe fn transmute<T, U>(thing: T) -> U {
5832
intrinsics::transmute(thing)
5933
}
6034

35+
/**
36+
* Move a thing into the void
37+
*
38+
* The forget function will take ownership of the provided value but neglect
39+
* to run any required cleanup or memory-management operations on it.
40+
*/
41+
#[inline]
42+
pub unsafe fn forget<T>(thing: T) { intrinsics::forget(thing); }
43+
44+
/// Casts the value at `src` to U. The two types must have the same length.
45+
#[inline]
46+
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
47+
let mut dest: U = mem::uninit();
48+
let dest_ptr: *mut u8 = transmute(&mut dest);
49+
let src_ptr: *u8 = transmute(src);
50+
copy_nonoverlapping_memory(dest_ptr, src_ptr, mem::size_of::<U>());
51+
dest
52+
}
53+
6154
/// Coerce an immutable reference to be mutable.
6255
#[inline]
6356
#[deprecated="casting &T to &mut T is undefined behaviour: use Cell<T>, RefCell<T> or Unsafe<T>"]
@@ -106,7 +99,7 @@ pub unsafe fn copy_lifetime_vec<'a,S,T>(_ptr: &'a [S], ptr: &T) -> &'a T {
10699

107100
#[cfg(test)]
108101
mod tests {
109-
use cast::{bump_box_refcount, transmute};
102+
use cast::transmute;
110103
use raw;
111104
use realstd::str::StrAllocating;
112105

@@ -115,21 +108,6 @@ mod tests {
115108
assert_eq!(1u, unsafe { ::cast::transmute_copy(&1) });
116109
}
117110

118-
#[test]
119-
fn test_bump_managed_refcount() {
120-
unsafe {
121-
let managed = @"box box box".to_owned(); // refcount 1
122-
bump_box_refcount(managed); // refcount 2
123-
let ptr: *int = transmute(managed); // refcount 2
124-
let _box1: @~str = ::cast::transmute_copy(&ptr);
125-
let _box2: @~str = ::cast::transmute_copy(&ptr);
126-
assert!(*_box1 == "box box box".to_owned());
127-
assert!(*_box2 == "box box box".to_owned());
128-
// Will destroy _box1 and _box2. Without the bump, this would
129-
// use-after-free. With too many bumps, it would leak.
130-
}
131-
}
132-
133111
#[test]
134112
fn test_transmute() {
135113
unsafe {

branches/try2/src/libcore/cell.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-
//! Types dealing with dynamic mutability
11+
//! Types that provide interior mutability.
1212
1313
use clone::Clone;
1414
use cmp::Eq;

branches/try2/src/libcore/iter.rs

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,8 @@ pub trait Iterator<A> {
455455
///
456456
/// ```rust
457457
/// let a = [1, 2, 3, 4, 5];
458-
/// let b: ~[int] = a.iter().map(|&x| x).collect();
459-
/// assert!(a == b);
458+
/// let b: Vec<int> = a.iter().map(|&x| x).collect();
459+
/// assert!(a.as_slice() == b.as_slice());
460460
/// ```
461461
#[inline]
462462
fn collect<B: FromIterator<A>>(&mut self) -> B {
@@ -2340,8 +2340,8 @@ mod tests {
23402340
#[test]
23412341
fn test_counter_from_iter() {
23422342
let it = count(0, 5).take(10);
2343-
let xs: ~[int] = FromIterator::from_iter(it);
2344-
assert_eq!(xs, box [0, 5, 10, 15, 20, 25, 30, 35, 40, 45]);
2343+
let xs: Vec<int> = FromIterator::from_iter(it);
2344+
assert_eq!(xs, vec![0, 5, 10, 15, 20, 25, 30, 35, 40, 45]);
23452345
}
23462346

23472347
#[test]
@@ -2371,7 +2371,7 @@ mod tests {
23712371
fn test_filter_map() {
23722372
let mut it = count(0u, 1u).take(10)
23732373
.filter_map(|x| if x % 2 == 0 { Some(x*x) } else { None });
2374-
assert_eq!(it.collect::<~[uint]>(), box [0*0, 2*2, 4*4, 6*6, 8*8]);
2374+
assert_eq!(it.collect::<Vec<uint>>(), vec![0*0, 2*2, 4*4, 6*6, 8*8]);
23752375
}
23762376

23772377
#[test]
@@ -2493,7 +2493,7 @@ mod tests {
24932493
let ys = xs.iter()
24942494
.map(|&x| x)
24952495
.inspect(|_| n += 1)
2496-
.collect::<~[uint]>();
2496+
.collect::<Vec<uint>>();
24972497

24982498
assert_eq!(n, xs.len());
24992499
assert_eq!(xs.as_slice(), ys.as_slice());
@@ -2628,8 +2628,8 @@ mod tests {
26282628

26292629
#[test]
26302630
fn test_collect() {
2631-
let a = box [1, 2, 3, 4, 5];
2632-
let b: ~[int] = a.iter().map(|&x| x).collect();
2631+
let a = vec![1, 2, 3, 4, 5];
2632+
let b: Vec<int> = a.iter().map(|&x| x).collect();
26332633
assert_eq!(a, b);
26342634
}
26352635

@@ -2702,7 +2702,7 @@ mod tests {
27022702
let mut it = xs.iter();
27032703
it.next();
27042704
it.next();
2705-
assert_eq!(it.rev().map(|&x| x).collect::<~[int]>(), box [16, 14, 12, 10, 8, 6]);
2705+
assert_eq!(it.rev().map(|&x| x).collect::<Vec<int>>(), vec![16, 14, 12, 10, 8, 6]);
27062706
}
27072707

27082708
#[test]
@@ -2940,12 +2940,12 @@ mod tests {
29402940

29412941
#[test]
29422942
fn test_double_ended_range() {
2943-
assert_eq!(range(11i, 14).rev().collect::<~[int]>(), box [13i, 12, 11]);
2943+
assert_eq!(range(11i, 14).rev().collect::<Vec<int>>(), vec![13i, 12, 11]);
29442944
for _ in range(10i, 0).rev() {
29452945
fail!("unreachable");
29462946
}
29472947

2948-
assert_eq!(range(11u, 14).rev().collect::<~[uint]>(), box [13u, 12, 11]);
2948+
assert_eq!(range(11u, 14).rev().collect::<Vec<uint>>(), vec![13u, 12, 11]);
29492949
for _ in range(10u, 0).rev() {
29502950
fail!("unreachable");
29512951
}
@@ -2997,13 +2997,14 @@ mod tests {
29972997
}
29982998
}
29992999

3000-
assert_eq!(range(0i, 5).collect::<~[int]>(), box [0i, 1, 2, 3, 4]);
3001-
assert_eq!(range(-10i, -1).collect::<~[int]>(), box [-10, -9, -8, -7, -6, -5, -4, -3, -2]);
3002-
assert_eq!(range(0i, 5).rev().collect::<~[int]>(), box [4, 3, 2, 1, 0]);
3003-
assert_eq!(range(200, -5).collect::<~[int]>(), box []);
3004-
assert_eq!(range(200, -5).rev().collect::<~[int]>(), box []);
3005-
assert_eq!(range(200, 200).collect::<~[int]>(), box []);
3006-
assert_eq!(range(200, 200).rev().collect::<~[int]>(), box []);
3000+
assert_eq!(range(0i, 5).collect::<Vec<int>>(), vec![0i, 1, 2, 3, 4]);
3001+
assert_eq!(range(-10i, -1).collect::<Vec<int>>(),
3002+
vec![-10, -9, -8, -7, -6, -5, -4, -3, -2]);
3003+
assert_eq!(range(0i, 5).rev().collect::<Vec<int>>(), vec![4, 3, 2, 1, 0]);
3004+
assert_eq!(range(200, -5).collect::<Vec<int>>(), vec![]);
3005+
assert_eq!(range(200, -5).rev().collect::<Vec<int>>(), vec![]);
3006+
assert_eq!(range(200, 200).collect::<Vec<int>>(), vec![]);
3007+
assert_eq!(range(200, 200).rev().collect::<Vec<int>>(), vec![]);
30073008

30083009
assert_eq!(range(0i, 100).size_hint(), (100, Some(100)));
30093010
// this test is only meaningful when sizeof uint < sizeof u64
@@ -3014,32 +3015,32 @@ mod tests {
30143015

30153016
#[test]
30163017
fn test_range_inclusive() {
3017-
assert_eq!(range_inclusive(0i, 5).collect::<~[int]>(), box [0i, 1, 2, 3, 4, 5]);
3018-
assert_eq!(range_inclusive(0i, 5).rev().collect::<~[int]>(), box [5i, 4, 3, 2, 1, 0]);
3019-
assert_eq!(range_inclusive(200, -5).collect::<~[int]>(), box []);
3020-
assert_eq!(range_inclusive(200, -5).rev().collect::<~[int]>(), box []);
3021-
assert_eq!(range_inclusive(200, 200).collect::<~[int]>(), box [200]);
3022-
assert_eq!(range_inclusive(200, 200).rev().collect::<~[int]>(), box [200]);
3018+
assert_eq!(range_inclusive(0i, 5).collect::<Vec<int>>(), vec![0i, 1, 2, 3, 4, 5]);
3019+
assert_eq!(range_inclusive(0i, 5).rev().collect::<Vec<int>>(), vec![5i, 4, 3, 2, 1, 0]);
3020+
assert_eq!(range_inclusive(200, -5).collect::<Vec<int>>(), vec![]);
3021+
assert_eq!(range_inclusive(200, -5).rev().collect::<Vec<int>>(), vec![]);
3022+
assert_eq!(range_inclusive(200, 200).collect::<Vec<int>>(), vec![200]);
3023+
assert_eq!(range_inclusive(200, 200).rev().collect::<Vec<int>>(), vec![200]);
30233024
}
30243025

30253026
#[test]
30263027
fn test_range_step() {
3027-
assert_eq!(range_step(0i, 20, 5).collect::<~[int]>(), box [0, 5, 10, 15]);
3028-
assert_eq!(range_step(20i, 0, -5).collect::<~[int]>(), box [20, 15, 10, 5]);
3029-
assert_eq!(range_step(20i, 0, -6).collect::<~[int]>(), box [20, 14, 8, 2]);
3030-
assert_eq!(range_step(200u8, 255, 50).collect::<~[u8]>(), box [200u8, 250]);
3031-
assert_eq!(range_step(200, -5, 1).collect::<~[int]>(), box []);
3032-
assert_eq!(range_step(200, 200, 1).collect::<~[int]>(), box []);
3028+
assert_eq!(range_step(0i, 20, 5).collect::<Vec<int>>(), vec![0, 5, 10, 15]);
3029+
assert_eq!(range_step(20i, 0, -5).collect::<Vec<int>>(), vec![20, 15, 10, 5]);
3030+
assert_eq!(range_step(20i, 0, -6).collect::<Vec<int>>(), vec![20, 14, 8, 2]);
3031+
assert_eq!(range_step(200u8, 255, 50).collect::<Vec<u8>>(), vec![200u8, 250]);
3032+
assert_eq!(range_step(200, -5, 1).collect::<Vec<int>>(), vec![]);
3033+
assert_eq!(range_step(200, 200, 1).collect::<Vec<int>>(), vec![]);
30333034
}
30343035

30353036
#[test]
30363037
fn test_range_step_inclusive() {
3037-
assert_eq!(range_step_inclusive(0i, 20, 5).collect::<~[int]>(), box [0, 5, 10, 15, 20]);
3038-
assert_eq!(range_step_inclusive(20i, 0, -5).collect::<~[int]>(), box [20, 15, 10, 5, 0]);
3039-
assert_eq!(range_step_inclusive(20i, 0, -6).collect::<~[int]>(), box [20, 14, 8, 2]);
3040-
assert_eq!(range_step_inclusive(200u8, 255, 50).collect::<~[u8]>(), box [200u8, 250]);
3041-
assert_eq!(range_step_inclusive(200, -5, 1).collect::<~[int]>(), box []);
3042-
assert_eq!(range_step_inclusive(200, 200, 1).collect::<~[int]>(), box [200]);
3038+
assert_eq!(range_step_inclusive(0i, 20, 5).collect::<Vec<int>>(), vec![0, 5, 10, 15, 20]);
3039+
assert_eq!(range_step_inclusive(20i, 0, -5).collect::<Vec<int>>(), vec![20, 15, 10, 5, 0]);
3040+
assert_eq!(range_step_inclusive(20i, 0, -6).collect::<Vec<int>>(), vec![20, 14, 8, 2]);
3041+
assert_eq!(range_step_inclusive(200u8, 255, 50).collect::<Vec<u8>>(), vec![200u8, 250]);
3042+
assert_eq!(range_step_inclusive(200, -5, 1).collect::<Vec<int>>(), vec![]);
3043+
assert_eq!(range_step_inclusive(200, 200, 1).collect::<Vec<int>>(), vec![200]);
30433044
}
30443045

30453046
#[test]

0 commit comments

Comments
 (0)