Skip to content

Commit 9ecc989

Browse files
committed
Auto merge of #25281 - steveklabnik:rollup, r=steveklabnik
- Successful merges: #24948, #25158, #25188, #25222, #25239, #25240, #25241, #25255, #25257, #25263 - Failed merges:
2 parents 750f2c6 + c70458b commit 9ecc989

File tree

11 files changed

+100
-11
lines changed

11 files changed

+100
-11
lines changed

src/doc/trpl/guessing-game.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ variety of numbers, we need to give Rust a hint as to the exact type of number
713713
we want. Hence, `let guess: u32`. The colon (`:`) after `guess` tells Rust
714714
we’re going to annotate its type. `u32` is an unsigned, thirty-two bit
715715
integer. Rust has [a number of built-in number types][number], but we’ve
716-
chosen `u32`. It’s a good default choice for a small positive numer.
716+
chosen `u32`. It’s a good default choice for a small positive number.
717717
718718
[parse]: ../std/primitive.str.html#method.parse
719719
[number]: primitive-types.html#numeric-types
@@ -922,7 +922,7 @@ failure. Each contains more information: the successful parsed integer, or an
922922
error type. In this case, we `match` on `Ok(num)`, which sets the inner value
923923
of the `Ok` to the name `num`, and then we just return it on the right-hand
924924
side. In the `Err` case, we don’t care what kind of error it is, so we just
925-
use `_` intead of a name. This ignores the error, and `continue` causes us
925+
use `_` instead of a name. This ignores the error, and `continue` causes us
926926
to go to the next iteration of the `loop`.
927927
928928
Now we should be good! Let’s try:

src/doc/trpl/match.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ side of a `let` binding or directly where an expression is used:
5050
```rust
5151
let x = 5;
5252

53-
let numer = match x {
53+
let number = match x {
5454
1 => "one",
5555
2 => "two",
5656
3 => "three",

src/doc/trpl/mutability.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ When we call `clone()`, the `Arc<T>` needs to update the reference count. Yet
7878
we’ve not used any `mut`s here, `x` is an immutable binding, and we didn’t take
7979
`&mut 5` or anything. So what gives?
8080

81-
To this, we have to go back to the core of Rust’s guiding philosophy, memory
82-
safety, and the mechanism by which Rust guarantees it, the
81+
To understand this, we have to go back to the core of Rust’s guiding
82+
philosophy, memory safety, and the mechanism by which Rust guarantees it, the
8383
[ownership][ownership] system, and more specifically, [borrowing][borrowing]:
8484

8585
> You may have one or the other of these two kinds of borrows, but not both at

src/doc/trpl/ownership.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ fn foo(v: Vec<i32>) -> Vec<i32> {
174174
}
175175
```
176176

177-
This would get very tedius. It gets worse the more things we want to take ownership of:
177+
This would get very tedious. It gets worse the more things we want to take ownership of:
178178

179179
```rust
180180
fn foo(v1: Vec<i32>, v2: Vec<i32>) -> (Vec<i32>, Vec<i32>, i32) {

src/doc/trpl/primitive-types.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ Slices have type `&[T]`. We’ll talk about that `T` when we cover
176176

177177
[generics]: generics.html
178178

179-
You can find more documentation for `slices`s [in the standard library
179+
You can find more documentation for slices [in the standard library
180180
documentation][slice].
181181

182182
[slice]: ../std/primitive.slice.html

src/doc/trpl/references-and-borrowing.md

+35
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ println!("{}", y);
312312

313313
We get this error:
314314

315+
```text
315316
error: `x` does not live long enough
316317
y = &x;
317318
^
@@ -334,3 +335,37 @@ In other words, `y` is only valid for the scope where `x` exists. As soon as
334335
`x` goes away, it becomes invalid to refer to it. As such, the error says that
335336
the borrow ‘doesn’t live long enough’ because it’s not valid for the right
336337
amount of time.
338+
339+
The same problem occurs when the reference is declared _before_ the variable it refers to:
340+
341+
```rust,ignore
342+
let y: &i32;
343+
let x = 5;
344+
y = &x;
345+
346+
println!("{}", y);
347+
```
348+
349+
We get this error:
350+
351+
```text
352+
error: `x` does not live long enough
353+
y = &x;
354+
^
355+
note: reference must be valid for the block suffix following statement 0 at
356+
2:16...
357+
let y: &i32;
358+
let x = 5;
359+
y = &x;
360+
361+
println!("{}", y);
362+
}
363+
364+
note: ...but borrowed value is only valid for the block suffix following
365+
statement 1 at 3:14
366+
let x = 5;
367+
y = &x;
368+
369+
println!("{}", y);
370+
}
371+
```

