Skip to content

Commit a612ccd

Browse files
committed
---
yaml --- r: 232205 b: refs/heads/auto c: c5fa777 h: refs/heads/master i: 232203: 45435ed v: v3
1 parent dbd1862 commit a612ccd

File tree

155 files changed

+1283
-1576
lines changed

Some content is hidden

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

155 files changed

+1283
-1576
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: 0a967561783f093c2b63057283784892e855a408
11+
refs/heads/auto: c5fa7776dff913dd75fed6f4e7ed483f0e75e367
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/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/auto/src/doc/complement-project-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Existing languages at this level of abstraction and efficiency are unsatisfactor
2222

2323
# Is any part of this thing production-ready?
2424

25-
Yes!
25+
No. Feel free to play around, but don't expect completeness or stability yet. Expect incompleteness and breakage.
2626

2727
# Is this a completely Mozilla-planned and orchestrated thing?
2828

branches/auto/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/auto/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/auto/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/auto/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

0 commit comments

Comments
 (0)