Skip to content

Commit fe7422f

Browse files
committed
---
yaml --- r: 234766 b: refs/heads/tmp c: ed77fcc h: refs/heads/master v: v3
1 parent 3171645 commit fe7422f

File tree

146 files changed

+734
-1753
lines changed

Some content is hidden

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

146 files changed

+734
-1753
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: d2e13e822a73e0ea46ae9e21afdd3155fc997f6d
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: 6602b2f1c777e6e563a7bcc920bbd1ee1c4f7eab
28+
refs/heads/tmp: ed77fcc8a67cbff506ffaf73781e8d25d382a2f3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: ab792abf1fcc28afbd315426213f6428da25c085
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/mk/dist.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ $(PKG_TAR): $(PKG_FILES)
7777
-C $(S) \
7878
--exclude-vcs \
7979
--exclude=*~ \
80-
--exclude=*.pyc \
8180
--exclude=*/llvm/test/*/*.ll \
8281
--exclude=*/llvm/test/*/*.td \
8382
--exclude=*/llvm/test/*/*.s \

branches/tmp/mk/platform.mk

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,6 @@ define CFG_MAKE_TOOLCHAIN
208208

209209
ifeq ($$(findstring $(HOST_$(1)),arm aarch64 mips mipsel powerpc),)
210210

211-
# On OpenBSD, we need to pass the path of libstdc++.so to the linker
212-
# (use path of libstdc++.a which is a known name for the same path)
213-
ifeq ($(OSTYPE_$(1)),unknown-openbsd)
214-
RUSTC_FLAGS_$(1)=-L "$$(dir $$(shell $$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
215-
-print-file-name=lib$(CFG_STDCPP_NAME).a))" \
216-
$(RUSTC_FLAGS_$(1))
217-
endif
218-
219211
# On Bitrig, we need the relocation model to be PIC for everything
220212
ifeq (,$(filter $(OSTYPE_$(1)),bitrig))
221213
LLVM_MC_RELOCATION_MODEL="pic"

branches/tmp/src/doc/style/errors/ergonomics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn write_info(info: &Info) -> Result<(), IoError> {
5757
```
5858

5959
See
60-
[the `result` module documentation](https://doc.rust-lang.org/stable/std/result/index.html#the-try-macro)
60+
[the `result` module documentation](https://doc.rust-lang.org/stable/std/result/index.html#the-try!-macro)
6161
for more details.
6262

6363
### The `Result`-`impl` pattern [FIXME]

branches/tmp/src/doc/style/features/traits/generics.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ explicitly implement to be used by this generic function.
2727
* _Inference_. Since the type parameters to generic functions can usually be
2828
inferred, generic functions can help cut down on verbosity in code where
2929
explicit conversions or other method calls would usually be necessary. See the
30-
[overloading/implicits use case](#use-case-limited-overloading-andor-implicit-conversions)
30+
[overloading/implicits use case](#use-case:-limited-overloading-and/or-implicit-conversions)
3131
below.
3232
* _Precise types_. Because generics give a _name_ to the specific type
3333
implementing a trait, it is possible to be precise about places where that
@@ -51,7 +51,7 @@ explicitly implement to be used by this generic function.
5151
a `Vec<T>` contains elements of a single concrete type (and, indeed, the
5252
vector representation is specialized to lay these out in line). Sometimes
5353
heterogeneous collections are useful; see
54-
[trait objects](#use-case-trait-objects) below.
54+
[trait objects](#use-case:-trait-objects) below.
5555
* _Signature verbosity_. Heavy use of generics can bloat function signatures.
5656
**[Ed. note]** This problem may be mitigated by some language improvements; stay tuned.
5757

branches/tmp/src/doc/trpl/choosing-your-guarantees.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ there's a lot of concurrent access happening.
321321

322322
# Composition
323323

324-
A common gripe when reading Rust code is with types like `Rc<RefCell<Vec<T>>>` (or even more
324+
A common gripe when reading Rust code is with types like `Rc<RefCell<Vec<T>>>` (or even more more
325325
complicated compositions of such types). It's not always clear what the composition does, or why the
326326
author chose one like this (and when one should be using such a composition in one's own code)
327327

branches/tmp/src/doc/trpl/concurrency.md

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ to help us make sense of code that can possibly be concurrent.
2626
### `Send`
2727

2828
The first trait we're going to talk about is
29-
[`Send`](../std/marker/trait.Send.html). When a type `T` implements `Send`, it
30-
indicates that something of this type is able to have ownership transferred
29+
[`Send`](../std/marker/trait.Send.html). When a type `T` implements `Send`, it indicates
30+
to the compiler that something of this type is able to have ownership transferred
3131
safely between threads.
3232

3333
This is important to enforce certain restrictions. For example, if we have a
@@ -42,19 +42,13 @@ us enforce that it can't leave the current thread.
4242
### `Sync`
4343

4444
The second of these traits is called [`Sync`](../std/marker/trait.Sync.html).
45-
When a type `T` implements `Sync`, it indicates that something
45+
When a type `T` implements `Sync`, it indicates to the compiler that something
4646
of this type has no possibility of introducing memory unsafety when used from
47-
multiple threads concurrently through shared references. This implies that
48-
types which don't have [interior mutability](mutability.html) are inherently
49-
`Sync`, which includes simple primitive types (like `u8`) and aggregate types
50-
containing them.
51-
52-
For sharing references across threads, Rust provides a wrapper type called
53-
`Arc<T>`. `Arc<T>` implements `Send` and `Sync` if and only if `T` implements
54-
both `Send` and `Sync`. For example, an object of type `Arc<RefCell<U>>` cannot
55-
be transferred across threads because
56-
[`RefCell`](choosing-your-guarantees.html#refcell%3Ct%3E) does not implement
57-
`Sync`, consequently `Arc<RefCell<U>>` would not implement `Send`.
47+
multiple threads concurrently.
48+
49+
For example, sharing immutable data with an atomic reference count is
50+
threadsafe. Rust provides a type like this, `Arc<T>`, and it implements `Sync`,
51+
so it is safe to share between threads.
5852

5953
These two traits allow you to use the type system to make strong guarantees
6054
about the properties of your code under concurrency. Before we demonstrate
@@ -76,7 +70,7 @@ fn main() {
7670
}
7771
```
7872

79-
The `thread::spawn()` method accepts a [closure](closures.html), which is executed in a
73+
The `thread::spawn()` method accepts a closure, which is executed in a
8074
new thread. It returns a handle to the thread, that can be used to
8175
wait for the child thread to finish and extract its result:
8276

@@ -221,18 +215,29 @@ fn main() {
221215
}
222216
```
223217

224-
Note that the value of `i` is bound (copied) to the closure and not shared
225-
among the threads.
226218

227-
Also note that [`lock`](../std/sync/struct.Mutex.html#method.lock) method of
228-
[`Mutex`](../std/sync/struct.Mutex.html) has this signature:
219+
If we'd tried to use `Mutex<T>` without wrapping it in an `Arc<T>` we would have
220+
seen another error like:
221+
222+
```text
223+
error: the trait `core::marker::Send` is not implemented for the type `std::sync::mutex::MutexGuard<'_, collections::vec::Vec<u32>>` [E0277]
224+
thread::spawn(move || {
225+
^~~~~~~~~~~~~
226+
note: `std::sync::mutex::MutexGuard<'_, collections::vec::Vec<u32>>` cannot be sent between threads safely
227+
thread::spawn(move || {
228+
^~~~~~~~~~~~~
229+
```
230+
231+
You see, [`Mutex`](../std/sync/struct.Mutex.html) has a
232+
[`lock`](../std/sync/struct.Mutex.html#method.lock)
233+
method which has this signature:
229234

230235
```ignore
231236
fn lock(&self) -> LockResult<MutexGuard<T>>
232237
```
233238

234-
and because `Send` is not implemented for `MutexGuard<T>`, the guard cannot
235-
cross thread boundaries, ensuring thread-locality of lock acquire and release.
239+
and because `Send` is not implemented for `MutexGuard<T>`, we couldn't have
240+
transferred the guard across thread boundaries on it's own.
236241

237242
Let's examine the body of the thread more closely:
238243

@@ -312,24 +317,22 @@ use std::sync::mpsc;
312317
fn main() {
313318
let (tx, rx) = mpsc::channel();
314319

315-
for i in 0..10 {
320+
for _ in 0..10 {
316321
let tx = tx.clone();
317322

318323
thread::spawn(move || {
319-
let answer = i * i;
324+
let answer = 42;
320325

321326
tx.send(answer);
322327
});
323328
}
324329

325-
for _ in 0..10 {
326-
println!("{}", rx.recv().unwrap());
327-
}
330+
rx.recv().ok().expect("Could not receive answer");
328331
}
329332
```
330333

331-
Here we create 10 threads, asking each to calculate the square of a number (`i`
332-
at the time of `spawn()`), and then `send()` back the answer over the channel.
334+
A `u32` is `Send` because we can make a copy. So we create a thread, ask it to calculate
335+
the answer, and then it `send()`s us the answer over the channel.
333336

334337

335338
## Panics

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

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,28 @@ systems may want to jump around.
2424
* [The Basics](#the-basics)
2525
* [Unwrapping explained](#unwrapping-explained)
2626
* [The `Option` type](#the-option-type)
27-
* [Composing `Option<T>` values](#composing-optiont-values)
27+
* [Composing `Option<T>` values](#composing-option<t>-values)
2828
* [The `Result` type](#the-result-type)
2929
* [Parsing integers](#parsing-integers)
3030
* [The `Result` type alias idiom](#the-result-type-alias-idiom)
31-
* [A brief interlude: unwrapping isn't evil](#a-brief-interlude-unwrapping-isn't-evil)
31+
* [A brief interlude: unwrapping isn't evil](#a-brief-interlude:-unwrapping-isn't-evil)
3232
* [Working with multiple error types](#working-with-multiple-error-types)
3333
* [Composing `Option` and `Result`](#composing-option-and-result)
3434
* [The limits of combinators](#the-limits-of-combinators)
3535
* [Early returns](#early-returns)
36-
* [The `try!` macro](#the-try-macro)
36+
* [The `try!` macro](#the-try!-macro)
3737
* [Defining your own error type](#defining-your-own-error-type)
3838
* [Standard library traits used for error handling](#standard-library-traits-used-for-error-handling)
3939
* [The `Error` trait](#the-error-trait)
4040
* [The `From` trait](#the-from-trait)
41-
* [The real `try!` macro](#the-real-try-macro)
41+
* [The real `try!` macro](#the-real-try!-macro)
4242
* [Composing custom error types](#composing-custom-error-types)
4343
* [Advice for library writers](#advice-for-library-writers)
44-
* [Case study: A program to read population data](#case-study-a-program-to-read-population-data)
44+
* [Case study: A program to read population data](#case-study:-a-program-to-read-population-data)
4545
* [Initial setup](#initial-setup)
4646
* [Argument parsing](#argument-parsing)
4747
* [Writing the logic](#writing-the-logic)
48-
* [Error handling with `Box<Error>`](#error-handling-with-boxerror)
48+
* [Error handling with `Box<Error>`](#error-handling-with-box%3Cerror%3E)
4949
* [Reading from stdin](#reading-from-stdin)
5050
* [Error handling with a custom type](#error-handling-with-a-custom-type)
5151
* [Adding functionality](#adding-functionality)
@@ -87,7 +87,7 @@ thread '<main>' panicked at 'Invalid number: 11', src/bin/panic-simple.rs:5
8787
Here's another example that is slightly less contrived. A program that accepts
8888
an integer as an argument, doubles it and prints it.
8989

90-
<span id="code-unwrap-double"></span>
90+
<a name="code-unwrap-double"></a>
9191

9292
```rust,should_panic
9393
use std::env;
@@ -139,7 +139,7 @@ system is an important concept because it will cause the compiler to force the
139139
programmer to handle that absence. Let's take a look at an example that tries
140140
to find a character in a string:
141141

142-
<span id="code-option-ex-string-find"></span>
142+
<a name="code-option-ex-string-find"></a>
143143

144144
```rust
145145
// Searches `haystack` for the Unicode character `needle`. If one is found, the
@@ -186,7 +186,7 @@ But wait, what about `unwrap` used in [`unwrap-double`](#code-unwrap-double)?
186186
There was no case analysis there! Instead, the case analysis was put inside the
187187
`unwrap` method for you. You could define it yourself if you want:
188188

189-
<span id="code-option-def-unwrap"></span>
189+
<a name="code-option-def-unwrap"></a>
190190

191191
```rust
192192
enum Option<T> {
@@ -253,7 +253,7 @@ option is `None`, in which case, just return `None`.
253253
Rust has parametric polymorphism, so it is very easy to define a combinator
254254
that abstracts this pattern:
255255

256-
<span id="code-option-map"></span>
256+
<a name="code-option-map"></a>
257257

258258
```rust
259259
fn map<F, T, A>(option: Option<T>, f: F) -> Option<A> where F: FnOnce(T) -> A {
@@ -394,7 +394,7 @@ remove choices because they will panic if `Option<T>` is `None`.
394394
The `Result` type is also
395395
[defined in the standard library][6]:
396396

397-
<span id="code-result-def"></span>
397+
<a name="code-result-def-1"></a>
398398

399399
```rust
400400
enum Result<T, E> {
@@ -562,7 +562,7 @@ combinators that affect only the error type, such as
562562
### The `Result` type alias idiom
563563

564564
In the standard library, you may frequently see types like
565-
`Result<i32>`. But wait, [we defined `Result`](#code-result-def) to
565+
`Result<i32>`. But wait, [we defined `Result`](#code-result-def-1) to
566566
have two type parameters. How can we get away with only specifying
567567
one? The key is to define a `Result` type alias that *fixes* one of
568568
the type parameters to a particular type. Usually the fixed type is
@@ -672,7 +672,7 @@ with both an `Option` and a `Result`, the solution is *usually* to convert the
672672
(from `env::args()`) means the user didn't invoke the program correctly. We
673673
could just use a `String` to describe the error. Let's try:
674674

675-
<span id="code-error-double-string"></span>
675+
<a name="code-error-double-string"></a>
676676

677677
```rust
678678
use std::env;
@@ -906,7 +906,7 @@ seen above.
906906

907907
Here is a simplified definition of a `try!` macro:
908908

909-
<span id="code-try-def-simple"></span>
909+
<a nama name="code-try-def-simple"></a>
910910

911911
```rust
912912
macro_rules! try {
@@ -1168,7 +1168,7 @@ The `std::convert::From` trait is
11681168
[defined in the standard
11691169
library](../std/convert/trait.From.html):
11701170

1171-
<span id="code-from-def"></span>
1171+
<a name="code-from-def"></a>
11721172

11731173
```rust
11741174
trait From<T> {
@@ -1250,7 +1250,7 @@ macro_rules! try {
12501250
This is not its real definition. Its real definition is
12511251
[in the standard library](../std/macro.try!.html):
12521252

1253-
<span id="code-try-def"></span>
1253+
<a name="code-try-def"></a>
12541254

12551255
```rust
12561256
macro_rules! try {
@@ -1515,7 +1515,7 @@ and [`rustc-serialize`](https://crates.io/crates/rustc-serialize) crates.
15151515

15161516
We're not going to spend a lot of time on setting up a project with
15171517
Cargo because it is already covered well in [the Cargo
1518-
chapter](../book/hello-cargo.html) and [Cargo's documentation][14].
1518+
chapter](../book/hello-cargo) and [Cargo's documentation][14].
15191519

15201520
To get started from scratch, run `cargo new --bin city-pop` and make sure your
15211521
`Cargo.toml` looks something like this:
@@ -1573,7 +1573,7 @@ fn main() {
15731573
15741574
let mut opts = Options::new();
15751575
opts.optflag("h", "help", "Show this usage message.");
1576-
1576+
15771577
let matches = match opts.parse(&args[1..]) {
15781578
Ok(m) => { m }
15791579
Err(e) => { panic!(e.to_string()) }
@@ -1584,7 +1584,7 @@ fn main() {
15841584
}
15851585
let data_path = args[1].clone();
15861586
let city = args[2].clone();
1587-
1587+
15881588
// Do stuff with information
15891589
}
15901590
```
@@ -1647,27 +1647,27 @@ fn main() {
16471647
16481648
let mut opts = Options::new();
16491649
opts.optflag("h", "help", "Show this usage message.");
1650-
1650+
16511651
let matches = match opts.parse(&args[1..]) {
16521652
Ok(m) => { m }
16531653
Err(e) => { panic!(e.to_string()) }
16541654
};
1655-
1655+
16561656
if matches.opt_present("h") {
16571657
print_usage(&program, opts);
16581658
return;
16591659
}
1660-
1660+
16611661
let data_file = args[1].clone();
16621662
let data_path = Path::new(&data_file);
16631663
let city = args[2].clone();
1664-
1664+
16651665
let file = fs::File::open(data_path).unwrap();
16661666
let mut rdr = csv::Reader::from_reader(file);
1667-
1667+
16681668
for row in rdr.decode::<Row>() {
16691669
let row = row.unwrap();
1670-
1670+
16711671
if row.city == city {
16721672
println!("{}, {}: {:?}",
16731673
row.city, row.country,
@@ -1773,7 +1773,7 @@ fn main() {
17731773
print_usage(&program, opts);
17741774
return;
17751775
}
1776-
1776+
17771777
let data_file = args[1].clone();
17781778
let data_path = Path::new(&data_file);
17791779
let city = args[2].clone();
@@ -1882,7 +1882,7 @@ opts.optflag("h", "help", "Show this usage message.");
18821882
...
18831883
let file = matches.opt_str("f");
18841884
let data_file = file.as_ref().map(Path::new);
1885-
1885+
18861886
let city = if !matches.free.is_empty() {
18871887
matches.free[0].clone()
18881888
} else {

0 commit comments

Comments
 (0)