Skip to content

Commit a5b35e9

Browse files
committed
---
yaml --- r: 173986 b: refs/heads/batch c: 170c439 h: refs/heads/master v: v3
1 parent c41acfe commit a5b35e9

File tree

216 files changed

+3318
-1131
lines changed

Some content is hidden

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

216 files changed

+3318
-1131
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2929
refs/heads/issue-18208-method-dispatch-2: 9e1eae4fb9b6527315b4441cf8a0f5ca911d1671
3030
refs/heads/automation-fail: 1bf06495443584539b958873e04cc2f864ab10e4
3131
refs/heads/issue-18208-method-dispatch-3-quick-reject: 2009f85b9f99dedcec4404418eda9ddba90258a2
32-
refs/heads/batch: 616db5a501510cf29acf118812c192788e4e81e7
32+
refs/heads/batch: 170c4399e614fe599c3d41306b3429ca8b3b68c6
3333
refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 44a287e6eb22ec3c2a687fc156813577464017f7
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928

branches/batch/src/compiletest/runtest.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,16 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
966966
line.starts_with( prefix )
967967
}
968968

969+
// A multi-line error will have followup lines which will always
970+
// start with one of these strings.
971+
fn continuation( line: &str) -> bool {
972+
line.starts_with(" expected") ||
973+
line.starts_with(" found") ||
974+
// 1234
975+
// Should have 4 spaces: see issue 18946
976+
line.starts_with("(")
977+
}
978+
969979
// Scan and extract our error/warning messages,
970980
// which look like:
971981
// filename:line1:col1: line2:col2: *error:* msg
@@ -981,7 +991,7 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
981991
ee.kind,
982992
ee.msg,
983993
line);
984-
if prefix_matches(line, prefixes[i].as_slice()) &&
994+
if (prefix_matches(line, prefixes[i].as_slice()) || continuation(line)) &&
985995
line.contains(ee.kind.as_slice()) &&
986996
line.contains(ee.msg.as_slice()) {
987997
found_flags[i] = true;

branches/batch/src/doc/intro.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ use semver::Version;
106106
107107
fn main() {
108108
assert!(Version::parse("1.2.3") == Ok(Version {
109-
major: 1u,
110-
minor: 2u,
111-
patch: 3u,
109+
major: 1u64,
110+
minor: 2u64,
111+
patch: 3u64,
112112
pre: vec!(),
113113
build: vec!(),
114114
}));

branches/batch/src/doc/reference.md

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ mod b {
603603
```
604604

605605
* Paths starting with the keyword `super` begin resolution relative to the
606-
parent module. Each further identifier must resolve to an item
606+
parent module. Each further identifier must resolve to an item.
607607

608608
```rust
609609
mod a {
@@ -985,7 +985,7 @@ top of [modules](#modules) and [blocks](#blocks).
985985
986986
Use declarations support a number of convenient shortcuts:
987987

988-
* Rebinding the target name as a new local name, using the syntax `use p::q::r as x;`.
988+
* Rebinding the target name as a new local name, using the syntax `use p::q::r as x;`
989989
* Simultaneously binding a list of paths differing only in their final element,
990990
using the glob-like brace syntax `use a::b::{c,d,e,f};`
991991
* Binding all paths matching a given prefix, using the asterisk wildcard syntax
@@ -1091,7 +1091,7 @@ set of *input* [*slots*](#memory-slots) as parameters, through which the caller
10911091
passes arguments into the function, and an *output* [*slot*](#memory-slots)
10921092
through which the function passes results back to the caller.
10931093

1094-
A function may also be copied into a first class *value*, in which case the
1094+
A function may also be copied into a first-class *value*, in which case the
10951095
value has the corresponding [*function type*](#function-types), and can be used
10961096
otherwise exactly as a function item (with a minor additional cost of calling
10971097
the function indirectly).
@@ -1224,7 +1224,7 @@ the guarantee that these issues are never caused by safe code.
12241224
* A value other than `false` (0) or `true` (1) in a `bool`
12251225
* A discriminant in an `enum` not included in the type definition
12261226
* A value in a `char` which is a surrogate or above `char::MAX`
1227-
* non-UTF-8 byte sequences in a `str`
1227+
* Non-UTF-8 byte sequences in a `str`
12281228
* Unwinding into Rust from foreign code or unwinding from Rust into foreign
12291229
code. Rust's failure system is not compatible with exception handling in
12301230
other languages. Unwinding must be caught and handled at FFI boundaries.
@@ -1827,7 +1827,7 @@ accesses in two cases:
18271827

18281828
These two cases are surprisingly powerful for creating module hierarchies
18291829
exposing public APIs while hiding internal implementation details. To help
1830-
explain, here's a few use cases and what they would entail.
1830+
explain, here's a few use cases and what they would entail:
18311831

18321832
* A library developer needs to expose functionality to crates which link
18331833
against their library. As a consequence of the first case, this means that
@@ -1858,7 +1858,7 @@ import/expression is only valid if the destination is in the current visibility
18581858
scope.
18591859

18601860
Here's an example of a program which exemplifies the three cases outlined
1861-
above.
1861+
above:
18621862

18631863
```
18641864
// This module is private, meaning that no external crate can access this
@@ -2117,6 +2117,13 @@ macro scope.
21172117
destructors from being run twice. Destructors might be run multiple times on
21182118
the same object with this attribute.
21192119
- `doc` - Doc comments such as `/// foo` are equivalent to `#[doc = "foo"]`.
2120+
- `rustc_on_unimplemented` - Write a custom note to be shown along with the error
2121+
when the trait is found to be unimplemented on a type.
2122+
You may use format arguments like `{T}`, `{A}` to correspond to the
2123+
types at the point of use corresponding to the type parameters of the
2124+
trait of the same name. `{Self}` will be replaced with the type that is supposed
2125+
to implement the trait but doesn't. To use this, the `on_unimplemented` feature gate
2126+
must be enabled.
21202127

21212128
### Conditional compilation
21222129

@@ -2213,7 +2220,7 @@ mod m1 {
22132220
```
22142221

22152222
This example shows how one can use `allow` and `warn` to toggle a particular
2216-
check on and off.
2223+
check on and off:
22172224

22182225
```{.ignore}
22192226
#[warn(missing_docs)]
@@ -2235,7 +2242,7 @@ mod m2{
22352242
```
22362243

22372244
This example shows how one can use `forbid` to disallow uses of `allow` for
2238-
that lint check.
2245+
that lint check:
22392246

22402247
```{.ignore}
22412248
#[forbid(missing_docs)]
@@ -2318,9 +2325,9 @@ These language items are traits:
23182325
* `ord`
23192326
: Elements have a partial ordering.
23202327
* `deref`
2321-
: `*` can be applied, yielding a reference to another type
2328+
: `*` can be applied, yielding a reference to another type.
23222329
* `deref_mut`
2323-
: `*` can be applied, yielding a mutable reference to another type
2330+
: `*` can be applied, yielding a mutable reference to another type.
23242331

23252332
These are functions:
23262333

@@ -2341,7 +2348,7 @@ These are functions:
23412348
* `type_id`
23422349
: The type returned by the `type_id` intrinsic.
23432350
* `unsafe`
2344-
: A type whose contents can be mutated through an immutable reference
2351+
: A type whose contents can be mutated through an immutable reference.
23452352

23462353
#### Marker types
23472354

@@ -2350,11 +2357,11 @@ These types help drive the compiler's analysis
23502357
* `begin_unwind`
23512358
: ___Needs filling in___
23522359
* `no_copy_bound`
2353-
: This type does not implement "copy", even if eligible
2360+
: This type does not implement "copy", even if eligible.
23542361
* `no_send_bound`
2355-
: This type does not implement "send", even if eligible
2362+
: This type does not implement "send", even if eligible.
23562363
* `no_sync_bound`
2357-
: This type does not implement "sync", even if eligible
2364+
: This type does not implement "sync", even if eligible.
23582365
* `eh_personality`
23592366
: ___Needs filling in___
23602367
* `exchange_free`
@@ -2376,11 +2383,11 @@ These types help drive the compiler's analysis
23762383
* `iterator`
23772384
: ___Needs filling in___
23782385
* `contravariant_lifetime`
2379-
: The lifetime parameter should be considered contravariant
2386+
: The lifetime parameter should be considered contravariant.
23802387
* `covariant_lifetime`
2381-
: The lifetime parameter should be considered covariant
2388+
: The lifetime parameter should be considered covariant.
23822389
* `invariant_lifetime`
2383-
: The lifetime parameter should be considered invariant
2390+
: The lifetime parameter should be considered invariant.
23842391
* `malloc`
23852392
: Allocate memory on the managed heap.
23862393
* `owned_box`
@@ -2390,11 +2397,11 @@ These types help drive the compiler's analysis
23902397
* `start`
23912398
: ___Needs filling in___
23922399
* `contravariant_type`
2393-
: The type parameter should be considered contravariant
2400+
: The type parameter should be considered contravariant.
23942401
* `covariant_type`
2395-
: The type parameter should be considered covariant
2402+
: The type parameter should be considered covariant.
23962403
* `invariant_type`
2397-
: The type parameter should be considered invariant
2404+
: The type parameter should be considered invariant.
23982405
* `ty_desc`
23992406
: ___Needs filling in___
24002407

@@ -2921,13 +2928,13 @@ automatically dereferenced to make the field access possible.
29212928
```{.ebnf .gram}
29222929
array_expr : '[' "mut" ? vec_elems? ']' ;
29232930
2924-
array_elems : [expr [',' expr]*] | [expr ',' ".." expr] ;
2931+
array_elems : [expr [',' expr]*] | [expr ';' expr] ;
29252932
```
29262933

29272934
An [array](#array,-and-slice-types) _expression_ is written by enclosing zero
29282935
or more comma-separated expressions of uniform type in square brackets.
29292936

2930-
In the `[expr ',' ".." expr]` form, the expression after the `".."` must be a
2937+
In the `[expr ';' expr]` form, the expression after the `';'` must be a
29312938
constant expression that can be evaluated at compile time, such as a
29322939
[literal](#literals) or a [static item](#static-items).
29332940

@@ -3219,11 +3226,11 @@ the simplest and least-expensive form (analogous to a ```|| { }``` expression),
32193226
the lambda expression captures its environment by reference, effectively
32203227
borrowing pointers to all outer variables mentioned inside the function.
32213228
Alternately, the compiler may infer that a lambda expression should copy or
3222-
move values (depending on their type.) from the environment into the lambda
3229+
move values (depending on their type) from the environment into the lambda
32233230
expression's captured environment.
32243231

32253232
In this example, we define a function `ten_times` that takes a higher-order
3226-
function argument, and call it with a lambda expression as an argument.
3233+
function argument, and call it with a lambda expression as an argument:
32273234

32283235
```
32293236
fn ten_times<F>(f: F) where F: Fn(int) {
@@ -3661,14 +3668,14 @@ within an object along with one byte past the end.
36613668
The types `char` and `str` hold textual data.
36623669

36633670
A value of type `char` is a [Unicode scalar value](
3664-
http://www.unicode.org/glossary/#unicode_scalar_value) (ie. a code point that
3671+
http://www.unicode.org/glossary/#unicode_scalar_value) (i.e. a code point that
36653672
is not a surrogate), represented as a 32-bit unsigned word in the 0x0000 to
36663673
0xD7FF or 0xE000 to 0x10FFFF range. A `[char]` array is effectively an UCS-4 /
36673674
UTF-32 string.
36683675

36693676
A value of type `str` is a Unicode string, represented as an array of 8-bit
36703677
unsigned bytes holding a sequence of UTF-8 codepoints. Since `str` is of
3671-
unknown size, it is not a _first class_ type, but can only be instantiated
3678+
unknown size, it is not a _first-class_ type, but can only be instantiated
36723679
through a pointer type, such as `&str` or `String`.
36733680

36743681
### Tuple types
@@ -3698,7 +3705,7 @@ assert!(b != "world");
36983705

36993706
Rust has two different types for a list of items:
37003707

3701-
* `[T ..N]`, an 'array'
3708+
* `[T; N]`, an 'array'.
37023709
* `&[T]`, a 'slice'.
37033710

37043711
An array has a fixed size, and can be allocated on either the stack or the
@@ -3710,9 +3717,9 @@ to, it borrows it.
37103717
An example of each kind:
37113718

37123719
```{rust}
3713-
let vec: Vec<int> = vec![1, 2, 3];
3714-
let arr: [int; 3] = [1, 2, 3];
3715-
let s: &[int] = vec.as_slice();
3720+
let vec: Vec<i32> = vec![1, 2, 3];
3721+
let arr: [i32; 3] = [1, 2, 3];
3722+
let s: &[i32] = vec.as_slice();
37163723
```
37173724

37183725
As you can see, the `vec!` macro allows you to create a `Vec<T>` easily. The
@@ -3798,7 +3805,7 @@ enum List<T> {
37983805
Cons(T, Box<List<T>>)
37993806
}
38003807
3801-
let a: List<int> = List::Cons(7, Box::new(List::Cons(13, Box::new(List::Nil))));
3808+
let a: List<i32> = List::Cons(7, Box::new(List::Cons(13, Box::new(List::Nil))));
38023809
```
38033810

38043811
### Pointer types

branches/batch/src/doc/trpl/arrays-vectors-and-slices.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,6 @@ backed by arrays. Slices have type `&[T]`, which we'll talk about when we cover
9494
generics.
9595

9696
We have now learned all of the most basic Rust concepts. We're ready to start
97-
building our guessing game, we just need to know one last thing: how to get
98-
input from the keyboard. You can't have a guessing game without the ability to
99-
guess!
97+
building ourselves a guessing game, we just need to know one last thing: how to
98+
get input from the keyboard. You can't have a guessing game without the ability
99+
to guess!

branches/batch/src/doc/trpl/closures.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -110,25 +110,27 @@ passing two variables: one is an i32, and one is a function."
110110
Next, let's look at how `twice` is defined:
111111

112112
```{rust,ignore}
113-
fn twice(x: i32, f: |i32| -> i32) -> i32 {
113+
fn twice<F: Fn(i32) -> i32>(x: i32, f: F) -> i32 {
114114
```
115115

116116
`twice` takes two arguments, `x` and `f`. That's why we called it with two
117117
arguments. `x` is an `i32`, we've done that a ton of times. `f` is a function,
118-
though, and that function takes an `i32` and returns an `i32`. Notice
119-
how the `|i32| -> i32` syntax looks a lot like our definition of `square`
120-
above, if we added the return type in:
121-
122-
```{rust}
123-
let square = |&: x: i32| -> i32 { x * x };
124-
// |i32| -> i32
125-
```
126-
127-
This function takes an `i32` and returns an `i32`.
118+
though, and that function takes an `i32` and returns an `i32`. This is
119+
what the requirement `Fn(i32) -> i32` for the type parameter `F` says.
120+
You might ask yourself: why do we need to introduce a type parameter here?
121+
That is because in Rust each closure has its own unique type.
122+
So, not only do closures with different signatures have different types,
123+
but different closures with the *same* signature have *different* types!
124+
You can think of it this way: the behaviour of a closure is part of its type.
125+
And since we want to support many different closures that all take
126+
an `i32` and return an `i32` we introduced a type parameter that is able
127+
to represent all these closures.
128128

129129
This is the most complicated function signature we've seen yet! Give it a read
130130
a few times until you can see how it works. It takes a teeny bit of practice, and
131-
then it's easy.
131+
then it's easy. The good news is that this kind of passing a closure around
132+
can be very efficient. With all the type information available at compile-time
133+
the compiler can do wonders.
132134

133135
Finally, `twice` returns an `i32` as well.
134136

branches/batch/src/doc/trpl/comments.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ fn hello(name: &str) {
4040
```
4141

4242
When writing doc comments, adding sections for any arguments, return values,
43-
and providing some examples of usage is very, very helpful.
43+
and providing some examples of usage is very, very helpful. Don't worry about
44+
the `&str`, we'll get to it soon.
4445

4546
You can use the [`rustdoc`](../rustdoc.html) tool to generate HTML documentation
4647
from these doc comments.

branches/batch/src/doc/trpl/compound-data-types.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ let x: (i32, &str) = (1, "hello");
2323
As you can see, the type of a tuple looks just like the tuple, but with each
2424
position having a type name rather than the value. Careful readers will also
2525
note that tuples are heterogeneous: we have an `i32` and a `&str` in this tuple.
26-
You haven't seen `&str` as a type before, and we'll discuss the details of
27-
strings later. In systems programming languages, strings are a bit more complex
28-
than in other languages. For now, just read `&str` as a *string slice*, and
29-
we'll learn more soon.
26+
You have briefly seen `&str` used as a type before, and we'll discuss the
27+
details of strings later. In systems programming languages, strings are a bit
28+
more complex than in other languages. For now, just read `&str` as a *string
29+
slice*, and we'll learn more soon.
3030

3131
You can access the fields in a tuple through a *destructuring let*. Here's
3232
an example:

branches/batch/src/doc/trpl/crates-and-modules.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ fn goodbye() -> String {
256256
}
257257
```
258258

259-
(This is "Sayoonara", if you're curious.)
259+
(This is "Sayōnara", if you're curious.)
260260

261261
Now that we have our some functionality in our crate, let's try to use it from
262262
another crate.
@@ -559,7 +559,7 @@ Also, note that we `pub use`d before we declared our `mod`s. Rust requires that
559559
This will build and run:
560560
561561
```bash
562-
$ cargo build
562+
$ cargo run
563563
Compiling phrases v0.0.1 (file:///home/you/projects/phrases)
564564
Running `target/phrases`
565565
Hello in English: Hello!

branches/batch/src/doc/trpl/error-handling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% Error Handling in Rust
22

3-
> The best-laid plans of mice and men
3+
> The best-laid plans of mice and men
44
> Often go awry
55
>
66
> "Tae a Moose", Robert Burns

branches/batch/src/doc/trpl/functions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ Unlike `let`, you _must_ declare the types of function arguments. This does
5959
not work:
6060

6161
```{ignore}
62-
fn print_number(x, y) {
62+
fn print_sum(x, y) {
6363
println!("x is: {}", x + y);
6464
}
6565
```
6666

6767
You get this error:
6868

6969
```text
70-
hello.rs:5:18: 5:19 error: expected `:` but found `,`
70+
hello.rs:5:18: 5:19 expected one of `!`, `:`, or `@`, found `)`
7171
hello.rs:5 fn print_number(x, y) {
7272
```
7373

0 commit comments

Comments
 (0)