Skip to content

Commit 3fba503

Browse files
authored
Auto merge of #37514 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 7 pull requests - Successful merges: #36849, #37059, #37296, #37316, #37484, #37485, #37495 - Failed merges:
2 parents 7c69b0d + f5c192a commit 3fba503

File tree

15 files changed

+251
-249
lines changed

15 files changed

+251
-249
lines changed

src/doc/book/closures.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -510,12 +510,11 @@ fn factory() -> Box<Fn(i32) -> i32> {
510510
511511
Box::new(|x| x + num)
512512
}
513-
# fn main() {
513+
514514
let f = factory();
515515
516516
let answer = f(1);
517517
assert_eq!(6, answer);
518-
# }
519518
```
520519

521520
There’s just one last problem:
@@ -540,12 +539,11 @@ fn factory() -> Box<Fn(i32) -> i32> {
540539

541540
Box::new(move |x| x + num)
542541
}
543-
fn main() {
542+
544543
let f = factory();
545544

546545
let answer = f(1);
547546
assert_eq!(6, answer);
548-
}
549547
```
550548

551549
By making the inner closure a `move Fn`, we create a new stack frame for our

src/doc/book/guessing-game.md

-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,6 @@ numbers. A bare number like above is actually shorthand for `^0.3.0`,
362362
meaning "anything compatible with 0.3.0".
363363
If we wanted to use only `0.3.0` exactly, we could say `rand="=0.3.0"`
364364
(note the two equal signs).
365-
And if we wanted to use the latest version we could use `rand="*"`.
366365
We could also use a range of versions.
367366
[Cargo’s documentation][cargodoc] contains more details.
368367

src/doc/book/testing.md

+39-35
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ Cargo will automatically generate a simple test when you make a new project.
2424
Here's the contents of `src/lib.rs`:
2525

2626
```rust
27-
# fn main() {}
28-
#[test]
29-
fn it_works() {
27+
#[cfg(test)]
28+
mod tests {
29+
#[test]
30+
fn it_works() {
31+
}
3032
}
3133
```
3234

@@ -36,11 +38,11 @@ currently has no body. That's good enough to pass! We can run the tests with
3638

