Skip to content

Commit 221c940

Browse files
committed
Auto merge of #32561 - steveklabnik:rollup, r=steveklabnik
Rollup of 7 pull requests - Successful merges: #32177, #32235, #32472, #32504, #32507, #32509, #32534 - Failed merges:
2 parents 1f131fb + 9eea1d7 commit 221c940

File tree

16 files changed

+73
-44
lines changed

16 files changed

+73
-44
lines changed

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ Some common make targets are:
132132
- `make check-stage1-std NO_REBUILD=1` - test the standard library without
133133
rebuilding the entire compiler
134134
- `make check TESTNAME=<substring-of-test-name>` - Run a matching set of tests.
135-
- `TESTNAME` should be a substring of the tests to match against e.g. it could
136-
be the fully qualified test name, or just a part of it.
135+
- `TESTNAME` should be a substring of the tests to match against e.g. it could
136+
be the fully qualified test name, or just a part of it.
137137
`TESTNAME=collections::hash::map::test_map::test_capacity_not_less_than_len`
138138
or `TESTNAME=test_capacity_not_less_than_len`.
139139
- `make check-stage1-rpass TESTNAME=<substring-of-test-name>` - Run a single

src/doc/book/casting-between-types.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ function result.
1717
The most common case of coercion is removing mutability from a reference:
1818

1919
* `&mut T` to `&T`
20-
20+
2121
An analogous conversion is to remove mutability from a
2222
[raw pointer](raw-pointers.md):
2323

2424
* `*mut T` to `*const T`
25-
25+
2626
References can also be coerced to raw pointers:
2727

2828
* `&T` to `*const T`
@@ -32,7 +32,7 @@ References can also be coerced to raw pointers:
3232
Custom coercions may be defined using [`Deref`](deref-coercions.md).
3333

3434
Coercion is transitive.
35-
35+
3636
# `as`
3737

3838
The `as` keyword does safe casting:
@@ -64,7 +64,7 @@ A cast `e as U` is also valid in any of the following cases:
6464
and `U` is an integer type; *enum-cast*
6565
* `e` has type `bool` or `char` and `U` is an integer type; *prim-int-cast*
6666
* `e` has type `u8` and `U` is `char`; *u8-char-cast*
67-
67+
6868
For example
6969

7070
```rust
@@ -98,9 +98,9 @@ The semantics of numeric casts are:
9898

9999
[float-int]: https://github.com/rust-lang/rust/issues/10184
100100
[float-float]: https://github.com/rust-lang/rust/issues/15536
101-
101+
102102
## Pointer casts
103-
103+
104104
Perhaps surprisingly, it is safe to cast [raw pointers](raw-pointers.md) to and
105105
from integers, and to cast between pointers to different types subject to
106106
some constraints. It is only unsafe to dereference the pointer:
@@ -114,7 +114,7 @@ let b = a as u32;
114114

115115
* `e` has type `*T`, `U` has type `*U_0`, and either `U_0: Sized` or
116116
`unsize_kind(T) == unsize_kind(U_0)`; a *ptr-ptr-cast*
117-
117+
118118
* `e` has type `*T` and `U` is a numeric type, while `T: Sized`; *ptr-addr-cast*
119119

120120
* `e` is an integer and `U` is `*U_0`, while `U_0: Sized`; *addr-ptr-cast*

src/doc/book/closures.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -502,5 +502,5 @@ assert_eq!(6, answer);
502502
```
503503

504504
By making the inner closure a `move Fn`, we create a new stack frame for our
505-
closure. By `Box`ing it up, we’ve given it a known size, and allowing it to
505+
closure. By `Box`ing it up, we’ve given it a known size, allowing it to
506506
escape our stack frame.

src/doc/book/const-and-static.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ a [`Drop`][drop] implementation.
7272
# Initializing
7373

7474
Both `const` and `static` have requirements for giving them a value. They must
75-
be given a value that’s a constant expression. In other words, you cannot use
75+
be given a value that’s a constant expression. In other words, you cannot use
7676
the result of a function call or anything similarly complex or at runtime.
7777

7878
# Which construct should I use?

