Skip to content

Commit 5760d63

Browse files
committed
---
yaml --- r: 276949 b: refs/heads/try c: 7979dd6 h: refs/heads/master i: 276947: c649f38
1 parent 3a1adb1 commit 5760d63

File tree

242 files changed

+1791
-1243
lines changed

Some content is hidden

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

242 files changed

+1791
-1243
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 6dbb0e86aec11050480beb76eade6fb805010ba7
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4-
refs/heads/try: 9eaae920117594f5bddab1f46f406e5402e8cc8a
4+
refs/heads/try: 7979dd6089ee5cba39cfbe6e880a3edeb7fff788
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/doc/book/closures.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,14 +371,13 @@ assert_eq!(6, answer);
371371
This gives us these long, related errors:
372372

373373
```text
374-
error: the trait `core::marker::Sized` is not implemented for the type
375-
`core::ops::Fn(i32) -> i32` [E0277]
374+
error: the trait bound `core::ops::Fn(i32) -> i32 : core::marker::Sized` is not satisfied [E0277]
376375
fn factory() -> (Fn(i32) -> i32) {
377376
^~~~~~~~~~~~~~~~
378377
note: `core::ops::Fn(i32) -> i32` does not have a constant size known at compile-time
379378
fn factory() -> (Fn(i32) -> i32) {
380379
^~~~~~~~~~~~~~~~
381-
error: the trait `core::marker::Sized` is not implemented for the type `core::ops::Fn(i32) -> i32` [E0277]
380+
error: the trait bound `core::ops::Fn(i32) -> i32 : core::marker::Sized` is not satisfied [E0277]
382381
let f = factory();
383382
^
384383
note: `core::ops::Fn(i32) -> i32` does not have a constant size known at compile-time

branches/try/src/doc/book/concurrency.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@ thread may outlive the scope of `x`, leading to a dangling pointer.
127127

128128
To fix this, we use a `move` closure as mentioned in the error message. `move`
129129
closures are explained in depth [here](closures.html#move-closures); basically
130-
they move variables from their environment into themselves. This means that `x`
131-
is now owned by the closure, and cannot be used in `main()` after the call to
132-
`spawn()`.
130+
they move variables from their environment into themselves.
133131

134132
```rust
135133
use std::thread;
@@ -164,7 +162,7 @@ The same [ownership system](ownership.html) that helps prevent using pointers
164162
incorrectly also helps rule out data races, one of the worst kinds of
165163
concurrency bugs.
166164

167-
As an example, here is a Rust program that would have a data race in many
165+
As an example, here is a Rust program that could have a data race in many
168166
languages. It will not compile:
169167

170168
```ignore
@@ -197,6 +195,11 @@ thread, and the thread takes ownership of the reference, we'd have three owners!
197195
`data` gets moved out of `main` in the first call to `spawn()`, so subsequent
198196
calls in the loop cannot use this variable.
199197

198+
Note that this specific example will not cause a data race since different array
199+
indices are being accessed. But this can't be determined at compile time, and in
200+
a similar situation where `i` is a constant or is random, you would have a data
201+
race.
202+
200203
So, we need some type that lets us have more than one owning reference to a
201204
value. Usually, we'd use `Rc<T>` for this, which is a reference counted type
202205
that provides shared ownership. It has some runtime bookkeeping that keeps track
@@ -231,8 +234,8 @@ fn main() {
231234
This won't work, however, and will give us the error:
232235

233236
```text
234-
13:9: 13:22 error: the trait `core::marker::Send` is not
235-
implemented for the type `alloc::rc::Rc<collections::vec::Vec<i32>>`
237+
13:9: 13:22 error: the trait bound `alloc::rc::Rc<collections::vec::Vec<i32>> : core::marker::Send`
238+
is not satisfied
236239
...
237240
13:9: 13:22 note: `alloc::rc::Rc<collections::vec::Vec<i32>>`
238241
cannot be sent between threads safely

branches/try/src/doc/book/crates-and-modules.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ build deps examples libphrases-a7448e02a0468eaa.rlib native
118118
`libphrases-hash.rlib` is the compiled crate. Before we see how to use this
119119
crate from another crate, let’s break it up into multiple files.
120120

121-
# Multiple file crates
121+
# Multiple File Crates
122122

