Skip to content

Commit 2290db3

Browse files
committed
---
yaml --- r: 208607 b: refs/heads/snap-stage3 c: c23a9d4 h: refs/heads/master i: 208605: 98641b3 208603: 3a02df9 208599: 162c30e 208591: 259aa1d 208575: 354d459 v: v3
1 parent 58f911a commit 2290db3

File tree

185 files changed

+3667
-2628
lines changed

Some content is hidden

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

185 files changed

+3667
-2628
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 38a97becdf3e6a6157f6f7ec2d98ade8d8edc193
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 8cc9878f8d5d7581006d3af1fb3c6732b41c85a3
4+
refs/heads/snap-stage3: c23a9d42ea082830593a73d25821842baf9ccf33
55
refs/heads/try: 7b4ef47b7805a402d756fb8157101f64880a522f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# The Rust Programming Language
22

3-
This is a compiler for Rust, including standard libraries, tools and
4-
documentation. Rust is a systems programming language that is fast,
5-
memory safe and multithreaded, but does not employ a garbage collector
6-
or otherwise impose significant runtime overhead.
3+
Rust is a systems programming language that is fast, memory safe and
4+
multithreaded, but does not employ a garbage collector or otherwise
5+
impose significant runtime overhead.
6+
7+
This repo contains the code for `rustc`, the Rust compiler, as well
8+
as standard libraries, tools and documentation for Rust.
79

810
## Quick Start
911