src/doc/book/getting-started.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ first. This leaves the top-level project directory (in this case,
417417
to your code. In this way, using Cargo helps you keep your projects nice and
418418
tidy. There's a place for everything, and everything is in its place.
419419

420-
Now, copy *main.rs* to the *src* directory, and delete the compiled file you
420+
Now, move *main.rs* into the *src* directory, and delete the compiled file you
421421
created with `rustc`. As usual, replace `main` with `main.exe` if you're on
422422
Windows.
423423

src/doc/book/macros.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ fn main() {
337337
}
338338
```
339339

340-
Instead you need to pass the variable name into the invocation, so it’s tagged
341-
with the right syntax context.
340+
Instead you need to pass the variable name into the invocation, so that it’s
341+
tagged with the right syntax context.
342342

343343
```rust
344344
macro_rules! foo {
@@ -470,7 +470,7 @@ which syntactic form it matches.
470470
* `ty`: a type. Examples: `i32`; `Vec<(char, String)>`; `&T`.
471471
* `pat`: a pattern. Examples: `Some(t)`; `(17, 'a')`; `_`.
472472
* `stmt`: a single statement. Example: `let x = 3`.
473-
* `block`: a brace-delimited sequence of statements. Example:
473+
* `block`: a brace-delimited sequence of statements and optionally an expression. Example:
474474
`{ log(error, "hi"); return 12; }`.
475475
* `item`: an [item][item]. Examples: `fn foo() { }`; `struct Bar;`.
476476
* `meta`: a "meta item", as found in attributes. Example: `cfg(target_os = "windows")`.

src/doc/book/match.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ patterns][patterns] that covers all the patterns that are possible here.
2828

2929
[patterns]: patterns.html
3030

31-
One of the many advantages of `match` is it enforces ‘exhaustiveness checking’.
32-
For example if we remove the last arm with the underscore `_`, the compiler will
31+
One of the many advantages of `match` is it enforces ‘exhaustiveness checking’.
32+
For example if we remove the last arm with the underscore `_`, the compiler will
3333
give us an error:
3434

3535
```text
@@ -58,7 +58,7 @@ let number = match x {
5858
};
5959
```
6060

61-
Sometimes it’s a nice way of converting something from one type to another; in
61+
Sometimes it’s a nice way of converting something from one type to another; in
6262
this example the integers are converted to `String`.
6363

6464
# Matching on enums
@@ -90,7 +90,7 @@ fn process_message(msg: Message) {
9090

9191
Again, the Rust compiler checks exhaustiveness, so it demands that you
9292
have a match arm for every variant of the enum. If you leave one off, it
93-
will give you a compile-time error unless you use `_` or provide all possible
93+
will give you a compile-time error unless you use `_` or provide all possible
9494
arms.
9595

9696
Unlike the previous uses of `match`, you can’t use the normal `if`

src/doc/book/ownership.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ special annotation here, it’s the default thing that Rust does.
124124
## The details
125125

126126
The reason that we cannot use a binding after we’ve moved it is subtle, but
127-
important.
127+
important.
128128

129129
When we write code like this:
130130

@@ -148,7 +148,7 @@ The first line allocates memory for the vector object `v` on the stack like
148148
it does for `x` above. But in addition to that it also allocates some memory
149149
on the [heap][sh] for the actual data (`[1, 2, 3]`). Rust copies the address
150150
of this heap allocation to an internal pointer, which is part of the vector
151-
object placed on the stack (let's call it the data pointer).
151+
object placed on the stack (let's call it the data pointer).
152152

153153
It is worth pointing out (even at the risk of stating the obvious) that the
154154
vector object and its data live in separate memory regions instead of being a
@@ -163,7 +163,7 @@ does not create a copy of the heap allocation containing the actual data.
163163
Which means that there would be two pointers to the contents of the vector
164164
both pointing to the same memory allocation on the heap. It would violate
165165
Rust’s safety guarantees by introducing a data race if one could access both
166-
`v` and `v2` at the same time.
166+
`v` and `v2` at the same time.
167167

168168
For example if we truncated the vector to just two elements through `v2`:
169169

src/doc/book/primitive-types.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ copying. For example, you might want to reference only one line of a file read
164164
into memory. By nature, a slice is not created directly, but from an existing
165165
variable binding. Slices have a defined length, can be mutable or immutable.
166166

167-
Internally, slices are represented as a pointer to the beginning of the data
167+
Internally, slices are represented as a pointer to the beginning of the data
168168
and a length.
169169

170170
## Slicing syntax

src/doc/book/vectors.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ for i in v {
116116
```
117117

118118
Note: You cannot use the vector again once you have iterated by taking ownership of the vector.
119-
You can iterate the vector multiple times by taking a reference to the vector whilst iterating.
119+
You can iterate the vector multiple times by taking a reference to the vector whilst iterating.
120120
For example, the following code does not compile.
121121

122122
```rust,ignore

src/liballoc/arc.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize;
107107
/// use std::thread;
108108
///
109109
/// fn main() {
110-
/// let numbers: Vec<_> = (0..100u32).collect();
110+
/// let numbers: Vec<_> = (0..100).collect();
111111
/// let shared_numbers = Arc::new(numbers);
112112
///
113113
/// for _ in 0..10 {
@@ -1118,7 +1118,7 @@ mod tests {
11181118

11191119
#[test]
11201120
fn test_strong_count() {
1121-
let a = Arc::new(0u32);
1121+
let a = Arc::new(0);
11221122
assert!(Arc::strong_count(&a) == 1);
11231123
let w = Arc::downgrade(&a);
11241124
assert!(Arc::strong_count(&a) == 1);
@@ -1135,7 +1135,7 @@ mod tests {
11351135

11361136
#[test]
11371137
fn test_weak_count() {
1138-
let a = Arc::new(0u32);
1138+
let a = Arc::new(0);
11391139
assert!(Arc::strong_count(&a) == 1);
11401140
assert!(Arc::weak_count(&a) == 0);
11411141
let w = Arc::downgrade(&a);
@@ -1161,7 +1161,7 @@ mod tests {
11611161

11621162
#[test]
11631163
fn show_arc() {
1164-
let a = Arc::new(5u32);
1164+
let a = Arc::new(5);
11651165
assert_eq!(format!("{:?}", a), "5");
11661166
}
11671167

src/liballoc/rc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ mod tests {
10141014

10151015
#[test]
10161016
fn test_strong_count() {
1017-
let a = Rc::new(0u32);
1017+
let a = Rc::new(0);
10181018
assert!(Rc::strong_count(&a) == 1);
10191019
let w = Rc::downgrade(&a);
10201020
assert!(Rc::strong_count(&a) == 1);
@@ -1031,7 +1031,7 @@ mod tests {
10311031

10321032
#[test]
10331033
fn test_weak_count() {
1034-
let a = Rc::new(0u32);
1034+
let a = Rc::new(0);
10351035
assert!(Rc::strong_count(&a) == 1);
10361036
assert!(Rc::weak_count(&a) == 0);
10371037
let w = Rc::downgrade(&a);

src/libcollections/linked_list.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1305,10 +1305,10 @@ mod tests {
13051305
//
13061306
// https://github.com/rust-lang/rust/issues/26021
13071307
let mut v1 = LinkedList::new();
1308-
v1.push_front(1u8);
1309-
v1.push_front(1u8);
1310-
v1.push_front(1u8);
1311-
v1.push_front(1u8);
1308+
v1.push_front(1);
1309+
v1.push_front(1);
1310+
v1.push_front(1);
1311+
v1.push_front(1);
13121312
let _ = v1.split_off(3); // Dropping this now should not cause laundry consumption
13131313
assert_eq!(v1.len(), 3);
13141314

@@ -1319,10 +1319,10 @@ mod tests {
13191319
#[test]
13201320
fn test_split_off() {
13211321
let mut v1 = LinkedList::new();
1322-
v1.push_front(1u8);
1323-
v1.push_front(1u8);
1324-
v1.push_front(1u8);
1325-
v1.push_front(1u8);
1322+
v1.push_front(1);
1323+
v1.push_front(1);
1324+
v1.push_front(1);
1325+
v1.push_front(1);
13261326

13271327
// test all splits
13281328
for ix in 0..1 + v1.len() {

src/libcollectionstest/slice.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@ fn test_swap_remove_fail() {
267267
fn test_swap_remove_noncopyable() {
268268
// Tests that we don't accidentally run destructors twice.
269269
let mut v: Vec<Box<_>> = Vec::new();
270-
v.push(box 0u8);
271-
v.push(box 0u8);
272-
v.push(box 0u8);
270+
v.push(box 0);
271+
v.push(box 0);
272+
v.push(box 0);
273273
let mut _e = v.swap_remove(0);
274274
assert_eq!(v.len(), 2);
275275
_e = v.swap_remove(1);
@@ -884,7 +884,7 @@ fn test_overflow_does_not_cause_segfault_managed() {
884884

885885
#[test]
886886
fn test_mut_split_at() {
887-
let mut values = [1u8,2,3,4,5];
887+
let mut values = [1,2,3,4,5];
888888
{
889889
let (left, right) = values.split_at_mut(2);
890890
{

src/librustc_typeck/diagnostics.rs

+24
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,30 @@ fn main() {
327327
<Test as Trait1>::foo()
328328
}
329329
```
330+
331+
One last example:
332+
333+
```
334+
trait F {
335+
fn m(&self);
336+
}
337+
338+
trait G {
339+
fn m(&self);
340+
}
341+
342+
struct X;
343+
344+
impl F for X { fn m(&self) { println!("I am F"); } }
345+
impl G for X { fn m(&self) { println!("I am G"); } }
346+
347+
fn main() {
348+
let f = X;
349+
350+
F::m(&f); // it displays "I am F"
351+
G::m(&f); // it displays "I am G"
352+
}
353+
```
330354
"##,
331355

332356
E0035: r##"

src/libstd/sync/barrier.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,21 @@ use sync::{Mutex, Condvar};
1717
/// use std::sync::{Arc, Barrier};
1818
/// use std::thread;
1919
///
20+
/// let mut handles = Vec::with_capacity(10);
2021
/// let barrier = Arc::new(Barrier::new(10));
2122
/// for _ in 0..10 {
2223
/// let c = barrier.clone();
2324
/// // The same messages will be printed together.
2425
/// // You will NOT see any interleaving.
25-
/// thread::spawn(move|| {
26+
/// handles.push(thread::spawn(move|| {
2627
/// println!("before wait");
2728
/// c.wait();
2829
/// println!("after wait");
29-
/// });
30+
/// }));
31+
/// }
32+
/// // Wait for other threads to finish.
33+
/// for handle in handles {
34+
/// handle.join().unwrap();
3035
/// }
3136
/// ```
3237
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)