Skip to content

Commit 153bb44

Browse files
committed
---
yaml --- r: 130199 b: refs/heads/master c: 5b0d3ad h: refs/heads/master i: 130197: 54d58d2 130195: 7ffde8e 130191: f99a48e v: v3
1 parent 137faf0 commit 153bb44

File tree

118 files changed

+800
-1251
lines changed

Some content is hidden

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

118 files changed

+800
-1251
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: 074d3da7b09883658cd0d52d53ebac7ee74e9e28
2+
refs/heads/master: 5b0d3adf3debde4cd21e7adb1f434580386d7265
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 67b97ab6d2b7de9b69fd97dc171fcf8feec932ff
55
refs/heads/try: 28d5878c1f0465c11c8e7a3085008b0c592d48d0

trunk/src/driver/driver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
// except according to those terms.
1010

1111
#[cfg(rustdoc)]
12-
extern crate "rustdoc" as this;
12+
extern crate this = "rustdoc";
1313

1414
#[cfg(rustc)]
15-
extern crate "rustc" as this;
15+
extern crate this = "rustc";
1616

1717
fn main() { this::main() }

trunk/src/libcollections/bitv.rs

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,20 @@ fn match_words <'a,'b>(a: &'a Bitv, b: &'b Bitv) -> (MatchWords<'a>, MatchWords<
9595
static TRUE: bool = true;
9696
static FALSE: bool = false;
9797

98+
#[deriving(Clone)]
99+
struct SmallBitv {
100+
/// only the lowest nbits of this value are used. the rest is undefined.
101+
bits: uint
102+
}
103+
104+
#[deriving(Clone)]
105+
struct BigBitv {
106+
storage: Vec<uint>
107+
}
108+
109+
#[deriving(Clone)]
110+
enum BitvVariant { Big(BigBitv), Small(SmallBitv) }
111+
98112
/// The bitvector type.
99113
///
100114
/// # Example
@@ -1639,7 +1653,6 @@ impl<'a> Iterator<uint> for TwoBitPositions<'a> {
16391653
#[cfg(test)]
16401654
mod tests {
16411655
use std::prelude::*;
1642-
use std::iter::range_step;
16431656
use std::uint;
16441657
use std::rand;
16451658
use std::rand::Rng;
@@ -2033,14 +2046,12 @@ mod tests {
20332046

20342047
#[test]
20352048
fn test_bitv_iterator() {
2036-
let bools = vec![true, false, true, true];
2049+
let bools = [true, false, true, true];
20372050
let bitv: Bitv = bools.iter().map(|n| *n).collect();
20382051

2039-
assert_eq!(bitv.iter().collect::<Vec<bool>>(), bools)
2040-
2041-
let long = Vec::from_fn(10000, |i| i % 2 == 0);
2042-
let bitv: Bitv = long.iter().map(|n| *n).collect();
2043-
assert_eq!(bitv.iter().collect::<Vec<bool>>(), long)
2052+
for (act, &ex) in bitv.iter().zip(bools.iter()) {
2053+
assert_eq!(ex, act);
2054+
}
20442055
}
20452056

20462057
#[test]
@@ -2050,12 +2061,6 @@ mod tests {
20502061

20512062
let idxs: Vec<uint> = bitv.iter().collect();
20522063
assert_eq!(idxs, vec!(0, 2, 3));
2053-
2054-
let long: BitvSet = range(0u, 10000).map(|n| n % 2 == 0).collect();
2055-
let real = range_step(0, 10000, 2).collect::<Vec<uint>>();
2056-
2057-
let idxs: Vec<uint> = long.iter().collect();
2058-
assert_eq!(idxs, real);
20592064
}
20602065

20612066
#[test]
@@ -2569,7 +2574,7 @@ mod tests {
25692574
}
25702575

25712576
#[bench]
2572-
fn bench_bitv_set_big_fixed(b: &mut Bencher) {
2577+
fn bench_bitv_big(b: &mut Bencher) {
25732578
let mut r = rng();
25742579
let mut bitv = Bitv::with_capacity(BENCH_BITS, false);
25752580
b.iter(|| {
@@ -2581,19 +2586,7 @@ mod tests {
25812586
}
25822587

25832588
#[bench]
2584-
fn bench_bitv_set_big_variable(b: &mut Bencher) {
2585-
let mut r = rng();
2586-
let mut bitv = Bitv::with_capacity(BENCH_BITS, false);
2587-
b.iter(|| {
2588-
for i in range(0u, 100) {
2589-
bitv.set((r.next_u32() as uint) % BENCH_BITS, r.gen());
2590-
}
2591-
&bitv
2592-
})
2593-
}
2594-
2595-
#[bench]
2596-
fn bench_bitv_set_small(b: &mut Bencher) {
2589+
fn bench_bitv_small(b: &mut Bencher) {
25972590
let mut r = rng();
25982591
let mut bitv = Bitv::with_capacity(uint::BITS, false);
25992592
b.iter(|| {
@@ -2605,7 +2598,7 @@ mod tests {
26052598
}
26062599

26072600
#[bench]
2608-
fn bench_bitvset_small(b: &mut Bencher) {
2601+
fn bench_bitv_set_small(b: &mut Bencher) {
26092602
let mut r = rng();
26102603
let mut bitv = BitvSet::new();
26112604
b.iter(|| {
@@ -2617,7 +2610,7 @@ mod tests {
26172610
}
26182611

26192612
#[bench]
2620-
fn bench_bitvset_big(b: &mut Bencher) {
2613+
fn bench_bitv_set_big(b: &mut Bencher) {
26212614
let mut r = rng();
26222615
let mut bitv = BitvSet::new();
26232616
b.iter(|| {

trunk/src/libcollections/dlist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<T> Rawlink<T> {
9090
/// Convert the `Rawlink` into an Option value
9191
fn resolve_immut<'a>(&self) -> Option<&'a T> {
9292
unsafe {
93-
self.p.as_ref()
93+
mem::transmute(self.p.to_option())
9494
}
9595
}
9696

trunk/src/libcollections/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ pub trait Set<T>: Collection {
289289
}
290290

291291
/// A mutable collection of values which are distinct from one another that
292-
/// can be mutated.
292+
/// can be mutaed.
293293
pub trait MutableSet<T>: Set<T> + Mutable {
294294
/// Adds a value to the set. Returns `true` if the value was not already
295295
/// present in the set.

trunk/src/libcollections/ringbuf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl<T> RingBuf<T> {
132132
elts: Vec::from_fn(cmp::max(MINIMUM_CAPACITY, n), |_| None)}
133133
}
134134

135-
/// Retrieve an element in the `RingBuf` by index.
135+
/// Retrieva an element in the `RingBuf` by index.
136136
///
137137
/// Fails if there is no element with the given index.
138138
///

trunk/src/libcollections/smallintmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl<V:Clone> SmallIntMap<V> {
324324
/// Updates a value in the map. If the key already exists in the map,
325325
/// modifies the value with `ff` taking `oldval, newval`.
326326
/// Otherwise, sets the value to `newval`.
327-
/// Returns `true` if the key did not already exist in the map.
327+
/// Returasn `true` if the key did not already exist in the map.
328328
///
329329
/// # Example
330330
///

trunk/src/libcollections/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
//!
4545
//! # Representation
4646
//!
47-
//! Rust's string type, `str`, is a sequence of Unicode scalar values encoded as a
47+
//! Rust's string type, `str`, is a sequence of unicode scalar values encoded as a
4848
//! stream of UTF-8 bytes. All strings are guaranteed to be validly encoded UTF-8
4949
//! sequences. Additionally, strings are not null-terminated and can contain null
5050
//! bytes.

trunk/src/libcore/char.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ pub fn escape_unicode(c: char, f: |char|) {
201201
/// - Tab, CR and LF are escaped as '\t', '\r' and '\n' respectively.
202202
/// - Single-quote, double-quote and backslash chars are backslash-escaped.
203203
/// - Any other chars in the range [0x20,0x7e] are not escaped.
204-
/// - Any other chars are given hex Unicode escapes; see `escape_unicode`.
204+
/// - Any other chars are given hex unicode escapes; see `escape_unicode`.
205205
///
206206
pub fn escape_default(c: char, f: |char|) {
207207
match c {
@@ -290,7 +290,7 @@ pub trait Char {
290290
/// * Single-quote, double-quote and backslash chars are backslash-
291291
/// escaped.
292292
/// * Any other chars in the range [0x20,0x7e] are not escaped.
293-
/// * Any other chars are given hex Unicode escapes; see `escape_unicode`.
293+
/// * Any other chars are given hex unicode escapes; see `escape_unicode`.
294294
fn escape_default(&self, f: |char|);
295295

296296
/// Returns the amount of bytes this character would need if encoded in

trunk/src/libcore/fmt/mod.rs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -461,28 +461,19 @@ impl<'a> Formatter<'a> {
461461
use char::Char;
462462
let align = match self.align {
463463
rt::AlignUnknown => default,
464-
_ => self.align
464+
rt::AlignLeft | rt::AlignRight => self.align
465465
};
466-
467-
let (pre_pad, post_pad) = match align {
468-
rt::AlignLeft => (0u, padding),
469-
rt::AlignRight | rt::AlignUnknown => (padding, 0u),
470-
rt::AlignCenter => (padding / 2, (padding + 1) / 2),
471-
};
472-
466+
if align == rt::AlignLeft {
467+
try!(f(self));
468+
}
473469
let mut fill = [0u8, ..4];
474470
let len = self.fill.encode_utf8(fill).unwrap_or(0);
475-
476-
for _ in range(0, pre_pad) {
471+
for _ in range(0, padding) {
477472
try!(self.buf.write(fill.slice_to(len)));
478473
}
479-
480-
try!(f(self));
481-
482-
for _ in range(0, post_pad) {
483-
try!(self.buf.write(fill.slice_to(len)));
474+
if align == rt::AlignRight {
475+
try!(f(self));
484476
}
485-
486477
Ok(())
487478
}
488479

trunk/src/libcore/fmt/rt.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ pub enum Alignment {
4343
AlignLeft,
4444
/// Indication that contents should be right-aligned.
4545
AlignRight,
46-
/// Indication that contents should be center-aligned.
47-
AlignCenter,
4846
/// No alignment was requested.
4947
AlignUnknown,
5048
}

trunk/src/libcore/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ extern "rust-intrinsic" {
311311

312312
/// Gives the address for the return value of the enclosing function.
313313
///
314-
/// Using this intrinsic in a function that does not use an out pointer
314+
/// Using this instrinsic in a function that does not use an out pointer
315315
/// will trigger a compiler error.
316316
pub fn return_address() -> *const u8;
317317

trunk/src/libcore/ptr.rs

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -256,46 +256,27 @@ pub unsafe fn position<T>(buf: *const T, f: |&T| -> bool) -> uint {
256256
pub trait RawPtr<T> {
257257
/// Returns the null pointer.
258258
fn null() -> Self;
259-
260259
/// Returns true if the pointer is equal to the null pointer.
261260
fn is_null(&self) -> bool;
262-
263261
/// Returns true if the pointer is not equal to the null pointer.
264262
fn is_not_null(&self) -> bool { !self.is_null() }
265-
266263
/// Returns the value of this pointer (ie, the address it points to)
267264
fn to_uint(&self) -> uint;
268-
269-
/// Returns `None` if the pointer is null, or else returns a reference to the
270-
/// value wrapped in `Some`.
265+
/// Returns `None` if the pointer is null, or else returns the value wrapped
266+
/// in `Some`.
271267
///
272268
/// # Safety Notes
273269
///
274-
/// While this method and its mutable counterpart are useful for null-safety,
275-
/// it is important to note that this is still an unsafe operation because
276-
/// the returned value could be pointing to invalid memory.
277-
unsafe fn as_ref<'a>(&self) -> Option<&'a T>;
278-
279-
/// A synonym for `as_ref`, except with incorrect lifetime semantics
280-
#[deprecated="Use `as_ref` instead"]
281-
unsafe fn to_option<'a>(&'a self) -> Option<&'a T> {
282-
mem::transmute(self.as_ref())
283-
}
284-
270+
/// While this method is useful for null-safety, it is important to note
271+
/// that this is still an unsafe operation because the returned value could
272+
/// be pointing to invalid memory.
273+
unsafe fn to_option(&self) -> Option<&T>;
285274
/// Calculates the offset from a pointer. The offset *must* be in-bounds of
286275
/// the object, or one-byte-past-the-end. `count` is in units of T; e.g. a
287276
/// `count` of 3 represents a pointer offset of `3 * sizeof::<T>()` bytes.
288277
unsafe fn offset(self, count: int) -> Self;
289278
}
290279

291-
/// Methods on mutable raw pointers
292-
pub trait RawMutPtr<T>{
293-
/// Returns `None` if the pointer is null, or else returns a mutable reference
294-
/// to the value wrapped in `Some`. As with `as_ref`, this is unsafe because
295-
/// it cannot verify the validity of the returned pointer.
296-
unsafe fn as_mut<'a>(&self) -> Option<&'a mut T>;
297-
}
298-
299280
impl<T> RawPtr<T> for *const T {
300281
#[inline]
301282
fn null() -> *const T { null() }
@@ -312,7 +293,7 @@ impl<T> RawPtr<T> for *const T {
312293
}
313294

314295
#[inline]
315-
unsafe fn as_ref<'a>(&self) -> Option<&'a T> {
296+
unsafe fn to_option(&self) -> Option<&T> {
316297
if self.is_null() {
317298
None
318299
} else {
@@ -337,7 +318,7 @@ impl<T> RawPtr<T> for *mut T {
337318
}
338319

339320
#[inline]
340-
unsafe fn as_ref<'a>(&self) -> Option<&'a T> {
321+
unsafe fn to_option(&self) -> Option<&T> {
341322
if self.is_null() {
342323
None
343324
} else {
@@ -346,17 +327,6 @@ impl<T> RawPtr<T> for *mut T {
346327
}
347328
}
348329

349-
impl<T> RawMutPtr<T> for *mut T {
350-
#[inline]
351-
unsafe fn as_mut<'a>(&self) -> Option<&'a mut T> {
352-
if self.is_null() {
353-
None
354-
} else {
355-
Some(&mut **self)
356-
}
357-
}
358-
}
359-
360330
// Equality for pointers
361331
impl<T> PartialEq for *const T {
362332
#[inline]

trunk/src/libcore/str.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ pub trait StrSlice<'a> {
11281128
fn contains_char(&self, needle: char) -> bool;
11291129

11301130
/// An iterator over the characters of `self`. Note, this iterates
1131-
/// over Unicode code-points, not Unicode graphemes.
1131+
/// over unicode code-points, not unicode graphemes.
11321132
///
11331133
/// # Example
11341134
///
@@ -1505,7 +1505,7 @@ pub trait StrSlice<'a> {
15051505
/// Pluck a character out of a string and return the index of the next
15061506
/// character.
15071507
///
1508-
/// This function can be used to iterate over the Unicode characters of a
1508+
/// This function can be used to iterate over the unicode characters of a
15091509
/// string.
15101510
///
15111511
/// # Example
@@ -1549,7 +1549,7 @@ pub trait StrSlice<'a> {
15491549
/// # Return value
15501550
///
15511551
/// A record {ch: char, next: uint} containing the char value and the byte
1552-
/// index of the next Unicode character.
1552+
/// index of the next unicode character.
15531553
///
15541554
/// # Failure
15551555
///
@@ -1559,7 +1559,7 @@ pub trait StrSlice<'a> {
15591559

15601560
/// Given a byte position and a str, return the previous char and its position.
15611561
///
1562-
/// This function can be used to iterate over a Unicode string in reverse.
1562+
/// This function can be used to iterate over a unicode string in reverse.
15631563
///
15641564
/// Returns 0 for next index if called on start index 0.
15651565
///

0 commit comments

Comments
 (0)