Skip to content

Commit e96ab74

Browse files
committed
---
yaml --- r: 195375 b: refs/heads/snap-stage3 c: 6e8693b h: refs/heads/master i: 195373: 17078c6 195371: fa9c2a4 195367: 214d7ee 195359: 8e2d83f v: v3
1 parent 9e447a2 commit e96ab74

File tree

125 files changed

+1324
-1302
lines changed

Some content is hidden

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

125 files changed

+1324
-1302
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: 14192d6df5cc714e5c9a3ca70b08f2514d977be2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 470996a7499c2182eedecbed6d8d40026be3d566
4+
refs/heads/snap-stage3: 6e8693b297a841e8ada1828820136c850b793158
55
refs/heads/try: 961e0358e1a5c0faaef606e31e9965742c1643bf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/AUTHORS.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ Peter Schuller <[email protected]>
606606
Peter Williams <[email protected]>
607607
Peter Zotov <[email protected]>
608608
Petter Remen <[email protected]>
609-
Phil Dawes <[email protected]>
609+
Phil Dawes <[email protected]>
610610
Phil Ruffwind <[email protected]>
611611
Philip Munksgaard <[email protected]>
612612
Philipp Brüschweiler <[email protected]>

branches/snap-stage3/configure

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ case $CFG_OSTYPE in
404404
CFG_OSTYPE=pc-windows-gnu
405405
;;
406406

407-
# Thad's Cygwin identifiers below
407+
# Thad's Cygwin identifers below
408408

409409
# Vista 32 bit
410410
CYGWIN_NT-6.0)
@@ -526,8 +526,7 @@ VAL_OPTIONS=""
526526
opt valgrind 0 "run tests with valgrind (memcheck by default)"
527527
opt helgrind 0 "run tests with helgrind instead of memcheck"
528528
opt valgrind-rpass 1 "run rpass-valgrind tests with valgrind"
529-
opt docs 1 "build standard library documentation"
530-
opt compiler-docs 0 "build compiler documentation"
529+
opt docs 1 "build documentation"
531530
opt optimize 1 "build optimized rust code"
532531
opt optimize-cxx 1 "build optimized C++ code"
533532
opt optimize-llvm 1 "build optimized LLVM"

branches/snap-stage3/mk/crates.mk

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -122,29 +122,17 @@ ONLY_RLIB_rustc_bitflags := 1
122122
# You should not need to edit below this line
123123
################################################################################
124124

125-
# On channels where the only usable crate is std, only build documentation for
126-
# std. This keeps distributions small and doesn't clutter up the API docs with
127-
# confusing internal details from the crates behind the facade.
128-
129-
ifeq ($(CFG_RELEASE_CHANNEL),stable)
130-
DOC_CRATES := std
131-
else
132-
ifeq ($(CFG_RELEASE_CHANNEL),beta)
133-
DOC_CRATES := std
134-
else
135125
DOC_CRATES := $(filter-out rustc, \
136-
$(filter-out rustc_trans, \
137-
$(filter-out rustc_typeck, \
138-
$(filter-out rustc_borrowck, \
139-
$(filter-out rustc_resolve, \
140-
$(filter-out rustc_driver, \
141-
$(filter-out rustc_privacy, \
142-
$(filter-out rustc_lint, \
143-
$(filter-out log, \
144-
$(filter-out getopts, \
145-
$(filter-out syntax, $(CRATES))))))))))))
146-
endif
147-
endif
126+
$(filter-out rustc_trans, \
127+
$(filter-out rustc_typeck, \
128+
$(filter-out rustc_borrowck, \
129+
$(filter-out rustc_resolve, \
130+
$(filter-out rustc_driver, \
131+
$(filter-out rustc_privacy, \
132+
$(filter-out rustc_lint, \
133+
$(filter-out log, \
134+
$(filter-out getopts, \
135+
$(filter-out syntax, $(CRATES))))))))))))
148136
COMPILER_DOC_CRATES := rustc rustc_trans rustc_borrowck rustc_resolve \
149137
rustc_typeck rustc_driver syntax rustc_privacy \
150138
rustc_lint

branches/snap-stage3/mk/docs.mk

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,7 @@ doc/$(1)/index.html: $$(LIB_DOC_DEP_$(1)) doc/$(1)/
259259
endef
260260