src/etc/CONFIGS.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
# Configs
22

3-
Here are some links to repos with configs which ease the use of rust:
3+
These are some links to repos with configs which ease the use of rust.
4+
5+
## Officially Maintained Configs
46

57
* [rust.vim](https://github.com/rust-lang/rust.vim)
68
* [emacs rust-mode](https://github.com/rust-lang/rust-mode)
79
* [gedit-config](https://github.com/rust-lang/gedit-config)
810
* [kate-config](https://github.com/rust-lang/kate-config)
911
* [nano-config](https://github.com/rust-lang/nano-config)
1012
* [zsh-config](https://github.com/rust-lang/zsh-config)
13+
14+
## Community-maintained Configs
15+
16+
* [.editorconfig](https://gist.github.com/derhuerst/c9d1b9309e308d9851fa) ([what is this?](http://editorconfig.org/))

src/libcollections/string.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,7 @@ impl<T: fmt::Display + ?Sized> ToString for T {
10521052

10531053
#[stable(feature = "rust1", since = "1.0.0")]
10541054
impl AsRef<str> for String {
1055+
#[inline]
10551056
fn as_ref(&self) -> &str {
10561057
self
10571058
}

src/libcore/convert.rs

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ impl<T> AsMut<[T]> for [T] {
173173

174174
#[stable(feature = "rust1", since = "1.0.0")]
175175
impl AsRef<str> for str {
176+
#[inline]
176177
fn as_ref(&self) -> &str {
177178
self
178179
}

src/librustc_typeck/diagnostics.rs

+31-3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,23 @@ enum variant, one of the fields was not provided. Each field should be specified
4646
exactly once.
4747
"##,
4848

49+
E0067: r##"
50+
The left-hand side of an assignment operator must be an lvalue expression. An
51+
lvalue expression represents a memory location and includes item paths (ie,
52+
namespaced variables), dereferences, indexing expressions, and field references.
53+
54+
```
55+
use std::collections::LinkedList;
56+
57+
// Good
58+
let mut list = LinkedList::new();
59+
60+
61+
// Bad: assignment to non-lvalue expression
62+
LinkedList::new() += 1;
63+
```
64+
"##,
65+
4966
E0081: r##"
5067
Enum discriminants are used to differentiate enum variants stored in memory.
5168
This error indicates that the same value was used for two or more variants,
@@ -119,6 +136,20 @@ construct an instance of the following type using only safe code:
119136
```
120137
enum Empty {}
121138
```
139+
"##,
140+
141+
E0131: r##"
142+
It is not possible to define `main` with type parameters, or even with function
143+
parameters. When `main` is present, it must take no arguments and return `()`.
144+
"##,
145+
146+
E0132: r##"
147+
It is not possible to declare type parameters on a function that has the `start`
148+
attribute. Such a function must have the following type signature:
149+
150+
```
151+
fn(isize, *const *const u8) -> isize
152+
```
122153
"##
123154

124155
}
@@ -149,7 +180,6 @@ register_diagnostics! {
149180
E0060,
150181
E0061,
151182
E0066,
152-
E0067,
153183
E0068,
154184
E0069,
155185
E0070,
@@ -189,8 +219,6 @@ register_diagnostics! {
189219
E0128,
190220
E0129,
191221
E0130,
192-
E0131,
193-
E0132,
194222
E0141,
195223
E0159,
196224
E0163,

src/libstd/collections/hash/map.rs

+18
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,24 @@ impl<K, V, S> HashMap<K, V, S>
916916
}
917917

918918
/// Gets the given key's corresponding entry in the map for in-place manipulation.
919+
///
920+
/// # Examples
921+
///
922+
/// ```
923+
/// use std::collections::HashMap;
924+
///
925+
/// let mut letters = HashMap::new();
926+
///
927+
/// for ch in "a short treatise on fungi".chars() {
928+
/// let counter = letters.entry(ch).or_insert(0);
929+
/// *counter += 1;
930+
/// }
931+
///
932+
/// assert_eq!(letters[&'s'], 2);
933+
/// assert_eq!(letters[&'t'], 3);
934+
/// assert_eq!(letters[&'u'], 1);
935+
/// assert_eq!(letters.get(&'y'), None);
936+
/// ```
919937
#[stable(feature = "rust1", since = "1.0.0")]
920938
pub fn entry(&mut self, key: K) -> Entry<K, V> {
921939
// Gotta resize now.

0 commit comments

Comments
 (0)