branches/snap-stage3/configure

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ probe() {
106106
T=$(command -v $P 2>&1)
107107
if [ $? -eq 0 ]
108108
then
109-
VER0=$($P --version 2>/dev/null | head -1 \
110-
| sed -e 's/[^0-9]*\([vV]\?[0-9.]\+[^ ]*\).*/\1/' )
109+
VER0=$($P --version 2>/dev/null \
110+
| grep -o '[vV]\?[0-9][0-9.][a-z0-9.-]*' | head -1 )
111111
if [ $? -eq 0 -a "x${VER0}" != "x" ]
112112
then
113113
VER="($VER0)"
@@ -711,6 +711,20 @@ else
711711
probe_need CFG_GIT git
712712
fi
713713

714+
# Use `md5sum` on GNU platforms, or `md5 -q` on BSD
715+
probe CFG_MD5 md5
716+
probe CFG_MD5SUM md5sum
717+
if [ -n "$CFG_MD5" ]
718+
then
719+
CFG_HASH_COMMAND="$CFG_MD5 -q | head -c 8"
720+
elif [ -n "$CFG_MD5SUM" ]
721+
then
722+
CFG_HASH_COMMAND="$CFG_MD5SUM | head -c 8"
723+
else
724+
err 'could not find one of: md5 md5sum'
725+
fi
726+
putvar CFG_HASH_COMMAND
727+
714728
probe CFG_CLANG clang++
715729
probe CFG_CCACHE ccache
716730
probe CFG_GCC gcc

branches/snap-stage3/mk/main.mk

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@
1313
######################################################################
1414

1515
# The version number
16-
CFG_RELEASE_NUM=1.1.0
16+
CFG_RELEASE_NUM=1.2.0
1717

1818
# An optional number to put after the label, e.g. '.2' -> '-beta.2'
1919
# NB Make sure it starts with a dot to conform to semver pre-release
2020
# versions (section 9)
2121
CFG_PRERELEASE_VERSION=.1
2222

23-
CFG_FILENAME_EXTRA=4e7c5e5c
23+
# Append a version-dependent hash to each library, so we can install different
24+
# versions in the same place
25+
CFG_FILENAME_EXTRA=$(shell printf '%s' $(CFG_RELEASE) | $(CFG_HASH_COMMAND))
2426

2527
ifeq ($(CFG_RELEASE_CHANNEL),stable)
2628
# This is the normal semver version string, e.g. "0.12.0", "0.12.0-nightly"

branches/snap-stage3/src/doc/complement-design-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ feature.
7979
A nice replacement is the [lazy constructor macro][lcm] by [Marvin
8080
Löbel][kim].
8181

82-
[fqa]: https://mail.mozilla.org/pipermail/rust-dev/2013-April/003815.html
82+
[fqa]: http://yosefk.com/c++fqa/ctors.html#fqa-10.12
8383
[elp]: http://ericlippert.com/2013/02/06/static-constructors-part-one/
8484
[lcm]: https://gist.github.com/Kimundi/8782487
8585
[kim]: https://github.com/Kimundi

branches/snap-stage3/src/doc/reference.md

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,6 +1346,8 @@ vtable when the trait is used as a [trait object](#trait-objects).
13461346
Traits are implemented for specific types through separate
13471347
[implementations](#implementations).
13481348

1349+
Consider the following trait:
1350+
13491351
```
13501352
# type Surface = i32;
13511353
# type BoundingBox = i32;
@@ -1360,6 +1362,20 @@ This defines a trait with two methods. All values that have
13601362
`draw` and `bounding_box` methods called, using `value.bounding_box()`
13611363
[syntax](#method-call-expressions).
13621364

1365+
Traits can include default implementations of methods, as in:
1366+
1367+
```
1368+
trait Foo {
1369+
fn bar(&self);
1370+
1371+
fn baz(&self) { println!("We called baz."); }
1372+
}
1373+
```
1374+
1375+
Here the `baz` method has a default implementation, so types that implement
1376+
`Foo` need only implement `bar`. It is also possible for implementing types
1377+
to override a method that has a default implementation.
1378+
13631379
Type parameters can be specified for a trait to make it generic. These appear
13641380
after the trait name, using the same syntax used in [generic
13651381
functions](#generic-functions).
@@ -1372,6 +1388,35 @@ trait Seq<T> {
13721388
}
13731389
```
13741390

1391+
It is also possible to define associated types for a trait. Consider the
1392+
following example of a `Container` trait. Notice how the type is available
1393+
for use in the method signatures:
1394+
1395+
```
1396+
trait Container {
1397+
type E;
1398+
fn empty() -> Self;
1399+
fn insert(&mut self, Self::E);
1400+
}
1401+
```
1402+
1403+
In order for a type to implement this trait, it must not only provide
1404+
implementations for every method, but it must specify the type `E`. Here's
1405+
an implementation of `Container` for the standard library type `Vec`:
1406+
1407+
```
1408+
# trait Container {
1409+
# type E;
1410+
# fn empty() -> Self;
1411+
# fn insert(&mut self, Self::E);
1412+
# }
1413+
impl<T> Container for Vec<T> {
1414+
type E = T;
1415+
fn empty() -> Vec<T> { Vec::new() }
1416+
fn insert(&mut self, x: T) { self.push(x); }
1417+
}
1418+
```
1419+
13751420
Generic functions may use traits as _bounds_ on their type parameters. This
13761421
will have two effects: only types that have the trait may instantiate the
13771422
parameter, and within the generic function, the methods of the trait can be
@@ -3470,13 +3515,23 @@ more of the closure traits:
34703515

34713516
### Trait objects
34723517

3473-
Every trait item (see [traits](#traits)) defines a type with the same name as
3474-
the trait. This type is called the _trait object_ of the trait. Trait objects
3475-
permit "late binding" of methods, dispatched using _virtual method tables_
3476-
("vtables"). Whereas most calls to trait methods are "early bound" (statically
3477-
resolved) to specific implementations at compile time, a call to a method on an
3478-
trait objects is only resolved to a vtable entry at compile time. The actual
3479-
implementation for each vtable entry can vary on an object-by-object basis.
3518+
In Rust, a type like `&SomeTrait` or `Box<SomeTrait>` is called a _trait object_.
3519+
Each instance of a trait object includes:
3520+
3521+
- a pointer to an instance of a type `T` that implements `SomeTrait`
3522+
- a _virtual method table_, often just called a _vtable_, which contains, for
3523+
each method of `SomeTrait` that `T` implements, a pointer to `T`'s
3524+
implementation (i.e. a function pointer).
3525+
3526+
The purpose of trait objects is to permit "late binding" of methods. A call to
3527+
a method on a trait object is only resolved to a vtable entry at compile time.
3528+
The actual implementation for each vtable entry can vary on an object-by-object
3529+
basis.
3530+
3531+
Note that for a trait object to be instantiated, the trait must be
3532+
_object-safe_. Object safety rules are defined in [RFC 255].
3533+
3534+
[RFC 255]: https://github.com/rust-lang/rfcs/blob/master/text/0255-object-safety.md
34803535

34813536
Given a pointer-typed expression `E` of type `&T` or `Box<T>`, where `T`
34823537
implements trait `R`, casting `E` to the corresponding pointer type `&R` or

branches/snap-stage3/src/doc/trpl/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ data, we call the `clone()` method. In this example, `y` is no longer a referenc
175175
to the vector stored in `x`, but a copy of its first element, `"Hello"`. Now
176176
that we don’t have a reference, our `push()` works just fine.
177177

178-
[move]: move-semantics.html
178+
[move]: ownership.html#move-semantics
179179

180180
If we truly want a reference, we need the other option: ensure that our reference
181181
goes out of scope before we try to do the mutation. That looks like this:

branches/snap-stage3/src/doc/trpl/concurrency.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ and more cores, yet many programmers aren't prepared to fully utilize them.
66

77
Rust's memory safety features also apply to its concurrency story too. Even
88
concurrent Rust programs must be memory safe, having no data races. Rust's type
9-
system is up to the thread, and gives you powerful ways to reason about
9+
system is up to the task, and gives you powerful ways to reason about
1010
concurrent code at compile time.
1111

1212
Before we talk about the concurrency features that come with Rust, it's important

branches/snap-stage3/src/doc/trpl/const-and-static.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ static N: i32 = 5;
3131

3232
Unlike [`let`][let] bindings, you must annotate the type of a `static`.
3333

34-
[let]: variable-bindings.html
35-
3634
Statics live for the entire lifetime of a program, and therefore any
37-
reference stored in a constant has a [`static` lifetime][lifetimes]:
35+
reference stored in a constant has a [`'static` lifetime][lifetimes]:
3836

3937
```rust
4038
static NAME: &'static str = "Steve";

branches/snap-stage3/src/doc/trpl/dining-philosophers.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ a name is all we need. We choose the [`String`][string] type for the name,
7373
rather than `&str`. Generally speaking, working with a type which owns its
7474
data is easier than working with one that uses references.
7575

76+
[struct]: structs.html
77+
[string]: strings.html
78+
7679
Let’s continue:
7780

7881
```rust
@@ -393,7 +396,7 @@ let handles: Vec<_> = philosophers.into_iter().map(|p| {
393396
}).collect();
394397
```
395398

396-
While this is only five lines, they’re a dense four. Let’s break it down.
399+
While this is only five lines, they’re a dense five. Let’s break it down.
397400

398401
```rust,ignore
399402
let handles: Vec<_> =
@@ -450,7 +453,7 @@ which blocks execution until the thread has completed execution. This ensures
450453
that the threads complete their work before the program exits.
451454

452455
If you run this program, you’ll see that the philosophers eat out of order!
453-
We have mult-threading!
456+
We have multi-threading!
454457

455458
```text
456459
Gilles Deleuze is eating.

branches/snap-stage3/src/doc/trpl/enums.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ fn process_color_change(msg: Message) {
5555
}
5656
```
5757

58-
Both variants are named `Digit`, but since they’re scoped to the `enum` name
59-
there's no ambiguity.
60-
6158
Not supporting these operations may seem rather limiting, but it’s a limitation
6259
which we can overcome. There are two ways: by implementing equality ourselves,
6360
or by pattern matching variants with [`match`][match] expressions, which you’ll
@@ -66,3 +63,4 @@ equality yet, but we’ll find out in the [`traits`][traits] section.
6663

6764
[match]: match.html
6865
[if-let]: if-let.html
66+
[traits]: traits.html

branches/snap-stage3/src/doc/trpl/error-handling.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ match version {
181181
This function makes use of an enum, `ParseError`, to enumerate the various
182182
errors that can occur.
183183

184+
The [`Debug`](../std/fmt/trait.Debug.html) trait is what lets us print the enum value using the `{:?}` format operation.
185+
184186
# Non-recoverable errors with `panic!`
185187

186188
In the case of an error that is unexpected and not recoverable, the `panic!`

branches/snap-stage3/src/doc/trpl/guessing-game.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Check out the generated `Cargo.toml`:
2727
[package]
2828

2929
name = "guessing_game"
30-
version = "0.0.1"
30+
version = "0.1.0"
3131
authors = ["Your Name <[email protected]>"]
3232
```
3333

@@ -46,7 +46,7 @@ Let’s try compiling what Cargo gave us:
4646

4747
```{bash}
4848
$ cargo build
49-
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
49+
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
5050
```
5151

5252
Excellent! Open up your `src/main.rs` again. We’ll be writing all of
@@ -58,7 +58,7 @@ Try it out:
5858

5959
```bash
6060
$ cargo run
61-
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
61+
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
6262
Running `target/debug/guessing_game`
6363
Hello, world!
6464
```
@@ -213,12 +213,12 @@ The next part will use this handle to get input from the user:
213213
```
214214

215215
Here, we call the [`read_line()`][read_line] method on our handle.
216-
[Method][method]s are like associated functions, but are only available on a
216+
[Methods][method] are like associated functions, but are only available on a
217217
particular instance of a type, rather than the type itself. We’re also passing
218218
one argument to `read_line()`: `&mut guess`.
219219

220220
[read_line]: ../std/io/struct.Stdin.html#method.read_line
221-
[method]: methods.html
221+
[method]: method-syntax.html
222222

223223
Remember how we bound `guess` above? We said it was mutable. However,
224224
`read_line` doesn’t take a `String` as an argument: it takes a `&mut String`.
@@ -727,7 +727,7 @@ Let’s try our program out!
727727
728728
```bash
729729
$ cargo run
730-
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
730+
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
731731
Running `target/guessing_game`
732732
Guess the number!
733733
The secret number is: 58
@@ -792,7 +792,7 @@ and quit. Observe:
792792
793793
```bash
794794
$ cargo run
795-
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
795+
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
796796
Running `target/guessing_game`
797797
Guess the number!
798798
The secret number is: 59
@@ -929,7 +929,7 @@ Now we should be good! Let’s try:
929929
930930
```bash
931931
$ cargo run
932-
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
932+
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
933933
Running `target/guessing_game`
934934
Guess the number!
935935
The secret number is: 61

branches/snap-stage3/src/doc/trpl/iterators.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ loop is just a handy way to write this `loop`/`match`/`break` construct.
4242
`for` loops aren't the only thing that uses iterators, however. Writing your
4343
own iterator involves implementing the `Iterator` trait. While doing that is
4444
outside of the scope of this guide, Rust provides a number of useful iterators
45-
to accomplish various threads. Before we talk about those, we should talk about a
45+
to accomplish various tasks. Before we talk about those, we should talk about a
4646
Rust anti-pattern. And that's using ranges like this.
4747

4848
Yes, we just talked about how ranges are cool. But ranges are also very

branches/snap-stage3/src/doc/trpl/match.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@ Unlike the previous uses of `match`, you can’t use the normal `if`
9797
statement to do this. You can use the [`if let`][if-let] statement,
9898
which can be seen as an abbreviated form of `match`.
9999

100-
[if-let][if-let.html]
100+
[if-let]: if-let.html

branches/snap-stage3/src/doc/trpl/method-syntax.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ fn main() {
156156

157157
This ‘associated function’ builds a new `Circle` for us. Note that associated
158158
functions are called with the `Struct::function()` syntax, rather than the
159-
`ref.method()` syntax. Some other langauges call associated functions ‘static
159+
`ref.method()` syntax. Some other languages call associated functions ‘static
160160
methods’.
161161

162162
# Builder Pattern

branches/snap-stage3/src/doc/trpl/mutability.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ let y = &mut x;
3535

3636
`y` is an immutable binding to a mutable reference, which means that you can’t
3737
bind `y` to something else (`y = &mut z`), but you can mutate the thing that’s
38-
bound to `y`. (`*y = 5`) A subtle distinction.
38+
bound to `y` (`*y = 5`). A subtle distinction.
3939

4040
Of course, if you need both:
4141

branches/snap-stage3/src/doc/trpl/nightly-rust.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ $ sh rustup.sh --channel=nightly
2626
If you're on Windows, please download either the [32-bit installer][win32] or
2727
the [64-bit installer][win64] and run it.
2828

29-
[win32]: https://static.rust-lang.org/dist/rust-1.0.0-beta-i686-pc-windows-gnu.msi
30-
[win64]: https://static.rust-lang.org/dist/rust-1.0.0-beta-x86_64-pc-windows-gnu.msi
29+
[win32]: https://static.rust-lang.org/dist/rust-nightly-i686-pc-windows-gnu.msi
30+
[win64]: https://static.rust-lang.org/dist/rust-nightly-x86_64-pc-windows-gnu.msi
3131

3232
## Uninstalling
3333

branches/snap-stage3/src/doc/trpl/patterns.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ match x {
6666
}
6767
```
6868

69-
This prints `something else`
69+
This prints `something else`.
7070

7171
# Bindings
7272

@@ -152,7 +152,7 @@ match x {
152152
}
153153
```
154154

155-
This prints `Got an int!`
155+
This prints `Got an int!`.
156156

157157
# ref and ref mut
158158

0 commit comments

Comments
 (0)