261261
$(foreach crate,$(DOC_CRATES),$(eval $(call DEF_LIB_DOC,$(crate),DOC_TARGETS)))
262-
263-
ifdef CFG_COMPILER_DOCS
264-
$(foreach crate,$(COMPILER_DOC_CRATES),$(eval $(call DEF_LIB_DOC,$(crate),COMPILER_DOC_TARGETS)))
265-
endif
262+
$(foreach crate,$(COMPILER_DOC_CRATES),$(eval $(call DEF_LIB_DOC,$(crate),COMPILER_DOC_TARGETS)))
266263

267264
ifdef CFG_DISABLE_DOCS
268265
$(info cfg: disabling doc build (CFG_DISABLE_DOCS))

branches/snap-stage3/mk/platform.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ define CFG_MAKE_TOOLCHAIN
179179

180180
ifeq ($$(findstring $(HOST_$(1)),arm aarch64 mips mipsel powerpc),)
181181

182-
# On Bitrig, we need the relocation model to be PIC for everything
182+
# On Bitrig, we need the relocation model to be PIC for everthing
183183
ifeq (,$(filter $(OSTYPE_$(1)),bitrig))
184184
LLVM_MC_RELOCATION_MODEL="pic"
185185
else

branches/snap-stage3/mk/target.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ endef
132132
# on $$(TSREQ$(1)_T_$(2)_H_$(3)), to ensure that no products will be
133133
# put into the target area until after the get-snapshot.py script has
134134
# had its chance to clean it out; otherwise the other products will be
135-
# inadvertently included in the clean out.
135+
# inadvertantly included in the clean out.
136136
SNAPSHOT_RUSTC_POST_CLEANUP=$(HBIN0_H_$(CFG_BUILD))/rustc$(X_$(CFG_BUILD))
137137

138138
define TARGET_HOST_RULES

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,15 +1188,12 @@ the guarantee that these issues are never caused by safe code.
11881188