123123
If each crate were just one file, these files would get very large. It’s often
124124
easier to split up crates into multiple files, and Rust supports this in two
@@ -190,13 +190,19 @@ mod farewells;
190190
```
191191

192192
Again, these declarations tell Rust to look for either
193-
`src/english/greetings.rs` and `src/japanese/greetings.rs` or
194-
`src/english/farewells/mod.rs` and `src/japanese/farewells/mod.rs`. Because
195-
these sub-modules don’t have their own sub-modules, we’ve chosen to make them
196-
`src/english/greetings.rs` and `src/japanese/farewells.rs`. Whew!
197-
198-
The contents of `src/english/greetings.rs` and `src/japanese/farewells.rs` are
199-
both empty at the moment. Let’s add some functions.
193+
`src/english/greetings.rs`, `src/english/farewells.rs`,
194+
`src/japanese/greetings.rs` and `src/japanese/farewells.rs` or
195+
`src/english/greetings/mod.rs`, `src/english/farewells/mod.rs`,
196+
`src/japanese/greetings/mod.rs` and
197+
`src/japanese/farewells/mod.rs`. Because these sub-modules don’t have
198+
their own sub-modules, we’ve chosen to make them
199+
`src/english/greetings.rs`, `src/english/farewells.rs`,
200+
`src/japanese/greetings.rs` and `src/japanese/farewells.rs`. Whew!
201+
202+
The contents of `src/english/greetings.rs`,
203+
`src/english/farewells.rs`, `src/japanese/greetings.rs` and
204+
`src/japanese/farewells.rs` are all empty at the moment. Let’s add
205+
some functions.
200206

201207
Put this in `src/english/greetings.rs`:
202208

branches/try/src/doc/book/lifetimes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ To fix this, we have to make sure that step four never happens after step
5656
three. The ownership system in Rust does this through a concept called
5757
lifetimes, which describe the scope that a reference is valid for.
5858

59-
When we have a function that takes a reference by argument, we can be implicit
60-
or explicit about the lifetime of the reference:
59+
When we have a function that takes an argument by reference, we can be
60+
implicit or explicit about the lifetime of the reference:
6161

6262
```rust
6363
// implicit

branches/try/src/doc/book/traits.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ print_area(5);
154154
We get a compile-time error:
155155

156156
```text
157-
error: the trait `HasArea` is not implemented for the type `_` [E0277]
157+
error: the trait bound `_ : HasArea` is not satisfied [E0277]
158158
```
159159

