Skip to content

Commit 6a74106

Browse files
committed
---
yaml --- r: 130263 b: refs/heads/auto c: 2e38581 h: refs/heads/master i: 130261: 366ea02 130259: bdd8805 130255: 9271549 v: v3
1 parent eff886d commit 6a74106

File tree

113 files changed

+1196
-1136
lines changed

Some content is hidden

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

113 files changed

+1196
-1136
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 9374d50c30539811216d81ef61d17712de31ed9e
16+
refs/heads/auto: 2e385817926f6f914fbff482aab3a8b627e7feee
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/doc/complement-lang-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ We want to maintain the option to parametrize at runtime. We may eventually chan
8383

8484
## Why aren't values type-parametric? Why only items?
8585

86-
Doing so would make type inference much more complex, and require the implementation strategy of runtime parametrization.
86+
Doing so would make type inference much more complex, and require the implementation strategy of runtime parameterization.
8787

8888
## Why are enumerations nominal and closed?
8989

branches/auto/src/doc/guide-ffi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,8 @@ the `libc` module, and Rust links against `libc` and `libm` by default.
528528
# The "nullable pointer optimization"
529529
530530
Certain types are defined to not be `null`. This includes references (`&T`,
531-
`&mut T`), owning pointers (`~T`), and function pointers (`extern "abi"
532-
fn()`). When interfacing with C, pointers that might be null are often used.
531+
`&mut T`), boxes (`Box<T>`), and function pointers (`extern "abi" fn()`).
532+
When interfacing with C, pointers that might be null are often used.
533533
As a special case, a generic `enum` that contains exactly two variants, one of
534534
which contains no data and the other containing a single field, is eligible
535535
for the "nullable pointer optimization". When such an enum is instantiated

branches/auto/src/doc/guide-pointers.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,31 @@ This part is coming soon.
729729

730730
This part is coming soon.
731731

732+
# Patterns and `ref`
733+
734+
When you're trying to match something that's stored in a pointer, there may be
735+
a situation where matching directly isn't the best option available. Let's see
736+
how to properly handle this:
737+
738+
```{rust,ignore}
739+
fn possibly_print(x: &Option<String>) {
740+
match *x {
741+
// BAD: cannot move out of a `&`
742+
Some(s) => println!("{}", s)
743+
744+
// GOOD: instead take a reference into the memory of the `Option`
745+
Some(ref s) => println!("{}", *s),
746+
None => {}
747+
}
748+
}
749+
```
750+
751+
The `ref s` here means that `s` will be of type `&String`, rather than type
752+
`String`.
753+
754+
This is important when the type you're trying to get access to has a destructor
755+
and you don't want to move it, you just want a reference to it.
756+
732757
# Cheat Sheet
733758

734759
Here's a quick rundown of Rust's pointer types:

branches/auto/src/doc/guide.md

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ $ mv hello_world.rs src/hello_world.rs
297297
```
298298

299299
Cargo expects your source files to live inside a `src` directory. That leaves
300-
the top level for other things, like READMEs, licence information, and anything
300+
the top level for other things, like READMEs, license information, and anything
301301
not related to your code. Cargo helps us keep our projects nice and tidy. A
302302
place for everything, and everything in its place.
303303

@@ -315,7 +315,7 @@ Put this inside:
315315
[package]
316316
317317
name = "hello_world"
318-
version = "0.1.0"
318+
version = "0.0.1"
319319
authors = [ "Your name <[email protected]>" ]
320320
321321
[[bin]]
@@ -630,7 +630,7 @@ In Rust, however, using `let` to introduce a binding is _not_ an expression. The
630630
following will produce a compile-time error:
631631

632632
```{ignore}
633-
let x = (let y = 5i); // found `let` in ident position
633+
let x = (let y = 5i); // expected identifier, found keyword `let`
634634
```
635635

636636
The compiler is telling us here that it was expecting to see the beginning of
@@ -1743,7 +1743,7 @@ fn main() {
17431743
}
17441744
```
17451745

1746-
Sometimes, this makes things more readable. Sometimes, less. Use your judgement
1746+
Sometimes, this makes things more readable. Sometimes, less. Use your judgment
17471747
here.
17481748

17491749
That's all you need to get basic input from the standard input! It's not too
@@ -1808,12 +1808,12 @@ our code in this file. We'll talk about multiple-file projects later on in the
18081808
guide.
18091809

18101810
Before we move on, let me show you one more Cargo command: `run`. `cargo run`
1811-
is kind of like `cargo build`, but it also then runs the produced exectuable.
1811+
is kind of like `cargo build`, but it also then runs the produced executable.
18121812
Try it out:
18131813