11891189
* Data races
11901190
* Dereferencing a null/dangling raw pointer
1191+
* Mutating an immutable value/reference without `UnsafeCell`
11911192
* Reads of [undef](http://llvm.org/docs/LangRef.html#undefined-values)
11921193
(uninitialized) memory
11931194
* Breaking the [pointer aliasing
11941195
rules](http://llvm.org/docs/LangRef.html#pointer-aliasing-rules)
11951196
with raw pointers (a subset of the rules used by C)
1196-
* `&mut` and `&` follow LLVM’s scoped [noalias] model, except if the `&T`
1197-
contains an `UnsafeCell<U>`. Unsafe code must not violate these aliasing
1198-
guarantees.
1199-
* Mutating an immutable value/reference without `UnsafeCell<U>`
12001197
* Invoking undefined behavior via compiler intrinsics:
12011198
* Indexing outside of the bounds of an object with `std::ptr::offset`
12021199
(`offset` intrinsic), with
@@ -1213,8 +1210,6 @@ the guarantee that these issues are never caused by safe code.
12131210
code. Rust's failure system is not compatible with exception handling in
12141211
other languages. Unwinding must be caught and handled at FFI boundaries.
12151212

1216-
[noalias]: http://llvm.org/docs/LangRef.html#noalias
1217-
12181213
##### Behaviour not considered unsafe
12191214

12201215
This is a list of behaviour not considered *unsafe* in Rust terms, but that may

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* [Looping](looping.md)
1414
* [Strings](strings.md)
1515
* [Arrays, Vectors, and Slices](arrays-vectors-and-slices.md)
16+
* [Standard Input](standard-input.md)
1617
* [Intermediate Rust](intermediate.md)
1718
* [Crates and Modules](crates-and-modules.md)
1819
* [Testing](testing.md)

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,5 @@ You can also take a slice of a vector, `String`, or `&str`, because they are
9999
backed by arrays. Slices have type `&[T]`, which we'll talk about when we cover
100100
generics.
101101

102-
We have now learned all of the most basic Rust concepts.
102+
We have now learned all of the most basic Rust concepts. Next, we learn how to
103+
get input from the keyboard.

branches/snap-stage3/src/doc/trpl/associated-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ let obj = Box::new(graph) as Box<Graph>;
170170
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
171171
```
172172

173-
We can’t create a trait object like this, because we don’t know the associated
173+
We can’t create a trait object like this, becuase we don’t know the associated
174174
types. Instead, we can write this:
175175

176176
```rust

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ can be useful when changing some options, or when writing a macro.
517517

518518
### Re-exports
519519

520-
`rustdoc` will show the documentation for a public re-export in both places:
520+
`rustdoc` will show the documentation for a publc re-export in both places:
521521

522522
```ignore
523523
extern crate foo;
@@ -529,7 +529,7 @@ This will create documentation for bar both inside the documentation for the
529529
crate `foo`, as well as the documentation for your crate. It will use the same
530530
documentation in both places.
531531

532-
This behavior can be suppressed with `no_inline`:
532+
This behavior can be supressed with `no_inline`:
533533

534534
```ignore
535535
extern crate foo;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ parameter, of which there are three variants: `self`, `&self`, and `&mut self`.
5050
You can think of this first parameter as being the `x` in `x.foo()`. The three
5151
variants correspond to the three kinds of thing `x` could be: `self` if it's
5252
just a value on the stack, `&self` if it's a reference, and `&mut self` if it's
53-
a mutable reference. We should default to using `&self`, as you should prefer
54-
borrowing over taking ownership, as well as taking immutable references
55-
over mutable ones. Here's an example of all three variants:
53+
a mutable reference. We should default to using `&self`, as it's the most
54+
common, as Rustaceans prefer borrowing over taking ownership, and references
55+
over mutable references. Here's an example of all three variants:
5656

5757
```rust
5858
struct Circle {

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -472,15 +472,10 @@ thread-safe counterpart of `Rc<T>`.
472472

473473
## Lifetime Elision
474474

475-
Rust supports powerful local type inference in function bodies, but it’s
476-
forbidden in item signatures to allow reasoning about the types just based in
477-
the item signature alone. However, for ergonomic reasons a very restricted
478-
secondary inference algorithm called “lifetime elision” applies in function
479-
signatures. It infers only based on the signature components themselves and not
480-
based on the body of the function, only infers lifetime paramters, and does
481-
this with only three easily memorizable and unambiguous rules. This makes
482-
lifetime elision a shorthand for writing an item signature, while not hiding
483-
away the actual types involved as full local inference would if applied to it.
475+
Earlier, we mentioned *lifetime elision*, a feature of Rust which allows you to
476+
not write lifetime annotations in certain circumstances. All references have a
477+
lifetime, and so if you elide a lifetime (like `&T` instead of `&'a T`), Rust
478+
will do three things to determine what those lifetimes should be.
484479

485480
When talking about lifetime elision, we use the term *input lifetime* and
486481
*output lifetime*. An *input lifetime* is a lifetime associated with a parameter
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
% Standard Input
2+
3+
Getting input from the keyboard is pretty easy, but uses some things
4+
we haven't seen before. Here's a simple program that reads some input,
5+
and then prints it back out:
6+
7+
```{rust,ignore}
8+
# #![feature(old_io)]
9+
fn main() {
10+
println!("Type something!");
11+
12+
let input = std::old_io::stdin().read_line().ok().expect("Failed to read line");
13+
14+
println!("{}", input);
15+
}
16+
```
17+
18+
Let's go over these chunks, one by one:
19+
20+
```{rust,ignore}
21+
std::old_io::stdin();
22+
```
23+
24+
This calls a function, `stdin()`, that lives inside the `std::old_io` module. As
25+
you can imagine, everything in `std` is provided by Rust, the 'standard
26+
library.' We'll talk more about the module system later.
27+
28+
Since writing the fully qualified name all the time is annoying, we can use
29+
the `use` statement to import it in:
30+
31+
```{rust}
32+
# #![feature(old_io)]
33+
use std::old_io::stdin;
34+
35+
stdin();
36+
```
37+
38+
However, it's considered better practice to not import individual functions, but
39+
to import the module, and only use one level of qualification:
40+
41+
```{rust}
42+
# #![feature(old_io)]
43+
use std::old_io;
44+
45+
old_io::stdin();
46+
```
47+
48+
Let's update our example to use this style:
49+
50+
```{rust,ignore}
51+
use std::old_io;
52+
53+
fn main() {
54+
println!("Type something!");
55+
56+
let input = old_io::stdin().read_line().ok().expect("Failed to read line");
57+
58+
println!("{}", input);
59+
}
60+
```
61+
62+
Next up:
63+
64+
```{rust,ignore}
65+
.read_line()
66+
```
67+
68+
The `read_line()` method can be called on the result of `stdin()` to return
69+
a full line of input. Nice and easy.
70+
71+
```{rust,ignore}
72+
.ok().expect("Failed to read line");
73+
```
74+
75+
Do you remember this code?
76+
77+
```{rust}
78+
enum OptionalInt {
79+
Value(i32),
80+
Missing,
81+
}
82+
83+
fn main() {
84+
let x = OptionalInt::Value(5);
85+
let y = OptionalInt::Missing;
86+
87+
match x {
88+
OptionalInt::Value(n) => println!("x is {}", n),
89+
OptionalInt::Missing => println!("x is missing!"),
90+
}
91+
92+
match y {
93+
OptionalInt::Value(n) => println!("y is {}", n),
94+
OptionalInt::Missing => println!("y is missing!"),
95+
}
96+
}
97+
```
98+
99+
We had to match each time to see if we had a value or not. In this case,
100+
though, we _know_ that `x` has a `Value`, but `match` forces us to handle
101+
the `missing` case. This is what we want 99% of the time, but sometimes, we
102+
know better than the compiler.
103+
104+
Likewise, `read_line()` does not return a line of input. It _might_ return a
105+
line of input, though it might also fail to do so. This could happen if our program
106+
isn't running in a terminal, but as part of a cron job, or some other context
107+
where there's no standard input. Because of this, `read_line` returns a type
108+
very similar to our `OptionalInt`: an `IoResult<T>`. We haven't talked about
109+
`IoResult<T>` yet because it is the *generic* form of our `OptionalInt`.
110+
Until then, you can think of it as being the same thing, just for any type –
111+
not just `i32`s.
112+
113+
Rust provides a method on these `IoResult<T>`s called `ok()`, which does the
114+
same thing as our `match` statement but assumes that we have a valid value.
115+
We then call `expect()` on the result, which will terminate our program if we
116+
don't have a valid value. In this case, if we can't get input, our program
117+
doesn't work, so we're okay with that. In most cases, we would want to handle
118+
the error case explicitly. `expect()` allows us to give an error message if
119+
this crash happens.
120+
121+
We will cover the exact details of how all of this works later in the Guide in
122+
[Error Handling]. For now, this gives you enough of a basic understanding to
123+
work with.
124+
125+
Back to the code we were working on! Here's a refresher:
126+
127+
```{rust,ignore}
128+
use std::old_io;
129+
130+
fn main() {
131+
println!("Type something!");
132+
133+
let input = old_io::stdin().read_line().ok().expect("Failed to read line");
134+
135+
println!("{}", input);
136+
}
137+
```
138+
139+
With long lines like this, Rust gives you some flexibility with the whitespace.
140+
We _could_ write the example like this:
141+
142+
```{rust,ignore}
143+
use std::old_io;
144+
145+
fn main() {
146+
println!("Type something!");
147+
148+
// here, we'll show the types at each step
149+
150+
let input = old_io::stdin() // std::old_io::stdio::StdinReader
151+
.read_line() // IoResult<String>
152+
.ok() // Option<String>
153+
.expect("Failed to read line"); // String
154+
155+
println!("{}", input);
156+
}
157+
```
158+
159+
Sometimes, this makes things more readable – sometimes, less. Use your judgement
160+
here.
161+
162+
That's all you need to get basic input from the standard input! It's not too
163+
complicated, but there are a number of small parts.
164+
165+
166+
[Error Handling]: ./error-handling.html

branches/snap-stage3/src/etc/rustup.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ case $CFG_OSTYPE in
335335
MINGW32*)
336336
CFG_OSTYPE=pc-mingw32
337337
;;
338-
# Thad's Cygwin identifiers below
338+
# Thad's Cygwin identifers below
339339

340340
# Vista 32 bit
341341
CYGWIN_NT-6.0)
@@ -437,7 +437,7 @@ CFG_TMP_DIR=$(mktemp -d 2>/dev/null \
437437
|| create_tmp_dir)
438438

439439
# If we're saving nightlies and we didn't specify which one, grab the latest
440-
# version from the perspective of the server. Buildbot has typically finished
440+
# verison from the perspective of the server. Buildbot has typically finished
441441
# building and uploading by ~8UTC, but we want to include a little buffer.
442442
#
443443
# FIXME It would be better to use the known most recent nightly that has been

0 commit comments

Comments
 (0)