Skip to content

Commit 7e009a5

Browse files
committed
---
yaml --- r: 128927 b: refs/heads/try c: 3570095 h: refs/heads/master i: 128925: 5250d02 128923: 9d252d2 128919: 3510559 128911: cf9ea45 128895: 877d138 v: v3
1 parent 3f6c148 commit 7e009a5

Some content is hidden

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

92 files changed

+571
-282
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 07d86b46a949a94223da714e35b343243e4ecce4
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a86d9ad15e339ab343a12513f9c90556f677b9ca
5-
refs/heads/try: e7910322ccc4e4971dc2552959ccbbd7625286b0
5+
refs/heads/try: 3570095e34c58d5f40a3f81f4c970975befebe54
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/doc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ for the 'std' and 'extra' libraries.
1919
To generate HTML documentation from one source file/crate, do something like:
2020

2121
~~~~
22-
rustdoc --output-dir html-doc/ --output-format html ../src/libstd/path.rs
22+
rustdoc --output html-doc/ --output-format html ../src/libstd/path.rs
2323
~~~~
2424

2525
(This, of course, requires a working build of the `rustdoc` tool.)

branches/try/src/doc/guide.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ note: in expansion of format_args!
517517
<std macros>:1:1: 3:2 note: in expansion of println!
518518
src/hello_world.rs:4:5: 4:42 note: expansion site
519519
error: aborting due to previous error
520-
Could not execute process `rustc src/hello_world.rs --crate-type bin --out-dir /home/you/projects/hello_world/target -L /home/you/projects/hello_world/target -L /home/you/projects/hello_world/target/deps` (status=101)
520+
Could not compile `hello_world`.
521521
```
522522

523523
Rust will not let us use a value that has not been initialized. So why let us
@@ -532,7 +532,7 @@ in the middle of a string." We add a comma, and then `x`, to indicate that we
532532
want `x` to be the value we're interpolating. The comma is used to separate
533533
arguments we pass to functions and macros, if you're passing more than one.
534534

535-
When you just use the double curly braces, Rust will attempt to display the
535+
When you just use the curly braces, Rust will attempt to display the
536536
value in a meaningful way by checking out its type. If you want to specify the
537537
format in a more detailed manner, there are a [wide number of options
538538
available](/std/fmt/index.html). For now, we'll just stick to the default:
@@ -3669,10 +3669,9 @@ manually free this allocation! If we write
36693669
```
36703670

36713671
then Rust will automatically free `x` at the end of the block. This isn't
3672-
because Rust has a garbage collector -- it doesn't. Instead, Rust uses static
3673-
analysis to determine the *lifetime* of `x`, and then generates code to free it
3674-
once it's sure the `x` won't be used again. This Rust code will do the same
3675-
thing as the following C code:
3672+
because Rust has a garbage collector -- it doesn't. Instead, when `x` goes out
3673+
of scope, Rust `free`s `x`. This Rust code will do the same thing as the
3674+
following C code:
36763675

