Skip to content

Commit db63c04

Browse files
committed
---
yaml --- r: 150734 b: refs/heads/try2 c: 65abf96 h: refs/heads/master v: v3
1 parent 07264c6 commit db63c04

File tree

173 files changed

+2427
-1837
lines changed

Some content is hidden

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

173 files changed

+2427
-1837
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: ee4c770f8ba364857b97a8c51c3eda14120b9ac5
8+
refs/heads/try2: 65abf96fb6630d7ddbcdc3b39f599c02ecfc2f1e
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/docs.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ LIB_DOC_DEP_$(1) = $$(CRATEFILE_$(1)) $$(RSINPUTS_$(1))
269269
endif
270270

271271
$(2) += doc/$(1)/index.html
272+
doc/$(1)/index.html: CFG_COMPILER_HOST_TRIPLE = $(CFG_TARGET)
272273
doc/$(1)/index.html: $$(LIB_DOC_DEP_$(1))
273274
@$$(call E, rustdoc $$@)
274275
$$(Q)$$(RUSTDOC) --cfg dox --cfg stage2 $$<

branches/try2/mk/main.mk

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,17 +358,13 @@ CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
358358
endif
359359
endif
360360

361-
ifdef CFG_DISABLE_RPATH
362361
ifeq ($$(OSTYPE_$(3)),apple-darwin)
363362
RPATH_VAR$(1)_T_$(2)_H_$(3) := \
364363
DYLD_LIBRARY_PATH="$$$$DYLD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))"
365364
else
366365
RPATH_VAR$(1)_T_$(2)_H_$(3) := \
367366
LD_LIBRARY_PATH="$$$$LD_LIBRARY_PATH:$$(CURDIR)/$$(HLIB$(1)_H_$(3))"
368367
endif
369-
else
370-
RPATH_VAR$(1)_T_$(2)_H_$(3) :=
371-
endif
372368

373369
STAGE$(1)_T_$(2)_H_$(3) := \
374370
$$(Q)$$(RPATH_VAR$(1)_T_$(2)_H_$(3)) \

branches/try2/src/compiletest/runtest.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use std::io::timer;
3131
use std::io;
3232
use std::os;
3333
use std::str;
34+
use std::strbuf::StrBuf;
3435
use std::task;
3536
use std::slice;
3637
use test::MetricMap;
@@ -328,10 +329,10 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
328329
}
329330

