Skip to content

Commit bb6d5cc

Browse files
committed
---
yaml --- r: 128932 b: refs/heads/try c: c883510 h: refs/heads/master v: v3
1 parent 7ff16de commit bb6d5cc

Some content is hidden

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

70 files changed

+280
-188
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: 96f5eba4f5603c612464d6b1e961677e9d7084d3
5+
refs/heads/try: c8835104797335818bc1d5b0df61ce9f5907cd16
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/doc/guide.md

Lines changed: 15 additions & 8 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:
@@ -1888,8 +1888,16 @@ fn main() {
18881888

18891889
The first thing we changed was to `use std::rand`, as the docs
18901890
explained. We then added in a `let` expression to create a variable binding
1891-
named `secret_number`, and we printed out its result. Let's try to compile
1892-
this using `cargo build`:
1891+
named `secret_number`, and we printed out its result.
1892+
1893+
Also, you may wonder why we are using `%` on the result of `rand::random()`.
1894+
This operator is called 'modulo', and it returns the remainder of a division.
1895+
By taking the modulo of the result of `rand::random()`, we're limiting the
1896+
values to be between 0 and 99. Then, we add one to the result, making it from 1
1897+
to 100. Using modulo can give you a very, very small bias in the result, but
1898+
for this example, it is not important.
1899+
1900+
Let's try to compile this using `cargo build`:
18931901

18941902
```{notrust,no_run}
18951903
$ cargo build
@@ -3669,10 +3677,9 @@ manually free this allocation! If we write
36693677
```
36703678

36713679
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:
3680+
because Rust has a garbage collector -- it doesn't. Instead, when `x` goes out
3681+
of scope, Rust `free`s `x`. This Rust code will do the same thing as the
3682+
following C code:
36763683

36773684
```{c,ignore}
36783685
{

branches/try/src/doc/rust.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ sequence (`/**`), are interpreted as a special syntax for `doc`
169169
`#[doc="..."]` around the body of the comment (this includes the comment
170170
characters themselves, ie `/// Foo` turns into `#[doc="/// Foo"]`).
171171

172+
`//!` comments apply to the parent of the comment, rather than the item that
173+
follows. `//!` comments are usually used to display information on the crate
174+
index page.
175+
172176
Non-doc comments are interpreted as a form of whitespace.
173177

174178
## Whitespace
@@ -1801,7 +1805,7 @@ module through the rules above. It essentially allows public access into the
18011805
re-exported item. For example, this program is valid:
18021806

18031807
~~~~
1804-
pub use api = self::implementation;
1808+
pub use self::implementation as api;
18051809
18061810
mod implementation {
18071811
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: 41 additions & 26 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,25 +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>>>>>;
7879
// Take two BitV's, and return iterators of their words, where the shorter one
7980
// has been padded with 0's
80-
macro_rules! match_words(
81-
($a_expr:expr, $b_expr:expr) => ({
82-
let a = $a_expr;
83-
let b = $b_expr;
84-
let a_len = a.storage.len();
85-
let b_len = b.storage.len();
86-
87-
// have to uselessly pretend to pad the longer one for type matching
88-
if a_len < b_len {
89-
(a.mask_words(0).chain(iter::Repeat::new(0u).enumerate().take(b_len).skip(a_len)),
90-
b.mask_words(0).chain(iter::Repeat::new(0u).enumerate().take(0).skip(0)))
91-
} else {
92-
(a.mask_words(0).chain(iter::Repeat::new(0u).enumerate().take(0).skip(0)),
93-
b.mask_words(0).chain(iter::Repeat::new(0u).enumerate().take(a_len).skip(b_len)))
94-
}
95-
})
96-
)
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+
}
9794

9895
static TRUE: bool = true;
9996
static FALSE: bool = false;
@@ -1014,23 +1011,23 @@ impl Extendable<bool> for BitvSet {
10141011
impl PartialOrd for BitvSet {
10151012
#[inline]
10161013
fn partial_cmp(&self, other: &BitvSet) -> Option<Ordering> {
1017-
let (a_iter, b_iter) = match_words!(self.get_ref(), other.get_ref());
1014+
let (a_iter, b_iter) = match_words(self.get_ref(), other.get_ref());
10181015
iter::order::partial_cmp(a_iter, b_iter)
10191016
}
10201017
}
10211018

10221019
impl Ord for BitvSet {
10231020
#[inline]
10241021
fn cmp(&self, other: &BitvSet) -> Ordering {
1025-
let (a_iter, b_iter) = match_words!(self.get_ref(), other.get_ref());
1022+
let (a_iter, b_iter) = match_words(self.get_ref(), other.get_ref());
10261023
iter::order::cmp(a_iter, b_iter)
10271024
}
10281025
}
10291026

10301027
impl cmp::PartialEq for BitvSet {
10311028
#[inline]
10321029
fn eq(&self, other: &BitvSet) -> bool {
1033-
let (a_iter, b_iter) = match_words!(self.get_ref(), other.get_ref());
1030+
let (a_iter, b_iter) = match_words(self.get_ref(), other.get_ref());
10341031
iter::order::eq(a_iter, b_iter)
10351032
}
10361033
}
@@ -1191,10 +1188,10 @@ impl BitvSet {
11911188
self_bitv.reserve(other_bitv.capacity());
11921189

11931190
// virtually pad other with 0's for equal lengths
1194-
let self_len = self_bitv.storage.len();
1195-
let other_len = other_bitv.storage.len();
1196-
let mut other_words = other_bitv.mask_words(0)
1197-
.chain(iter::Repeat::new(0u).enumerate().take(self_len).skip(other_len));
1191+
let mut other_words = {
1192+
let (_, result) = match_words(self_bitv, other_bitv);
1193+
result
1194+
};
11981195

11991196
// Apply values found in other
12001197
for (i, w) in other_words {
@@ -1524,7 +1521,7 @@ impl Set<uint> for BitvSet {
15241521

15251522
#[inline]
15261523
fn is_disjoint(&self, other: &BitvSet) -> bool {
1527-
self.intersection(other).count() > 0
1524+
self.intersection(other).next().is_none()
15281525
}
15291526

15301527
#[inline]
@@ -2266,6 +2263,24 @@ mod tests {
22662263
assert!(set1.is_subset(&set2)); // { 2 } { 2, 4 }
22672264
}
22682265

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+
22692284
#[test]
22702285
fn test_bitv_set_intersect_with() {
22712286
// Explicitly 0'ed bits

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
//

branches/try/src/libgraphviz/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ forming a diamond-shaped acyclic graph and then pointing to the fifth
4747
which is cyclic.
4848
4949
```rust
50-
use dot = graphviz;
50+
use graphviz as dot;
5151
use graphviz::maybe_owned_vec::IntoMaybeOwnedVector;
5252
5353
type Nd = int;
@@ -147,7 +147,7 @@ labelled with the &sube; character (specified using the HTML character
147147
entity `&sube`).
148148
149149
```rust
150-
use dot = graphviz;
150+
use graphviz as dot;
151151
use std::str;
152152
153153
type Nd = uint;
@@ -203,7 +203,7 @@ The output from this example is the same as the second example: the
203203
Hasse-diagram for the subsets of the set `{x, y}`.
204204
205205
```rust
206-
use dot = graphviz;
206+
use graphviz as dot;
207207
use std::str;
208208
209209
type Nd<'a> = (uint, &'a str);

branches/try/src/libgreen/message_queue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use alloc::arc::Arc;
12-
use mpsc = std::sync::mpsc_queue;
12+
use std::sync::mpsc_queue as mpsc;
1313
use std::kinds::marker;
1414

1515
pub enum PopResult<T> {

branches/try/src/libgreen/sched.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use coroutine::Coroutine;
2525
use sleeper_list::SleeperList;
2626
use stack::StackPool;
2727
use task::{TypeSched, GreenTask, HomeSched, AnySched};
28-
use msgq = message_queue;
28+
use message_queue as msgq;
2929

3030
/// A scheduler is responsible for coordinating the execution of Tasks
3131
/// on a single thread. The scheduler runs inside a slightly modified

0 commit comments

Comments
 (0)