3739
```bash
3840
$ cargo test
39-
Compiling adder v0.0.1 (file:///home/you/projects/adder)
40-
Running target/adder-91b3e234d4ed382a
41+
Compiling adder v0.1.0 (file:///home/you/projects/adder)
42+
Running target/debug/deps/adder-91b3e234d4ed382a
4143

4244
running 1 test
43-
test it_works ... ok
45+
test tests::it_works ... ok
4446

4547
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
4648

@@ -56,7 +58,7 @@ for the test we wrote, and another for documentation tests. We'll talk about
5658
those later. For now, see this line:
5759

5860
```text
59-
test it_works ... ok
61+
test tests::it_works ... ok
6062
```
6163

6264
Note the `it_works`. This comes from the name of our function:
@@ -89,31 +91,30 @@ run our tests again:
8991

9092
```bash
9193
$ cargo test
92-
Compiling adder v0.0.1 (file:///home/you/projects/adder)
93-
Running target/adder-91b3e234d4ed382a
94+
Compiling adder v0.1.0 (file:///home/you/projects/adder)
95+
Running target/debug/deps/adder-91b3e234d4ed382a
9496

9597
running 1 test
96-
test it_works ... FAILED
98+
test tests::it_works ... FAILED
9799

98100
failures:
99101

100-
---- it_works stdout ----
101-
thread 'it_works' panicked at 'assertion failed: false', /home/steve/tmp/adder/src/lib.rs:3
102-
102+
---- test::it_works stdout ----
103+
thread 'tests::it_works' panicked at 'assertion failed: false', src/lib.rs:5
103104

104105

105106
failures:
106-
it_works
107+
tests::it_works
107108

108109
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured
109110

110-
thread 'main' panicked at 'Some tests failed', /home/steve/src/rust/src/libtest/lib.rs:247
111+
error: test failed
111112
```
112113

113114
Rust indicates that our test failed:
114115

115116
```text
116-
test it_works ... FAILED
117+
test tests::it_works ... FAILED
117118
```
118119

119120
And that's reflected in the summary line:
@@ -159,11 +160,11 @@ This test will now succeed if we `panic!` and fail if we complete. Let's try it:
159160

160161
```bash
161162
$ cargo test
162-
Compiling adder v0.0.1 (file:///home/you/projects/adder)
163-
Running target/adder-91b3e234d4ed382a
163+
Compiling adder v0.1.0 (file:///home/you/projects/adder)
164+
Running target/debug/deps/adder-91b3e234d4ed382a
164165

165166
running 1 test
166-
test it_works ... ok
167+
test tests::it_works ... ok
167168

168169
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
169170

@@ -191,11 +192,11 @@ passes:
191192

192193
```bash
193194
$ cargo test
194-
Compiling adder v0.0.1 (file:///home/you/projects/adder)
195-
Running target/adder-91b3e234d4ed382a
195+
Compiling adder v0.1.0 (file:///home/you/projects/adder)
196+
Running target/debug/deps/adder-91b3e234d4ed382a
196197

197198
running 1 test
198-
test it_works ... ok
199+
test tests::it_works ... ok
199200

200201
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
201202

@@ -262,8 +263,8 @@ not:
262263

263264
```bash
264265
$ cargo test
265-
Compiling adder v0.0.1 (file:///home/you/projects/adder)
266-
Running target/adder-91b3e234d4ed382a
266+
Compiling adder v0.1.0 (file:///home/you/projects/adder)
267+
Running target/debug/deps/adder-91b3e234d4ed382a
267268

268269
running 2 tests
269270
test expensive_test ... ignored
@@ -282,7 +283,7 @@ The expensive tests can be run explicitly using `cargo test -- --ignored`:
282283

283284
```bash
284285
$ cargo test -- --ignored
285-
Running target/adder-91b3e234d4ed382a
286+
Running target/debug/deps/adder-91b3e234d4ed382a
286287

287288
running 1 test
288289
test expensive_test ... ok
@@ -302,8 +303,11 @@ which is why the command is `cargo test -- --ignored`.
302303
# The `tests` module
303304

304305
There is one way in which our existing example is not idiomatic: it's
305-
missing the `tests` module. The idiomatic way of writing our example
306-
looks like this:
306+
missing the `tests` module. You might have noticed this test module was
307+
present in the code that was initially generated with `cargo new` but
308+
was missing from our last example. Let's explain what this does.
309+
310+
The idiomatic way of writing our example looks like this:
307311

308312
```rust,ignore
309313
# fn main() {}
@@ -356,8 +360,8 @@ Note the different `use` line. Now we run our tests:
356360
```bash
357361
$ cargo test
358362
Updating registry `https://github.com/rust-lang/crates.io-index`
359-
Compiling adder v0.0.1 (file:///home/you/projects/adder)
360-
Running target/adder-91b3e234d4ed382a
363+
Compiling adder v0.1.0 (file:///home/you/projects/adder)
364+
Running target/debug/deps/adder-91b3e234d4ed382a
361365

362366
running 1 test
363367
test tests::it_works ... ok
@@ -404,15 +408,15 @@ Let's run them:
404408

405409
```bash
406410
$ cargo test
407-
Compiling adder v0.0.1 (file:///home/you/projects/adder)
408-
Running target/adder-91b3e234d4ed382a
411+
Compiling adder v0.1.0 (file:///home/you/projects/adder)
412+
Running target/debug/deps/adder-91b3e234d4ed382a
409413

410414
running 1 test
411415
test tests::it_works ... ok
412416

413417
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
414418

415-
Running target/lib-c18e7d3494509e74
419+
Running target/debug/integration_test-68064b69521c828a
416420

417421
running 1 test
418422
test it_works ... ok
@@ -490,15 +494,15 @@ Let's run the tests again:
490494

491495
```bash
492496
$ cargo test
493-
Compiling adder v0.0.1 (file:///home/steve/tmp/adder)
494-
Running target/adder-91b3e234d4ed382a
497+
Compiling adder v0.1.0. (file:///home/you/projects/adder)
498+
Running target/debug/deps/adder-91b3e234d4ed382a
495499

496500
running 1 test
497501
test tests::it_works ... ok
498502

499503
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
500504

501-
Running target/lib-c18e7d3494509e74
505+
Running target/debug/integration_test-68064b69521c828a
502506

503507
running 1 test
504508
test it_works ... ok

src/libcore/convert.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ pub trait AsMut<T: ?Sized> {
145145
///
146146
/// # Generic Impls
147147
///
148-
/// - `[From<T>][From] for U` implies `Into<U> for T`
148+
/// - [`From<T>`][From]` for U` implies `Into<U> for T`
149149
/// - [`into()`] is reflexive, which means that `Into<T> for T` is implemented
150150
///
151151
/// [`TryInto`]: trait.TryInto.html
@@ -178,14 +178,14 @@ pub trait Into<T>: Sized {
178178
/// ```
179179
/// # Generic impls
180180
///
181-
/// - `From<T> for U` implies `[Into<U>] for T`
181+
/// - `From<T> for U` implies [`Into<U>`]` for T`
182182
/// - [`from()`] is reflexive, which means that `From<T> for T` is implemented
183183
///
184184
/// [`TryFrom`]: trait.TryFrom.html
185185
/// [`Option<T>`]: ../../std/option/enum.Option.html
186186
/// [`Result<T, E>`]: ../../std/result/enum.Result.html
187187
/// [`String`]: ../../std/string/struct.String.html
188-
/// [Into<U>]: trait.Into.html
188+
/// [`Into<U>`]: trait.Into.html
189189
/// [`from()`]: trait.From.html#tymethod.from
190190
#[stable(feature = "rust1", since = "1.0.0")]
191191
pub trait From<T>: Sized {

src/libcore/macros.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ macro_rules! panic {
4242
/// Unsafe code relies on `assert!` to enforce run-time invariants that, if
4343
/// violated could lead to unsafety.
4444
///
45-
/// Other use-cases of `assert!` include
46-
/// [testing](https://doc.rust-lang.org/book/testing.html) and enforcing
47-
/// run-time invariants in safe code (whose violation cannot result in unsafety).
45+
/// Other use-cases of `assert!` include [testing] and enforcing run-time
46+
/// invariants in safe code (whose violation cannot result in unsafety).
4847
///
4948
/// This macro has a second version, where a custom panic message can be provided.
5049
///
50+
/// [testing]: ../book/testing.html
51+
///
5152
/// # Examples
5253
///
5354
/// ```

src/libcore/marker.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ pub trait Unsize<T: ?Sized> {
241241
/// compile-time error. Specifically, with structs you'll get [E0204] and with enums you'll get
242242
/// [E0205].
243243
///
244-
/// [E0204]: https://doc.rust-lang.org/error-index.html#E0204
245-
/// [E0205]: https://doc.rust-lang.org/error-index.html#E0205
244+
/// [E0204]: ../../error-index.html#E0204
245+
/// [E0205]: ../../error-index.html#E0205
246246
///
247247
/// ## When *should* my type be `Copy`?
248248
///

src/libcore/ops.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ pub trait Drop {
182182
/// After this function is over, the memory of `self` will be deallocated.
183183
///
184184
/// This function cannot be called explicitly. This is compiler error
185-
/// [0040]. However, the [`std::mem::drop`] function in the prelude can be
185+
/// [E0040]. However, the [`std::mem::drop`] function in the prelude can be
186186
/// used to call the argument's `Drop` implementation.
187187
///
188-
/// [0040]: https://doc.rust-lang.org/error-index.html#E0040
189-
/// [`std::mem::drop`]: https://doc.rust-lang.org/std/mem/fn.drop.html
188+
/// [E0040]: ../../error-index.html#E0040
189+
/// [`std::mem::drop`]: ../../std/mem/fn.drop.html
190190
///
191191
/// # Panics
192192
///

src/libcore/str/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl Utf8Error {
132132
/// verified.
133133
///
134134
/// It is the maximum index such that `from_utf8(input[..index])`
135-
/// would return `Some(_)`.
135+
/// would return `Ok(_)`.
136136
///
137137
/// # Examples
138138
///

src/librustc/infer/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,6 @@ pub enum TypeOrigin {
199199
// Computing common supertype of an if expression with no else counter-part
200200
IfExpressionWithNoElse(Span),
201201

202-
// Computing common supertype in a range expression
203-
RangeExpression(Span),
204-
205202
// `where a == b`
206203
EquatePredicate(Span),
207204

@@ -231,7 +228,6 @@ impl TypeOrigin {
231228
},
232229
&TypeOrigin::IfExpression(_) => "if and else have incompatible types",
233230
&TypeOrigin::IfExpressionWithNoElse(_) => "if may be missing an else clause",
234-
&TypeOrigin::RangeExpression(_) => "start and end of range have incompatible types",
235231
&TypeOrigin::EquatePredicate(_) => "equality predicate not satisfied",
236232
&TypeOrigin::MainFunctionType(_) => "main function has wrong type",
237233
&TypeOrigin::StartFunctionType(_) => "start function has wrong type",
@@ -251,7 +247,6 @@ impl TypeOrigin {
251247
&TypeOrigin::MatchExpressionArm(..) => "match arms have compatible types",
252248
&TypeOrigin::IfExpression(_) => "if and else have compatible types",
253249
&TypeOrigin::IfExpressionWithNoElse(_) => "if missing an else returns ()",
254-
&TypeOrigin::RangeExpression(_) => "start and end of range have compatible types",
255250
&TypeOrigin::EquatePredicate(_) => "equality where clause is satisfied",
256251
&TypeOrigin::MainFunctionType(_) => "`main` function has the correct type",
257252
&TypeOrigin::StartFunctionType(_) => "`start` function has the correct type",
@@ -1755,7 +1750,6 @@ impl TypeOrigin {
17551750
TypeOrigin::MatchExpressionArm(match_span, ..) => match_span,
17561751
TypeOrigin::IfExpression(span) => span,
17571752
TypeOrigin::IfExpressionWithNoElse(span) => span,
1758-
TypeOrigin::RangeExpression(span) => span,
17591753
TypeOrigin::EquatePredicate(span) => span,
17601754
TypeOrigin::MainFunctionType(span) => span,
17611755
TypeOrigin::StartFunctionType(span) => span,

0 commit comments

Comments
 (0)