36773676
```{c,ignore}
36783677
{

branches/try/src/doc/rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1805,7 +1805,7 @@ module through the rules above. It essentially allows public access into the
18051805
re-exported item. For example, this program is valid:
18061806

18071807
~~~~
1808-
pub use api = self::implementation;
1808+
pub use self::implementation as api;
18091809
18101810
mod implementation {
18111811
pub fn f() {}

branches/try/src/doc/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3112,7 +3112,7 @@ use farm::*;
31123112
However, that's not all. You can also rename an item while you're bringing it into scope:
31133113

31143114
~~~
3115-
use egg_layer = farm::chicken;
3115+
use farm::chicken as egg_layer;
31163116
# mod farm { pub fn chicken() { println!("Laying eggs is fun!") } }
31173117
// ...
31183118
@@ -3335,7 +3335,7 @@ you just have to import it with an `use` statement.
33353335
For example, it re-exports `range` which is defined in `std::iter::range`:
33363336

33373337
~~~
3338-
use iter_range = std::iter::range;
3338+
use std::iter::range as iter_range;
33393339
33403340
fn main() {
33413341
// `range` is imported by default

branches/try/src/liballoc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ extern crate libc;
8686

8787
#[deprecated = "use boxed instead"]
8888
#[cfg(not(test))]
89-
pub use owned = boxed;
89+
pub use boxed as owned;
9090

9191
// Heaps provided for low-level allocation strategies
9292

branches/try/src/libcollections/bitv.rs

Lines changed: 131 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ use core::prelude::*;
6666
use core::cmp;
6767
use core::default::Default;
6868
use core::fmt;
69-
use core::iter::Take;
69+
use core::iter::{Chain, Enumerate, Repeat, Skip, Take};
7070
use core::iter;
7171
use core::slice;
7272
use core::uint;
@@ -75,6 +75,22 @@ use std::hash;
7575
use {Mutable, Set, MutableSet, MutableSeq};
7676
use vec::Vec;
7777

78+
type MatchWords<'a> = Chain<MaskWords<'a>, Skip<Take<Enumerate<Repeat<uint>>>>>;
79+
// Take two BitV's, and return iterators of their words, where the shorter one
80+
// has been padded with 0's
81+
fn match_words <'a,'b>(a: &'a Bitv, b: &'b Bitv) -> (MatchWords<'a>, MatchWords<'b>) {
82+
let a_len = a.storage.len();
83+
let b_len = b.storage.len();
84+
85+
// have to uselessly pretend to pad the longer one for type matching
86+
if a_len < b_len {
87+
(a.mask_words(0).chain(Repeat::new(0u).enumerate().take(b_len).skip(a_len)),
88+
b.mask_words(0).chain(Repeat::new(0u).enumerate().take(0).skip(0)))
89+
} else {
90+
(a.mask_words(0).chain(Repeat::new(0u).enumerate().take(0).skip(0)),
91+
b.mask_words(0).chain(Repeat::new(0u).enumerate().take(a_len).skip(b_len)))
92+
}
93+
}
7894

7995
static TRUE: bool = true;
8096
static FALSE: bool = false;
@@ -969,7 +985,7 @@ impl<'a> RandomAccessIterator<bool> for Bits<'a> {
969985
/// assert!(bv.eq_vec([true, true, false, true,
970986
/// false, false, false, false]));
971987
/// ```
972-
#[deriving(Clone, PartialEq, Eq, PartialOrd, Ord)]
988+
#[deriving(Clone)]
973989
pub struct BitvSet(Bitv);
974990

975991
impl Default for BitvSet {
@@ -992,6 +1008,32 @@ impl Extendable<bool> for BitvSet {
9921008
}
9931009
}
9941010