160160
## Trait bounds on generic structs
@@ -496,7 +496,7 @@ impl FooBar for Baz {
496496
If we forget to implement `Foo`, Rust will tell us:
497497

498498
```text
499-
error: the trait `main::Foo` is not implemented for the type `main::Baz` [E0277]
499+
error: the trait bound `main::Baz : main::Foo` is not satisfied [E0277]
500500
```
501501

502502
# Deriving

branches/try/src/doc/book/vectors.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ v[j];
5656
Indexing with a non-`usize` type gives an error that looks like this:
5757

5858
```text
59-
error: the trait `core::ops::Index<i32>` is not implemented for the type
60-
`collections::vec::Vec<_>` [E0277]
59+
error: the trait bound `collections::vec::Vec<_> : core::ops::Index<i32>`
60+
is not satisfied [E0277]
6161
v[j];
6262
^~~~
6363
note: the type `collections::vec::Vec<_>` cannot be indexed by `i32`

branches/try/src/doc/nomicon/coercions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn main() {
6464
```
6565

6666
```text
67-
<anon>:10:5: 10:8 error: the trait `Trait` is not implemented for the type `&mut i32` [E0277]
67+
<anon>:10:5: 10:8 error: the trait bound `&mut i32 : Trait` is not satisfied [E0277]
6868
<anon>:10 foo(t);
6969
^~~
7070
```

branches/try/src/liballoc/arc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ impl<T: ?Sized> Arc<T> {
263263
loop {
264264
// check if the weak counter is currently "locked"; if so, spin.
265265
if cur == usize::MAX {
266+
cur = this.inner().weak.load(Relaxed);
266267
continue;
267268
}
268269

branches/try/src/libcollections/borrow.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ pub trait ToOwned {
4949
type Owned: Borrow<Self>;
5050

5151
/// Creates owned data from borrowed data, usually by cloning.
52+
///
53+
/// # Examples
54+
///
55+
/// Basic usage:
56+
///
57+
/// ```
58+
/// let s = "a"; // &str
59+
/// let ss = s.to_owned(); // String
60+
///
61+
/// let v = &[1, 2]; // slice
62+
/// let vv = v.to_owned(); // Vec
63+
/// ```
5264
#[stable(feature = "rust1", since = "1.0.0")]
5365
fn to_owned(&self) -> Self::Owned;
5466
}

branches/try/src/libcollectionstest/slice.rs

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -574,18 +574,48 @@ fn test_slice_2() {
574574
assert_eq!(v[1], 3);
575575
}
576576

577+
macro_rules! assert_order {
578+
(Greater, $a:expr, $b:expr) => {
579+
assert_eq!($a.cmp($b), Greater);
580+
assert!($a > $b);
581+
};
582+
(Less, $a:expr, $b:expr) => {
583+
assert_eq!($a.cmp($b), Less);
584+
assert!($a < $b);
585+
};
586+
(Equal, $a:expr, $b:expr) => {
587+
assert_eq!($a.cmp($b), Equal);
588+
assert_eq!($a, $b);
589+
}
590+
}
591+
592+
#[test]
593+
fn test_total_ord_u8() {
594+
let c = &[1u8, 2, 3];
595+
assert_order!(Greater, &[1u8, 2, 3, 4][..], &c[..]);
596+
let c = &[1u8, 2, 3, 4];
597+
assert_order!(Less, &[1u8, 2, 3][..], &c[..]);
598+
let c = &[1u8, 2, 3, 6];
599+
assert_order!(Equal, &[1u8, 2, 3, 6][..], &c[..]);
600+
let c = &[1u8, 2, 3, 4, 5, 6];
601+
assert_order!(Less, &[1u8, 2, 3, 4, 5, 5, 5, 5][..], &c[..]);
602+
let c = &[1u8, 2, 3, 4];
603+
assert_order!(Greater, &[2u8, 2][..], &c[..]);
604+
}
605+
606+
577607
#[test]
578-
fn test_total_ord() {
608+
fn test_total_ord_i32() {
579609
let c = &[1, 2, 3];
580-
[1, 2, 3, 4][..].cmp(c) == Greater;
610+
assert_order!(Greater, &[1, 2, 3, 4][..], &c[..]);
581611
let c = &[1, 2, 3, 4];
582-
[1, 2, 3][..].cmp(c) == Less;
612+
assert_order!(Less, &[1, 2, 3][..], &c[..]);
583613
let c = &[1, 2, 3, 6];
584-
[1, 2, 3, 4][..].cmp(c) == Equal;
614+
assert_order!(Equal, &[1, 2, 3, 6][..], &c[..]);
585615
let c = &[1, 2, 3, 4, 5, 6];
586-
[1, 2, 3, 4, 5, 5, 5, 5][..].cmp(c) == Less;
616+
assert_order!(Less, &[1, 2, 3, 4, 5, 5, 5, 5][..], &c[..]);
587617
let c = &[1, 2, 3, 4];
588-
[2, 2][..].cmp(c) == Greater;
618+
assert_order!(Greater, &[2, 2][..], &c[..]);
589619
}
590620

591621
#[test]

branches/try/src/libcore/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
#![feature(unwind_attributes)]
7676
#![feature(repr_simd, platform_intrinsics)]
7777
#![feature(rustc_attrs)]
78+
#![feature(specialization)]
7879
#![feature(staged_api)]
7980
#![feature(unboxed_closures)]
8081
#![feature(question_mark)]

branches/try/src/libcore/ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl<T: ?Sized> *const T {
220220
/// ```
221221
/// let s: &str = "Follow the rabbit";
222222
/// let ptr: *const u8 = s.as_ptr();
223-
/// assert!(ptr.is_null() == false);
223+
/// assert!(!ptr.is_null());
224224
/// ```
225225
#[stable(feature = "rust1", since = "1.0.0")]
226226
#[inline]
@@ -306,7 +306,7 @@ impl<T: ?Sized> *mut T {
306306
/// ```
307307
/// let mut s = [1, 2, 3];
308308
/// let ptr: *mut u32 = s.as_mut_ptr();
309-
/// assert!(ptr.is_null() == false);
309+
/// assert!(!ptr.is_null());
310310
/// ```
311311
#[stable(feature = "rust1", since = "1.0.0")]
312312
#[inline]

0 commit comments

Comments
 (0)