Skip to content

Commit 7ff16de

Browse files
committed
---
yaml --- r: 128931 b: refs/heads/try c: 96f5eba h: refs/heads/master i: 128929: 14888da 128927: 7e009a5 v: v3
1 parent 96e017a commit 7ff16de

Some content is hidden

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

71 files changed

+196
-281
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: ef0d49d78f91d6e517af2e37ed89a3e3587b9f83
5+
refs/heads/try: 96f5eba4f5603c612464d6b1e961677e9d7084d3
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: 8 additions & 15 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 compile `hello_world`.
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)
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 curly braces, Rust will attempt to display the
535+
When you just use the double 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,16 +1888,8 @@ 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.
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`:
1891+
named `secret_number`, and we printed out its result. Let's try to compile
1892+
this using `cargo build`:
19011893

19021894
```{notrust,no_run}
19031895
$ cargo build
@@ -3677,9 +3669,10 @@ manually free this allocation! If we write
36773669
```
36783670

36793671
then Rust will automatically free `x` at the end of the block. This isn't
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:
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:
36833676

36843677
```{c,ignore}
36853678
{

branches/try/src/doc/rust.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,6 @@ 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-
176172
Non-doc comments are interpreted as a form of whitespace.
177173

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

18071803
~~~~
1808-
pub use self::implementation as api;
1804+
pub use api = self::implementation;
18091805
18101806
mod implementation {
18111807
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 farm::chicken as egg_layer;
3115+
use egg_layer = farm::chicken;
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 std::iter::range as iter_range;
3338+
use iter_range = std::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 boxed as owned;
89+
pub use owned = boxed;
9090

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

branches/try/src/libcollections/bitv.rs

Lines changed: 26 additions & 41 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::{Chain, Enumerate, Repeat, Skip, Take};
69+
use core::iter::Take;
7070
use core::iter;
7171
use core::slice;
7272
use core::uint;
@@ -75,22 +75,25 @@ 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>>>>>;
7978
// Take two BitV's, and return iterators of their words, where the shorter one
8079
// 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-
}
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+
)
9497

9598
static TRUE: bool = true;
9699
static FALSE: bool = false;
@@ -1011,23 +1014,23 @@ impl Extendable<bool> for BitvSet {
10111014
impl PartialOrd for BitvSet {
10121015
#[inline]
10131016
fn partial_cmp(&self, other: &BitvSet) -> Option<Ordering> {
1014-
let (a_iter, b_iter) = match_words(self.get_ref(), other.get_ref());
1017+
let (a_iter, b_iter) = match_words!(self.get_ref(), other.get_ref());
10151018
iter::order::partial_cmp(a_iter, b_iter)
10161019
}
10171020
}
10181021

10191022
impl Ord for BitvSet {
10201023
#[inline]
10211024
fn cmp(&self, other: &BitvSet) -> Ordering {
1022-
let (a_iter, b_iter) = match_words(self.get_ref(), other.get_ref());
1025+
let (a_iter, b_iter) = match_words!(self.get_ref(), other.get_ref());
10231026
iter::order::cmp(a_iter, b_iter)
10241027
}
10251028
}
10261029

10271030
impl cmp::PartialEq for BitvSet {
10281031
#[inline]
10291032
fn eq(&self, other: &BitvSet) -> bool {
1030-
let (a_iter, b_iter) = match_words(self.get_ref(), other.get_ref());
1033+
let (a_iter, b_iter) = match_words!(self.get_ref(), other.get_ref());
10311034
iter::order::eq(a_iter, b_iter)
10321035
}
10331036
}
@@ -1188,10 +1191,10 @@ impl BitvSet {
11881191
self_bitv.reserve(other_bitv.capacity());
11891192

11901193
// 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-
};
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));
11951198

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

15221525
#[inline]
15231526
fn is_disjoint(&self, other: &BitvSet) -> bool {
1524-
self.intersection(other).next().is_none()
1527+
self.intersection(other).count() > 0
15251528
}
15261529

15271530
#[inline]
@@ -2263,24 +2266,6 @@ mod tests {
22632266
assert!(set1.is_subset(&set2)); // { 2 } { 2, 4 }
22642267
}
22652268

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-
22842269
#[test]
22852270
fn test_bitv_set_intersect_with() {
22862271
// 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 self::sip::hash as hash;
76+
pub use hash = self::sip::hash;
7777

7878
pub mod sip;
7979

branches/try/src/libcollections/str.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ 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+
4758
# Representation
4859
4960
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 core::raw::Slice as RawSlice;
22+
use RawSlice = core::raw::Slice;
2323

2424
use {Mutable, MutableSeq};
2525
use hash;
2626
use str;
2727
use str::{CharRange, StrAllocating, MaybeOwned, Owned};
28-
use str::Slice as MaybeOwnedSlice; // So many `Slice`s...
28+
use MaybeOwnedSlice = str::Slice; // 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;
1617
use core::cmp::max;
1718
use core::default::Default;
1819
use core::fmt;
1920
use core::mem;
2021
use core::num;
2122
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 self::Sync as Share;
24+
pub use Share = self::Sync;
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 cell::UnsafeCell as Unsafe;
110+
pub use Unsafe = cell::UnsafeCell;
111111
}
112112

113113
/* Core types and methods on primitives */

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,19 +1345,17 @@ 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 failing on division by zero and instead of
1349-
/// wrapping around on underflow and overflow.
1348+
/// Performs division that returns `None` instead of wrapping around on underflow or overflow.
13501349
pub trait CheckedDiv: Div<Self, Self> {
1351-
/// Divides two numbers, checking for underflow, overflow and division by zero. If any of that
1352-
/// happens, / `None` is returned.
1350+
/// Divides two numbers, checking for underflow or overflow. If underflow or overflow happens,
1351+
/// `None` is returned.
13531352
///
13541353
/// # Example
13551354
///
13561355
/// ```rust
13571356
/// use std::num::CheckedDiv;
13581357
/// assert_eq!((-127i8).checked_div(&-1), Some(127));
13591358
/// assert_eq!((-128i8).checked_div(&-1), None);
1360-
/// assert_eq!((1i8).checked_div(&0), None);
13611359
/// ```
13621360
fn checked_div(&self, v: &Self) -> Option<Self>;
13631361
}

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-
/// Returns the inner `T` of a `Some(T)`.
247+
/// Moves a value out of an option type and returns it, consuming the `Option`.
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 raw::Slice as RawSlice;
53+
use RawSlice = raw::Slice;
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 graphviz as dot;
50+
use dot = graphviz;
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 graphviz as dot;
150+
use dot = graphviz;
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 graphviz as dot;
206+
use dot = graphviz;
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 std::sync::mpsc_queue as mpsc;
12+
use mpsc = std::sync::mpsc_queue;
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 message_queue as msgq;
28+
use msgq = message_queue;
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)