1011+
impl PartialOrd for BitvSet {
1012+
#[inline]
1013+
fn partial_cmp(&self, other: &BitvSet) -> Option<Ordering> {
1014+
let (a_iter, b_iter) = match_words(self.get_ref(), other.get_ref());
1015+
iter::order::partial_cmp(a_iter, b_iter)
1016+
}
1017+
}
1018+
1019+
impl Ord for BitvSet {
1020+
#[inline]
1021+
fn cmp(&self, other: &BitvSet) -> Ordering {
1022+
let (a_iter, b_iter) = match_words(self.get_ref(), other.get_ref());
1023+
iter::order::cmp(a_iter, b_iter)
1024+
}
1025+
}
1026+
1027+
impl cmp::PartialEq for BitvSet {
1028+
#[inline]
1029+
fn eq(&self, other: &BitvSet) -> bool {
1030+
let (a_iter, b_iter) = match_words(self.get_ref(), other.get_ref());
1031+
iter::order::eq(a_iter, b_iter)
1032+
}
1033+
}
1034+
1035+
impl cmp::Eq for BitvSet {}
1036+
9951037
impl BitvSet {
9961038
/// Create a new bit vector set with initially no contents.
9971039
///
@@ -1141,10 +1183,18 @@ impl BitvSet {
11411183
// Unwrap Bitvs
11421184
let &BitvSet(ref mut self_bitv) = self;
11431185
let &BitvSet(ref other_bitv) = other;
1186+
11441187
// Expand the vector if necessary
11451188
self_bitv.reserve(other_bitv.capacity());
1146-
// Apply values
1147-
for (i, w) in other_bitv.mask_words(0) {
1189+
1190+
// virtually pad other with 0's for equal lengths
1191+
let mut other_words = {
1192+
let (_, result) = match_words(self_bitv, other_bitv);
1193+
result
1194+
};
1195+
1196+
// Apply values found in other
1197+
for (i, w) in other_words {
11481198
let old = self_bitv.storage[i];
11491199
let new = f(old, w);
11501200
*self_bitv.storage.get_mut(i) = new;
@@ -1471,7 +1521,7 @@ impl Set<uint> for BitvSet {
14711521

14721522
#[inline]
14731523
fn is_disjoint(&self, other: &BitvSet) -> bool {
1474-
self.intersection(other).count() > 0
1524+
self.intersection(other).next().is_none()
14751525
}
14761526

14771527
#[inline]
@@ -2213,6 +2263,82 @@ mod tests {
22132263
assert!(set1.is_subset(&set2)); // { 2 } { 2, 4 }
22142264
}
22152265

2266+
#[test]
2267+
fn test_bitv_set_is_disjoint() {
2268+
let a = BitvSet::from_bitv(from_bytes([0b10100010]));
2269+
let b = BitvSet::from_bitv(from_bytes([0b01000000]));
2270+
let c = BitvSet::new();
2271+
let d = BitvSet::from_bitv(from_bytes([0b00110000]));
2272+
2273+
assert!(!a.is_disjoint(&d));
2274+
assert!(!d.is_disjoint(&a));
2275+
2276+
assert!(a.is_disjoint(&b))
2277+
assert!(a.is_disjoint(&c))
2278+
assert!(b.is_disjoint(&a))
2279+
assert!(b.is_disjoint(&c))
2280+
assert!(c.is_disjoint(&a))
2281+
assert!(c.is_disjoint(&b))
2282+
}
2283+
2284+
#[test]
2285+
fn test_bitv_set_intersect_with() {
2286+
// Explicitly 0'ed bits
2287+
let mut a = BitvSet::from_bitv(from_bytes([0b10100010]));
2288+
let mut b = BitvSet::from_bitv(from_bytes([0b00000000]));
2289+
let c = a.clone();
2290+
a.intersect_with(&b);
2291+
b.intersect_with(&c);
2292+
assert!(a.is_empty());
2293+
assert!(b.is_empty());
2294+
2295+
// Uninitialized bits should behave like 0's
2296+
let mut a = BitvSet::from_bitv(from_bytes([0b10100010]));
2297+
let mut b = BitvSet::new();
2298+
let c = a.clone();
2299+
a.intersect_with(&b);
2300+
b.intersect_with(&c);
2301+
assert!(a.is_empty());
2302+
assert!(b.is_empty());
2303+
2304+
// Standard
2305+
let mut a = BitvSet::from_bitv(from_bytes([0b10100010]));
2306+
let mut b = BitvSet::from_bitv(from_bytes([0b01100010]));
2307+
let c = a.clone();
2308+
a.intersect_with(&b);
2309+
b.intersect_with(&c);
2310+
assert_eq!(a.len(), 2);
2311+
assert_eq!(b.len(), 2);
2312+
}
2313+
2314+
#[test]
2315+
fn test_bitv_set_eq() {
2316+
let a = BitvSet::from_bitv(from_bytes([0b10100010]));
2317+
let b = BitvSet::from_bitv(from_bytes([0b00000000]));
2318+
let c = BitvSet::new();
2319+
2320+
assert!(a == a);
2321+
assert!(a != b);
2322+
assert!(a != c);
2323+
assert!(b == b);
2324+
assert!(b == c);
2325+
assert!(c == c);
2326+
}
2327+
2328+
#[test]
2329+
fn test_bitv_set_cmp() {
2330+
let a = BitvSet::from_bitv(from_bytes([0b10100010]));
2331+
let b = BitvSet::from_bitv(from_bytes([0b00000000]));
2332+
let c = BitvSet::new();
2333+
2334+
assert_eq!(a.cmp(&b), Greater);
2335+
assert_eq!(a.cmp(&c), Greater);
2336+
assert_eq!(b.cmp(&a), Less);
2337+
assert_eq!(b.cmp(&c), Equal);
2338+
assert_eq!(c.cmp(&a), Less);
2339+
assert_eq!(c.cmp(&b), Equal);
2340+
}
2341+
22162342
#[test]
22172343
fn test_bitv_remove() {
22182344
let mut a = BitvSet::new();

branches/try/src/libcollections/hash/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ use core::mem;
7373
use vec::Vec;
7474

7575
/// Reexport the `sip::hash` function as our default hasher.
76-
pub use hash = self::sip::hash;
76+
pub use self::sip::hash as hash;
7777

7878
pub mod sip;
7979

branches/try/src/libcollections/str.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,6 @@ the string is valid for the `'static` lifetime, otherwise known as the
4444
lifetime of the entire program. As can be inferred from the type, these static
4545
strings are not mutable.
4646
47-
# Mutability
48-
49-
Many languages have immutable strings by default, and Rust has a particular
50-
flavor on this idea. As with the rest of Rust types, strings are immutable by
51-
default. If a string is declared as `mut`, however, it may be mutated. This
52-
works the same way as the rest of Rust's type system in the sense that if
53-
there's a mutable reference to a string, there may only be one mutable reference
54-
to that string. With these guarantees, strings can easily transition between
55-
being mutable/immutable with the same benefits of having mutable strings in
56-
other languages.
57-
5847
# Representation
5948
6049
Rust's string type, `str`, is a sequence of unicode scalar values encoded as a

branches/try/src/libcollections/string.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ use core::fmt;
1919
use core::mem;
2020
use core::ptr;
2121
// FIXME: ICE's abound if you import the `Slice` type while importing `Slice` trait
22-
use RawSlice = core::raw::Slice;
22+
use core::raw::Slice as RawSlice;
2323

2424
use {Mutable, MutableSeq};
2525
use hash;
2626
use str;
2727
use str::{CharRange, StrAllocating, MaybeOwned, Owned};
28-
use MaybeOwnedSlice = str::Slice; // So many `Slice`s...
28+
use str::Slice as MaybeOwnedSlice; // So many `Slice`s...
2929
use vec::Vec;
3030

3131
/// A growable string stored as a UTF-8 encoded buffer.

branches/try/src/libcollections/vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
use core::prelude::*;
1414

1515
use alloc::heap::{allocate, reallocate, deallocate};
16-
use RawSlice = core::raw::Slice;
1716
use core::cmp::max;
1817
use core::default::Default;
1918
use core::fmt;
2019
use core::mem;
2120
use core::num;
2221
use core::ptr;
22+
use core::raw::Slice as RawSlice;
2323
use core::uint;
2424

2525
use {Mutable, MutableSeq};

branches/try/src/libcore/kinds.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ by the compiler automatically for the types to which they apply.
2121
*/
2222

2323
#[deprecated = "This has been renamed to Sync"]
24-
pub use Share = self::Sync;
24+
pub use self::Sync as Share;
2525

2626
/// Types able to be transferred across task boundaries.
2727
#[lang="send"]

branches/try/src/libcore/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub mod collections;
107107
/// Deprecated module in favor of `std::cell`
108108
pub mod ty {
109109
#[deprecated = "this type has been renamed to `UnsafeCell`"]
110-
pub use Unsafe = cell::UnsafeCell;
110+
pub use cell::UnsafeCell as Unsafe;
111111
}
112112

113113
/* Core types and methods on primitives */

branches/try/src/libcore/num/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,17 +1345,19 @@ checked_impl!(CheckedMul, checked_mul, i16, intrinsics::i16_mul_with_overflow)
13451345
checked_impl!(CheckedMul, checked_mul, i32, intrinsics::i32_mul_with_overflow)
13461346
checked_impl!(CheckedMul, checked_mul, i64, intrinsics::i64_mul_with_overflow)
13471347

1348-
/// Performs division that returns `None` instead of wrapping around on underflow or overflow.
1348+
/// Performs division that returns `None` instead of failing on division by zero and instead of
1349+
/// wrapping around on underflow and overflow.
13491350
pub trait CheckedDiv: Div<Self, Self> {
1350-
/// Divides two numbers, checking for underflow or overflow. If underflow or overflow happens,
1351-
/// `None` is returned.
1351+
/// Divides two numbers, checking for underflow, overflow and division by zero. If any of that
1352+
/// happens, / `None` is returned.
13521353
///
13531354
/// # Example
13541355
///
13551356
/// ```rust
13561357
/// use std::num::CheckedDiv;
13571358
/// assert_eq!((-127i8).checked_div(&-1), Some(127));
13581359
/// assert_eq!((-128i8).checked_div(&-1), None);
1360+
/// assert_eq!((1i8).checked_div(&0), None);
13591361
/// ```
13601362
fn checked_div(&self, v: &Self) -> Option<Self>;
13611363
}

branches/try/src/libcore/option.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl<T> Option<T> {
244244
}
245245
}
246246

247-
/// Moves a value out of an option type and returns it, consuming the `Option`.
247+
/// Returns the inner `T` of a `Some(T)`.
248248
///
249249
/// # Failure
250250
///

branches/try/src/libcore/slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use mem::size_of;
5050
use kinds::marker;
5151
use raw::Repr;
5252
// Avoid conflicts with *both* the Slice trait (buggy) and the `slice::raw` module.
53-
use RawSlice = raw::Slice;
53+
use raw::Slice as RawSlice;
5454

5555

5656
//

0 commit comments

Comments
 (0)