Skip to content

Commit 0486e12

Browse files
committed
Auto merge of #31148 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #30997, #31019, #31031, #31035, #31045, #31050, #31054, #31055, #31061, #31088, #31090, #31111, #31113, #31128, #31130, #31136, #31145, #31146 - Failed merges: #30932
2 parents b78b9ae + feb2673 commit 0486e12

File tree

19 files changed

+161
-37
lines changed

19 files changed

+161
-37
lines changed

src/doc/book/bibliography.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,4 @@ Language](http://www.cs.indiana.edu/~eholk/papers/hips2013.pdf). Early GPU work
8080
Rust](http://munksgaard.me/papers/laumann-munksgaard-larsen.pdf). Philip
8181
Munksgaard's master's thesis. Research for Servo.
8282
* [Ownership is Theft: Experiences Building an Embedded OS in Rust - Amit Levy, et. al.](http://amitlevy.com/papers/tock-plos2015.pdf)
83+
* [You can't spell trust without Rust](https://raw.githubusercontent.com/Gankro/thesis/master/thesis.pdf). Alexis Beingessner's master's thesis.

src/doc/book/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ If we're on Linux or a Mac, all we need to do is open a terminal and type this:
111111
$ curl -sSf https://static.rust-lang.org/rustup.sh | sh
112112
```
113113

114-
This will download a script, and stat the installation. If it all goes well,
114+
This will download a script, and start the installation. If it all goes well,
115115
you’ll see this appear:
116116

117117
```text

src/doc/book/guessing-game.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,7 @@ let guess: u32 = match guess.trim().parse() {
908908
```
909909
910910
This is how you generally move from ‘crash on error’ to ‘actually handle the
911+
error’, by switching from `expect()` to a `match` statement. The `Result`
911912
returned by `parse()` is an `enum` like `Ordering`, but in this case, each
912913
variant has some data associated with it: `Ok` is a success, and `Err` is a
913914
failure. Each contains more information: the successfully parsed integer, or an

src/doc/book/no-stdlib.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ The compiler currently makes a few assumptions about symbols which are available
7777
in the executable to call. Normally these functions are provided by the standard
7878
library, but without it you must define your own.
7979

80-
The first of these two functions, `eh_personality`, is used by the
81-
failure mechanisms of the compiler. This is often mapped to GCC's
82-
personality function (see the
83-
[libstd implementation](../std/rt/unwind/index.html) for more
84-
information), but crates which do not trigger a panic can be assured
85-
that this function is never called. The second function, `panic_fmt`, is
86-
also used by the failure mechanisms of the compiler.
80+
The first of these two functions, `eh_personality`, is used by the failure
81+
mechanisms of the compiler. This is often mapped to GCC's personality function
82+
(see the [libstd implementation][unwind] for more information), but crates
83+
which do not trigger a panic can be assured that this function is never
84+
called. The second function, `panic_fmt`, is also used by the failure
85+
mechanisms of the compiler.
86+
87+
[unwind]: https://github.com/rust-lang/rust/blob/master/src/libstd/sys/common/unwind/gcc.rs

src/doc/book/traits.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,16 +277,22 @@ This will compile without error.
277277
This means that even if someone does something bad like add methods to `i32`,
278278
it won’t affect you, unless you `use` that trait.
279279

280-
There’s one more restriction on implementing traits: either the trait, or the
281-
type you’re writing the `impl` for, must be defined by you. So, we could
282-
implement the `HasArea` type for `i32`, because `HasArea` is in our code. But
283-
if we tried to implement `ToString`, a trait provided by Rust, for `i32`, we could
284-
not, because neither the trait nor the type are in our code.
280+
There’s one more restriction on implementing traits: either the trait
281+
or the type you’re implementing it for must be defined by you. Or more
282+
precisely, one of them must be defined in the same crate as the `impl`
283+
you're writing. For more on Rust's module and package system, see the
284+
chapter on [crates and modules][cm].
285+
286+
So, we could implement the `HasArea` type for `i32`, because we defined
287+
`HasArea` in our code. But if we tried to implement `ToString`, a trait
288+
provided by Rust, for `i32`, we could not, because neither the trait nor
289+
the type are defined in our crate.
285290

286291
One last thing about traits: generic functions with a trait bound use
287292
‘monomorphization’ (mono: one, morph: form), so they are statically dispatched.
288293
What’s that mean? Check out the chapter on [trait objects][to] for more details.
289294

295+
[cm]: crates-and-modules.html
290296
[to]: trait-objects.html
291297

292298
# Multiple trait bounds

src/doc/version_info.html.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div id="versioninfo">
2-
<img src="https://www.rust-lang.org/logos/rust-logo-32x32-blk.png" width="32" height="32" alt><br>
2+
<img src="https://www.rust-lang.org/logos/rust-logo-32x32-blk.png" width="32" height="32" alt="Rust logo"><br>
33
<span class="white-sticker"><a href="https://www.rust-lang.org">Rust</a> VERSION</span><br>
44
<a href="https://github.com/rust-lang/rust/commit/STAMP"
55
class="hash white-sticker">SHORT_HASH</a>

src/libcollections/btree/map.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,17 +1194,17 @@ unsafe fn unwrap_unchecked<T>(val: Option<T>) -> T {
11941194
}
11951195

11961196
impl<K, V> BTreeMap<K, V> {
1197-
/// Gets an iterator over the entries of the map.
1197+
/// Gets an iterator over the entries of the map, sorted by key.
11981198
///
11991199
/// # Examples
12001200
///
12011201
/// ```
12021202
/// use std::collections::BTreeMap;
12031203
///
12041204
/// let mut map = BTreeMap::new();
1205-
/// map.insert(1, "a");
1206-
/// map.insert(2, "b");
12071205
/// map.insert(3, "c");
1206+
/// map.insert(2, "b");
1207+
/// map.insert(1, "a");
12081208
///
12091209
/// for (key, value) in map.iter() {
12101210
/// println!("{}: {}", key, value);
@@ -1224,7 +1224,7 @@ impl<K, V> BTreeMap<K, V> {
12241224
}
12251225
}
12261226

1227-
/// Gets a mutable iterator over the entries of the map.
1227+
/// Gets a mutable iterator over the entries of the map, sorted by key.
12281228
///
12291229
/// # Examples
12301230
///
@@ -1257,16 +1257,16 @@ impl<K, V> BTreeMap<K, V> {
12571257
}
12581258
}
12591259

1260-
/// Gets an iterator over the keys of the map.
1260+
/// Gets an iterator over the keys of the map, in sorted order.
12611261
///
12621262
/// # Examples
12631263
///
12641264
/// ```
12651265
/// use std::collections::BTreeMap;
12661266
///
12671267
/// let mut a = BTreeMap::new();
1268-
/// a.insert(1, "a");
12691268
/// a.insert(2, "b");
1269+
/// a.insert(1, "a");
12701270
///
12711271
/// let keys: Vec<_> = a.keys().cloned().collect();
12721272
/// assert_eq!(keys, [1, 2]);
@@ -1276,19 +1276,19 @@ impl<K, V> BTreeMap<K, V> {
12761276
Keys { inner: self.iter() }
12771277
}
12781278

1279-
/// Gets an iterator over the values of the map.
1279+
/// Gets an iterator over the values of the map, in order by key.
12801280
///
12811281
/// # Examples
12821282
///
12831283
/// ```
12841284
/// use std::collections::BTreeMap;
12851285
///
12861286
/// let mut a = BTreeMap::new();
1287-
/// a.insert(1, "a");
1288-
/// a.insert(2, "b");
1287+
/// a.insert(1, "hello");
1288+
/// a.insert(2, "goodbye");
12891289
///
12901290
/// let values: Vec<&str> = a.values().cloned().collect();
1291-
/// assert_eq!(values, ["a", "b"]);
1291+
/// assert_eq!(values, ["hello", "goodbye"]);
12921292
/// ```
12931293
#[stable(feature = "rust1", since = "1.0.0")]
12941294
pub fn values<'a>(&'a self) -> Values<'a, K, V> {

src/librustc_borrowck/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ fn main() {
124124
let mut x = Rc::new(RefCell::new(MyStruct{ s: 5u32 }));
125125
let y = x.clone();
126126
x.borrow_mut().s = 6;
127-
println!("{}", x.borrow.s);
127+
println!("{}", x.borrow().s);
128128
}
129129
```
130130

src/librustc_resolve/diagnostics.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,41 @@ https://doc.rust-lang.org/reference.html#statements
207207
E0317: r##"
208208
User-defined types or type parameters cannot shadow the primitive types.
209209
This error indicates you tried to define a type, struct or enum with the same
210-
name as an existing primitive type.
210+
name as an existing primitive type:
211+
212+
```
213+
struct u8 {
214+
// ...
215+
}
216+
```
217+
218+
To fix this, simply name it something else.
219+
220+
Such an error may also occur if you define a type parameter which shadows a
221+
primitive type. An example would be something like:
222+
223+
```
224+
impl<u8> MyTrait for Option<u8> {
225+
// ...
226+
}
227+
```
228+
229+
In such a case, if you meant for `u8` to be a generic type parameter (i.e. any
230+
type can be used in its place), use something like `T` instead:
231+
232+
```
233+
impl<T> MyTrait for Option<T> {
234+
// ...
235+
}
236+
```
237+
238+
On the other hand, if you wished to refer to the specific type `u8`, remove it
239+
from the type parameter list:
240+
241+
```
242+
impl MyTrait for Option<u8> {
243+
// ...
244+
}
211245
212246
See the Types section of the reference for more information about the primitive
213247
types:

src/librustc_typeck/diagnostics.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,6 +2269,8 @@ struct MyType<T>(T);
22692269
impl<T> ForeignTrait for MyType<T> { ... } // Ok
22702270
```
22712271
2272+
Please note that a type alias is not sufficient.
2273+
22722274
For another example of an error, suppose there's another trait defined in `foo`
22732275
named `ForeignTrait2` that takes two type parameters. Then this `impl` results
22742276
in the same rule violation:

0 commit comments

Comments
 (0)