330331
let args = split_maybe_args(&config.target_rustcflags);
331-
let mut tool_path:~str = ~"";
332+
let mut tool_path = StrBuf::new();
332333
for arg in args.iter() {
333334
if arg.contains("android-cross-path=") {
334-
tool_path = arg.replace("android-cross-path=","");
335+
tool_path = StrBuf::from_str(arg.replace("android-cross-path=", ""));
335336
break;
336337
}
337338
}
@@ -348,7 +349,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
348349
let gdb_path = tool_path.append("/bin/arm-linux-androideabi-gdb");
349350
let procsrv::Result{ out, err, status }=
350351
procsrv::run("",
351-
gdb_path,
352+
gdb_path.as_slice(),
352353
debugger_opts.as_slice(),
353354
vec!((~"",~"")),
354355
None)
@@ -451,7 +452,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
451452
let options_to_remove = [~"-O", ~"-g", ~"--debuginfo"];
452453
let new_options = split_maybe_args(options).move_iter()
453454
.filter(|x| !options_to_remove.contains(x))
454-
.collect::<~[~str]>()
455+
.collect::<Vec<~str>>()
455456
.connect(" ");
456457
Some(new_options)
457458
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,3 +496,16 @@ NUL-terminated string for interoperability with C, you should use the `c_str::to
496496

497497
The standard library includes type aliases and function definitions for the C standard library in
498498
the `libc` module, and Rust links against `libc` and `libm` by default.
499+
500+
# The "nullable pointer optimization"
501+
502+
Certain types are defined to not be `null`. This includes references (`&T`,
503+
`&mut T`), owning pointers (`~T`), and function pointers (`extern "abi"
504+
fn()`). When interfacing with C, pointers that might be null are often used.
505+
As a special case, a generic `enum` that contains exactly two variants, one of
506+
which contains no data and the other containing a single field, is eligible
507+
for the "nullable pointer optimization". When such an enum is instantiated
508+
with one of the non-nullable types, it is represented as a single pointer,
509+
and the non-data variant is represented as the null pointer. So
510+
`Option<extern "C" fn(c_int) -> c_int>` is how one represents a nullable
511+
function pointer using the C ABI.

branches/try2/src/doc/tutorial.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1579,6 +1579,8 @@ allocated memory on the heap. A unique vector owns the elements it contains, so
15791579
the elements are mutable if the vector is mutable.
15801580
15811581
~~~
1582+
use std::strbuf::StrBuf;
1583+
15821584
// A dynamically sized vector (unique vector)
15831585
let mut numbers = ~[1, 2, 3];
15841586
numbers.push(4);
@@ -1589,7 +1591,7 @@ let more_numbers: ~[int] = numbers;
15891591

15901592
// The original `numbers` value can no longer be used, due to move semantics.
15911593

1592-
let mut string = ~"fo";
1594+
let mut string = StrBuf::from_str("fo");
15931595
string.push_char('o');
15941596
~~~
15951597

branches/try2/src/libcollections/bitv.rs

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ use std::cmp;
1515
use std::iter::RandomAccessIterator;
1616
use std::iter::{Rev, Enumerate, Repeat, Map, Zip};
1717
use std::ops;
18-
use std::uint;
1918
use std::slice;
19+
use std::strbuf::StrBuf;
20+
use std::uint;
2021

2122
#[deriving(Clone)]
2223
struct SmallBitv {
@@ -111,7 +112,7 @@ impl SmallBitv {
111112

112113
#[deriving(Clone)]
113114
struct BigBitv {
114-
storage: ~[uint]
115+
storage: Vec<uint>
115116
}
116117

117118
/**
@@ -131,7 +132,7 @@ fn big_mask(nbits: uint, elem: uint) -> uint {
131132
}
132133

133134
impl BigBitv {
134-
pub fn new(storage: ~[uint]) -> BigBitv {
135+
pub fn new(storage: Vec<uint>) -> BigBitv {
135136
BigBitv {storage: storage}
136137
}
137138

@@ -193,7 +194,7 @@ impl BigBitv {
193194
pub fn get(&self, i: uint) -> bool {
194195
let w = i / uint::BITS;
195196
let b = i % uint::BITS;
196-
let x = 1 & self.storage[w] >> b;
197+
let x = 1 & self.storage.get(w) >> b;
197198
x == 1
198199
}
199200

@@ -202,15 +203,15 @@ impl BigBitv {
202203
let w = i / uint::BITS;
203204
let b = i % uint::BITS;
204205
let flag = 1 << b;
205-
self.storage[w] = if x { self.storage[w] | flag }
206-
else { self.storage[w] & !flag };
206+
*self.storage.get_mut(w) = if x { *self.storage.get(w) | flag }
207+
else { *self.storage.get(w) & !flag };
207208
}
208209

209210
#[inline]
210211
pub fn equals(&self, b: &BigBitv, nbits: uint) -> bool {
211212
for (i, elt) in b.storage.iter().enumerate() {
212213
let mask = big_mask(nbits, i);
213-
if mask & self.storage[i] != mask & *elt {
214+
if mask & *self.storage.get(i) != mask & *elt {
214215
return false;
215216
}
216217
}
@@ -278,13 +279,13 @@ impl Bitv {
278279
let s =
279280
if init {
280281
if exact {
281-
slice::from_elem(nelems, !0u)
282+
Vec::from_elem(nelems, !0u)
282283
} else {
283-
let mut v = slice::from_elem(nelems-1, !0u);
284+
let mut v = Vec::from_elem(nelems-1, !0u);
284285
v.push((1<<nbits % uint::BITS)-1);
285286
v
286287
}
287-
} else { slice::from_elem(nelems, 0u)};
288+
} else { Vec::from_elem(nelems, 0u)};
288289
Big(BigBitv::new(s))
289290
};
290291
Bitv {rep: rep, nbits: nbits}
@@ -451,8 +452,8 @@ impl Bitv {
451452
*
452453
* Each `uint` in the resulting vector has either value `0u` or `1u`.
453454
*/
454-
pub fn to_vec(&self) -> ~[uint] {
455-
slice::from_fn(self.nbits, |x| self.init_to_vec(x))
455+
pub fn to_vec(&self) -> Vec<uint> {
456+
Vec::from_fn(self.nbits, |x| self.init_to_vec(x))
456457
}
457458

458459
/**
@@ -461,7 +462,7 @@ impl Bitv {
461462
* size of the `Bitv` is not a multiple of 8 then trailing bits
462463
* will be filled-in with false/0
463464
*/
464-
pub fn to_bytes(&self) -> ~[u8] {
465+
pub fn to_bytes(&self) -> Vec<u8> {
465466
fn bit (bitv: &Bitv, byte: uint, bit: uint) -> u8 {
466467
let offset = byte * 8 + bit;
467468
if offset >= bitv.nbits {
@@ -473,7 +474,7 @@ impl Bitv {
473474

474475
let len = self.nbits/8 +
475476
if self.nbits % 8 == 0 { 0 } else { 1 };
476-
slice::from_fn(len, |i|
477+
Vec::from_fn(len, |i|
477478
bit(self, i, 0) |
478479
bit(self, i, 1) |
479480
bit(self, i, 2) |
@@ -486,10 +487,10 @@ impl Bitv {
486487
}
487488

488489
/**
489-
* Transform `self` into a `[bool]` by turning each bit into a `bool`.
490+
* Transform `self` into a `Vec<bool>` by turning each bit into a `bool`.
490491
*/
491-
pub fn to_bools(&self) -> ~[bool] {
492-
slice::from_fn(self.nbits, |i| self[i])
492+
pub fn to_bools(&self) -> Vec<bool> {
493+
Vec::from_fn(self.nbits, |i| self[i])
493494
}
494495

495496
/**
@@ -499,15 +500,15 @@ impl Bitv {
499500
* character is either '0' or '1'.
500501
*/
501502
pub fn to_str(&self) -> ~str {
502-
let mut rs = ~"";
503+
let mut rs = StrBuf::new();
503504
for i in self.iter() {
504505
if i {
505506
rs.push_char('1');
506507
} else {
507508
rs.push_char('0');
508509
}
509510
};
510-
rs
511+
rs.into_owned()
511512
}
512513

513514

@@ -659,7 +660,7 @@ pub struct BitvSet {
659660
impl BitvSet {
660661
/// Creates a new bit vector set with initially no contents
661662
pub fn new() -> BitvSet {
662-
BitvSet{ size: 0, bitv: BigBitv::new(~[0]) }
663+
BitvSet{ size: 0, bitv: BigBitv::new(vec!(0)) }
663664
}
664665

665666
/// Creates a new bit vector set from the given bit vector
@@ -673,7 +674,7 @@ impl BitvSet {
673674
match rep {
674675
Big(b) => BitvSet{ size: size, bitv: b },
675676
Small(SmallBitv{bits}) =>
676-
BitvSet{ size: size, bitv: BigBitv{ storage: ~[bits] } },
677+
BitvSet{ size: size, bitv: BigBitv{ storage: vec!(bits) } },
677678
}
678679
}
679680

@@ -705,9 +706,9 @@ impl BitvSet {
705706
self.bitv.storage.grow(other.capacity() / uint::BITS, &0);
706707
}
707708
for (i, &w) in other.bitv.storage.iter().enumerate() {
708-
let old = self.bitv.storage[i];
709+
let old = *self.bitv.storage.get(i);
709710
let new = f(old, w);
710-
self.bitv.storage[i] = new;
711+
*self.bitv.storage.get_mut(i) = new;
711712
self.size += nbits(new) - nbits(old);
712713
}
713714
}
@@ -863,7 +864,7 @@ impl MutableSet<uint> for BitvSet {
863864

864865
// Attempt to truncate our storage
865866
let mut i = self.bitv.storage.len();
866-
while i > 1 && self.bitv.storage[i - 1] == 0 {
867+
while i > 1 && *self.bitv.storage.get(i - 1) == 0 {
867868
i -= 1;
868869
}
869870
self.bitv.storage.truncate(i);
@@ -878,12 +879,12 @@ impl BitvSet {
878879
/// w1, w2) where the bit location is the number of bits offset so far,
879880
/// and w1/w2 are the words coming from the two vectors self, other.
880881
fn commons<'a>(&'a self, other: &'a BitvSet)
881-
-> Map<'static, ((uint, &'a uint), &'a ~[uint]), (uint, uint, uint),
882-
Zip<Enumerate<slice::Items<'a, uint>>, Repeat<&'a ~[uint]>>> {
882+
-> Map<'static, ((uint, &'a uint), &'a Vec<uint>), (uint, uint, uint),
883+
Zip<Enumerate<slice::Items<'a, uint>>, Repeat<&'a Vec<uint>>>> {
883884
let min = cmp::min(self.bitv.storage.len(), other.bitv.storage.len());
884885
self.bitv.storage.slice(0, min).iter().enumerate()
885886
.zip(Repeat::new(&other.bitv.storage))
886-
.map(|((i, &w), o_store)| (i * uint::BITS, w, o_store[i]))
887+
.map(|((i, &w), o_store)| (i * uint::BITS, w, *o_store.get(i)))
887888
}
888889

889890
/// Visits each word in `self` or `other` that extends beyond the other. This
@@ -946,7 +947,6 @@ mod tests {
946947
use bitv;
947948

948949
use std::uint;
949-
use std::slice;
950950
use rand;
951951
use rand::Rng;
952952

@@ -964,8 +964,8 @@ mod tests {
964964
#[test]
965965
fn test_0_elements() {
966966
let act = Bitv::new(0u, false);
967-
let exp = slice::from_elem::<bool>(0u, false);
968-
assert!(act.eq_vec(exp));
967+
let exp = Vec::from_elem(0u, false);
968+
assert!(act.eq_vec(exp.as_slice()));
969969
}
970970
971971
#[test]
@@ -1299,12 +1299,12 @@ mod tests {
12991299
fn test_to_bytes() {
13001300
let mut bv = Bitv::new(3, true);
13011301
bv.set(1, false);
1302-
assert_eq!(bv.to_bytes(), ~[0b10100000]);
1302+
assert_eq!(bv.to_bytes(), vec!(0b10100000));
13031303
13041304
let mut bv = Bitv::new(9, false);
13051305
bv.set(2, true);
13061306
bv.set(8, true);
1307-
assert_eq!(bv.to_bytes(), ~[0b00100000, 0b10000000]);
1307+
assert_eq!(bv.to_bytes(), vec!(0b00100000, 0b10000000));
13081308
}
13091309
13101310
#[test]
@@ -1315,7 +1315,7 @@ mod tests {
13151315
13161316
#[test]
13171317
fn test_to_bools() {
1318-
let bools = ~[false, false, true, false, false, true, true, false];
1318+
let bools = vec!(false, false, true, false, false, true, true, false);
13191319
assert_eq!(from_bytes([0b00100110]).to_bools(), bools);
13201320
}
13211321
@@ -1334,8 +1334,8 @@ mod tests {
13341334
let bools = [true, false, true, true];
13351335
let bitv = BitvSet::from_bitv(from_bools(bools));
13361336
1337-
let idxs: ~[uint] = bitv.iter().collect();
1338-
assert_eq!(idxs, ~[0, 2, 3]);
1337+
let idxs: Vec<uint> = bitv.iter().collect();
1338+
assert_eq!(idxs, vec!(0, 2, 3));
13391339
}
13401340
13411341
#[test]
@@ -1579,7 +1579,7 @@ mod tests {
15791579
#[bench]
15801580
fn bench_big_bitv_small(b: &mut BenchHarness) {
15811581
let mut r = rng();
1582-
let mut bitv = BigBitv::new(~[0]);
1582+
let mut bitv = BigBitv::new(vec!(0));
15831583
b.iter(|| {
15841584
bitv.set((r.next_u32() as uint) % uint::BITS, true);
15851585
&bitv
@@ -1589,7 +1589,7 @@ mod tests {
15891589
#[bench]
15901590
fn bench_big_bitv_big(b: &mut BenchHarness) {
15911591
let mut r = rng();
1592-
let mut storage = ~[];
1592+
let mut storage = vec!();
15931593
storage.grow(BENCH_BITS / uint::BITS, &0u);
15941594
let mut bitv = BigBitv::new(storage);
15951595
b.iter(|| {

0 commit comments

Comments
 (0)