18141814
```{notrust,ignore}
18151815
$ cargo run
1816-
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
1816+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
18171817
Running `target/guessing_game`
18181818
Hello, world!
18191819
```
@@ -1959,7 +1959,7 @@ Try running our new program a few times:
19591959

19601960
```{notrust,ignore}
19611961
$ cargo run
1962-
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
1962+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
19631963
Running `target/guessing_game`
19641964
Guess the number!
19651965
The secret number is: 7
@@ -2012,7 +2012,7 @@ And trying it out:
20122012

20132013
```{notrust,ignore}
20142014
$ cargo run
2015-
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
2015+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
20162016
Running `target/guessing_game`
20172017
Guess the number!
20182018
The secret number is: 57
@@ -2283,7 +2283,7 @@ print an error message and return. Let's give this a shot:
22832283

22842284
```{notrust,ignore}
22852285
$ cargo run
2286-
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
2286+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
22872287
Running `target/guessing_game`
22882288
Guess the number!
22892289
The secret number is: 17
@@ -2348,7 +2348,7 @@ Let's try it!
23482348

23492349
```{notrust,ignore}
23502350
$ cargo run
2351-
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
2351+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
23522352
Running `target/guessing_game`
23532353
Guess the number!
23542354
The secret number is: 58
@@ -2425,7 +2425,7 @@ that `return`? If we give a non-number answer, we'll `return` and quit. Observe:
24252425

24262426
```{notrust,ignore}
24272427
$ cargo run
2428-
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
2428+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
24292429
Running `target/guessing_game`
24302430
Guess the number!
24312431
The secret number is: 59
@@ -2557,7 +2557,7 @@ Now we should be good! Let's try:
25572557

25582558
```{notrust,ignore}
25592559
$ cargo run
2560-
Compiling guessing_game v0.1.0 (file:///home/you/projects/guessing_game)
2560+
Compiling guessing_game v0.0.1 (file:///home/you/projects/guessing_game)
25612561
Running `target/guessing_game`
25622562
Guess the number!
25632563
The secret number is: 61
@@ -2659,7 +2659,7 @@ modules, which can contain other modules, as deeply as you'd like.
26592659
Note that we haven't mentioned anything about files yet. Rust does not impose a
26602660
particular relationship between your filesystem structure and your module
26612661
structure. That said, there is a conventional approach to how Rust looks for
2662-
modules on the file system, but it's also overrideable.
2662+
modules on the file system, but it's also overridable.
26632663

26642664
Enough talk, let's build something! Let's make a new project called `modules`.
26652665

@@ -2670,10 +2670,10 @@ $ cargo new modules --bin
26702670

26712671
Let's double check our work by compiling:
26722672

2673-
```{bash,ignore}
2674-
$ cargo build
2673+
```{bash,notrust}
2674+
$ cargo run
26752675
Compiling modules v0.0.1 (file:///home/you/projects/modules)
2676-
$ ./target/modules
2676+
Running `target/modules`
26772677
Hello, world!
26782678
```
26792679

@@ -3011,7 +3011,7 @@ markers.
30113011
Rust provides six attributes to indicate the stability level of various
30123012
parts of your library. The six levels are:
30133013

3014-
* deprecated: this item should no longer be used. No guarantee of backwards
3014+
* deprecated: This item should no longer be used. No guarantee of backwards
30153015
compatibility.
30163016
* experimental: This item was only recently introduced or is otherwise in a
30173017
state of flux. It may change significantly, or even be removed. No guarantee
@@ -3300,7 +3300,7 @@ To learn more, run the command again with --verbose.
33003300

33013301
Rust can't find this function. That makes sense, as we didn't write it yet!
33023302

3303-
In order to share this codes with our tests, we'll need to make a library crate.
3303+
In order to share this code with our tests, we'll need to make a library crate.
33043304
This is also just good software design: as we mentioned before, it's a good idea
33053305
to put most of your functionality into a library crate, and have your executable
33063306
crate use that library. This allows for code re-use.
@@ -3511,7 +3511,7 @@ exporting the name again, somewhere else.
35113511

35123512
We've now covered the basics of testing. Rust's tools are primitive, but they
35133513
work well in the simple cases. There are some Rustaceans working on building
3514-
more complicated frameworks on top of all of this, but thery're just starting
3514+
more complicated frameworks on top of all of this, but they're just starting
35153515
out.
35163516

35173517
# Pointers
@@ -3668,15 +3668,20 @@ because it's easy. And if you need precise control over when something is
36683668
deallocated, leaving it up to your runtime can make this difficult.
36693669

36703670
Rust chooses a different path, and that path is called **ownership**. Any
3671-
binding that creates a resource is the **owner** of that resource. Being an
3672-
owner gives you three privileges, with two restrictions:
3671+
binding that creates a resource is the **owner** of that resource.
3672+
3673+
Being an owner affords you some privileges:
36733674

36743675
1. You control when that resource is deallocated.
36753676
2. You may lend that resource, immutably, to as many borrowers as you'd like.
3676-
3. You may lend that resource, mutably, to a single borrower. **BUT**
3677-
4. Once you've done so, you may not also lend it out otherwise, mutably or
3678-
immutably.
3679-
5. You may not lend it out mutably if you're currently lending it to someone.
3677+
3. You may lend that resource, mutably, to a single borrower.
3678+
3679+
But it also comes with some restrictions:
3680+
3681+
1. If someone is borrowing your resource (either mutably or immutably), you may
3682+
not mutate the resource or mutably lend it to someone.
3683+
2. If someone is mutably borrowing your resource, you may not lend it out at
3684+
all (mutably or immutably) or access it in any way.
36803685

36813686
What's up with all this 'lending' and 'borrowing'? When you allocate memory,
36823687
you get a pointer to that memory. This pointer allows you to manipulate said
@@ -4063,7 +4068,7 @@ match x {
40634068
}
40644069
```
40654070

4066-
If you have a struct, you can desugar it inside of a pattern:
4071+
If you have a struct, you can destructure it inside of a pattern:
40674072

40684073
```{rust}
40694074
struct Point {
@@ -4223,7 +4228,7 @@ don't need to declare one. This is different from named functions, which
42234228
default to returning unit (`()`).
42244229

42254230
There's one big difference between a closure and named functions, and it's in
4226-
the name: a function "closes over its environment." What's that mean? It means
4231+
the name: a closure "closes over its environment." What's that mean? It means
42274232
this:
42284233

42294234
```{rust}
@@ -5494,7 +5499,7 @@ fn main() {
54945499

54955500
Whew! This isn't too terrible. You can see that we still `let x = 5i`,
54965501
but then things get a little bit hairy. Three more bindings get set: a
5497-
static format string, an argument vector, and the aruments. We then
5502+
static format string, an argument vector, and the arguments. We then
54985503
invoke the `println_args` function with the generated arguments.
54995504

55005505
This is the code (well, the full version) that Rust actually compiles. You can
@@ -5510,7 +5515,7 @@ Guide can help you if you want to write your own.
55105515

55115516
# Unsafe
55125517

5513-
Finally, there's one more concept that you should be aware in Rust: `unsafe`.
5518+
Finally, there's one more Rust concept that you should be aware of: `unsafe`.
55145519
There are two circumstances where Rust's safety provisions don't work well.
55155520
The first is when interfacing with C code, and the second is when building
55165521
certain kinds of abstractions.

branches/auto/src/doc/rust.md

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,7 @@ On `struct`s:
19541954

19551955
- `repr` - specifies the representation to use for this struct. Takes a list
19561956
of options. The currently accepted ones are `C` and `packed`, which may be
1957-
combined. `C` will use a C ABI comptible struct layout, and `packed` will
1957+
combined. `C` will use a C ABI compatible struct layout, and `packed` will
19581958
remove any padding between fields (note that this is very fragile and may
19591959
break platforms which require aligned access).
19601960

@@ -2215,14 +2215,14 @@ These types help drive the compiler's analysis
22152215

22162216
* `begin_unwind`
22172217
: ___Needs filling in___
2218+
* `managed_bound`
2219+
: This type implements "managed"
22182220
* `no_copy_bound`
22192221
: This type does not implement "copy", even if eligible
22202222
* `no_send_bound`
22212223
: This type does not implement "send", even if eligible
2222-
* `no_sync_bound`
2223-
: This type does not implement "sync", even if eligible
2224-
* `managed_bound`
2225-
: This type implements "managed"
2224+
* `no_share_bound`
2225+
: This type does not implement "share", even if eligible
22262226
* `eh_personality`
22272227
: ___Needs filling in___
22282228
* `exchange_free`
@@ -2367,7 +2367,7 @@ One can indicate the stability of an API using the following attributes:
23672367
These levels are directly inspired by
23682368
[Node.js' "stability index"](http://nodejs.org/api/documentation.html).
23692369

2370-
Stability levels are inherited, so an items's stability attribute is the
2370+
Stability levels are inherited, so an item's stability attribute is the
23712371
default stability for everything nested underneath it.
23722372

23732373
There are lints for disallowing items marked with certain levels: `deprecated`,
@@ -2444,7 +2444,7 @@ The currently implemented features of the reference compiler are:
24442444

24452445
* `concat_idents` - Allows use of the `concat_idents` macro, which is in many
24462446
ways insufficient for concatenating identifiers, and may
2447-
be removed entirely for something more wholsome.
2447+
be removed entirely for something more wholesome.
24482448

24492449
* `default_type_params` - Allows use of default type parameters. The future of
24502450
this feature is uncertain.
@@ -3604,7 +3604,7 @@ of the type.[^structtype]
36043604

36053605
New instances of a `struct` can be constructed with a [struct expression](#structure-expressions).
36063606

3607-
The memory layout of a `struct` is undefined by default to allow for compiler optimziations like
3607+
The memory layout of a `struct` is undefined by default to allow for compiler optimizations like
36083608
field reordering, but it can be fixed with the `#[repr(...)]` attribute.
36093609
In either case, fields may be given in any order in a corresponding struct *expression*;
36103610
the resulting `struct` value will always have the same memory layout.
@@ -3668,32 +3668,17 @@ let a: List<int> = Cons(7, box Cons(13, box Nil));
36683668

36693669
All pointers in Rust are explicit first-class values.
36703670
They can be copied, stored into data structures, and returned from functions.
3671-
There are four varieties of pointer in Rust:
3672-
3673-
* Owning pointers (`Box`)
3674-
: These point to owned heap allocations (or "boxes") in the shared, inter-task heap.
3675-
Each owned box has a single owning pointer; pointer and pointee retain a 1:1 relationship at all times.
3676-
Owning pointers are written `Box<content>`,
3677-
for example `Box<int>` means an owning pointer to an owned box containing an integer.
3678-
Copying an owned box is a "deep" operation:
3679-
it involves allocating a new owned box and copying the contents of the old box into the new box.
3680-
Releasing an owning pointer immediately releases its corresponding owned box.
3671+
There are two varieties of pointer in Rust:
36813672

36823673
* References (`&`)
36833674
: These point to memory _owned by some other value_.
3684-
References arise by (automatic) conversion from owning pointers, managed pointers,
3685-
or by applying the borrowing operator `&` to some other value,
3686-
including [lvalues, rvalues or temporaries](#lvalues,-rvalues-and-temporaries).
3687-
A borrow expression is written `&content`.
3688-
3689-
A reference type is written `&'f type` for some lifetime-variable `f`,
3690-
or just `&type` when the lifetime can be elided;
3691-
for example `&int` means a reference to an integer.
3675+
A reference type is written `&type` for some lifetime-variable `f`,
3676+
or just `&'a type` when you need an explicit lifetime.
36923677
Copying a reference is a "shallow" operation:
36933678
it involves only copying the pointer itself.
36943679
Releasing a reference typically has no effect on the value it points to,
3695-
with the exception of temporary values,
3696-
which are released when the last reference to them is released.
3680+
with the exception of temporary values, which are released when the last
3681+
reference to them is released.
36973682

36983683
* Raw pointers (`*`)
36993684
: Raw pointers are pointers without safety or liveness guarantees.
@@ -3706,6 +3691,9 @@ There are four varieties of pointer in Rust:
37063691
they exist to support interoperability with foreign code,
37073692
and writing performance-critical or low-level functions.
37083693

3694+
The standard library contains addtional 'smart pointer' types beyond references
3695+
and raw pointers.
3696+
37093697
### Function types
37103698

37113699
The function type constructor `fn` forms new function types.
@@ -4214,7 +4202,7 @@ be ignored in favor of only building the artifacts specified by command line.
42144202
purpose of this output type is to create a static library containing all of
42154203
the local crate's code along with all upstream dependencies. The static
42164204
library is actually a `*.a` archive on linux and osx and a `*.lib` file on
4217-
windows. This format is recommended for use in situtations such as linking
4205+
windows. This format is recommended for use in situations such as linking
42184206
Rust code into an existing non-Rust application because it will not have
42194207
dynamic dependencies on other Rust code.
42204208

branches/auto/src/liballoc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//!
1313
//! This is the lowest level library through which allocation in Rust can be
1414
//! performed where the allocation is assumed to succeed. This library will
15-
//! trigger a task failure when allocation fails.
15+
//! abort the process when allocation fails.
1616
//!
1717
//! This library, like libcore, is not intended for general usage, but rather as
1818
//! a building block of other libraries. The types and interfaces in this

0 commit comments

Comments
 (0)