Skip to content

Commit 49fcd6f

Browse files
committed
---
yaml --- r: 234754 b: refs/heads/tmp c: d7ec69a h: refs/heads/master v: v3
1 parent 7414dc3 commit 49fcd6f

File tree

150 files changed

+1590
-243
lines changed

Some content is hidden

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

150 files changed

+1590
-243
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: 8aef16c2a5c175f7b4359122d7409765b09d6bf5
28+
refs/heads/tmp: d7ec69a652e8e58c788c8dfa060387d1ceb4b28d
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/COMPILER_TESTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Compiler Test Documentation
22

3-
In the Rust project, we use a special set of comands imbedded in
3+
In the Rust project, we use a special set of comands embedded in
44
comments to test the Rust compiler. There are two groups of commands:
55

66
1. Header commands
@@ -29,11 +29,11 @@ The error levels that you can have are:
2929
3. `NOTE`
3030
4. `HELP` and `SUGGESTION`*
3131

32-
\* **Note**: `SUGGESTION` must follow emediatly after `HELP`.
32+
\* **Note**: `SUGGESTION` must follow immediately after `HELP`.
3333

3434
## Summary of Header Commands
3535

36-
Header commands specify something about the entire test file, as a
36+
Header commands specify something about the entire test file as a
3737
whole, instead of just a few lines inside the test.
3838

3939
* `ignore-X` where `X` is an architecture, OS or stage will ignore the test accordingly

branches/tmp/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#
2727
# * check - Run the complete test suite
2828
#
29-
# * clean - Clean the build repertory. It is advised to run this
29+
# * clean - Clean the build repository. It is advised to run this
3030
# command if you want to build Rust again, after an update
3131
# of the git repository.
3232
#

branches/tmp/RELEASES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Version 1.3.0 (September 2015)
1+
Version 1.3.0 (2015-09-17)
22
==============================
33

44
* ~900 changes, numerous bugfixes

branches/tmp/configure

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,12 @@ envopt CPP
10951095
envopt CFLAGS
10961096
envopt CXXFLAGS
10971097

1098+
# stdc++ name in use
1099+
# used to manage non-standard name (on OpenBSD for example)
1100+
program_transform_name=$($CFG_CC -v 2>&1 | sed -n "s/.*--program-transform-name='\([^']*\)'.*/\1/p")
1101+
CFG_STDCPP_NAME=$(echo "stdc++" | sed "${program_transform_name}")
1102+
putvar CFG_STDCPP_NAME
1103+
10981104
# a little post-processing of various config values
10991105
CFG_PREFIX=${CFG_PREFIX%/}
11001106
CFG_MANDIR=${CFG_MANDIR%/}

branches/tmp/mk/dist.mk

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

branches/tmp/mk/llvm.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ $$(LLVM_STAMP_$(1)): $(S)src/rustllvm/llvm-auto-clean-trigger
7373

7474
ifeq ($$(CFG_ENABLE_LLVM_STATIC_STDCPP),1)
7575
LLVM_STDCPP_RUSTFLAGS_$(1) = -L "$$(dir $$(shell $$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
76-
-print-file-name=libstdc++.a))"
76+
-print-file-name=lib$(CFG_STDCPP_NAME).a))"
7777
else
7878
LLVM_STDCPP_RUSTFLAGS_$(1) =
7979
endif
@@ -83,7 +83,7 @@ endif
8383
LLVM_LINKAGE_PATH_$(1):=$$(abspath $$(RT_OUTPUT_DIR_$(1))/llvmdeps.rs)
8484
$$(LLVM_LINKAGE_PATH_$(1)): $(S)src/etc/mklldeps.py $$(LLVM_CONFIG_$(1))
8585
$(Q)$(CFG_PYTHON) "$$<" "$$@" "$$(LLVM_COMPONENTS)" "$$(CFG_ENABLE_LLVM_STATIC_STDCPP)" \
86-
$$(LLVM_CONFIG_$(1))
86+
$$(LLVM_CONFIG_$(1)) "$(CFG_STDCPP_NAME)"
8787
endef
8888

8989
$(foreach host,$(CFG_HOST), \

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 more
324+
A common gripe when reading Rust code is with types like `Rc<RefCell<Vec<T>>>` (or even 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: 28 additions & 31 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 indicates
30-
to the compiler 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
30+
indicates 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,13 +42,19 @@ 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 to the compiler that something
45+
When a type `T` implements `Sync`, it indicates that something
4646
of this type has no possibility of introducing memory unsafety when used from
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.
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`.
5258

5359
These two traits allow you to use the type system to make strong guarantees
5460
about the properties of your code under concurrency. Before we demonstrate
@@ -70,7 +76,7 @@ fn main() {
7076
}
7177
```
7278

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

@@ -215,29 +221,18 @@ fn main() {
215221
}
216222
```
217223

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

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:
227+
Also note that [`lock`](../std/sync/struct.Mutex.html#method.lock) method of
228+
[`Mutex`](../std/sync/struct.Mutex.html) has this signature:
234229

235230
```ignore
236231
fn lock(&self) -> LockResult<MutexGuard<T>>
237232
```
238233

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.
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.
241236

242237
Let's examine the body of the thread more closely:
243238

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

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

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

326321
tx.send(answer);
327322
});
328323
}
329324

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

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.
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.
336333

337334

338335
## Panics

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

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ systems may want to jump around.
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-isnt-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)
@@ -41,11 +41,11 @@ systems may want to jump around.
4141
* [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-box<error>)
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,9 +87,9 @@ 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-
<div id="code-unwrap-double">
91-
```rust,should_panic
90+
<a name="code-unwrap-double"></a>
9291

92+
```rust,should_panic
9393
use std::env;
9494
9595
fn main() {
@@ -99,7 +99,6 @@ fn main() {
9999
println!("{}", 2 * n);
100100
}
101101
```
102-
</div>
103102

104103
If you give this program zero arguments (error 1) or if the first argument
105104
isn't an integer (error 2), the program will panic just like in the first
@@ -140,7 +139,8 @@ system is an important concept because it will cause the compiler to force the
140139
programmer to handle that absence. Let's take a look at an example that tries
141140
to find a character in a string:
142141

143-
<div id="code-option-ex-string-find">
142+
<a name="code-option-ex-string-find"></a>
143+
144144
```rust
145145
// Searches `haystack` for the Unicode character `needle`. If one is found, the
146146
// byte offset of the character is returned. Otherwise, `None` is returned.
@@ -153,7 +153,6 @@ fn find(haystack: &str, needle: char) -> Option<usize> {
153153
None
154154
}
155155
```
156-
</div>
157156

158157
Notice that when this function finds a matching character, it doen't just
159158
return the `offset`. Instead, it returns `Some(offset)`. `Some` is a variant or
@@ -187,6 +186,8 @@ But wait, what about `unwrap` used in [`unwrap-double`](#code-unwrap-double)?
187186
There was no case analysis there! Instead, the case analysis was put inside the
188187
`unwrap` method for you. You could define it yourself if you want:
189188

189+
<a name="code-option-def-unwrap"></a>
190+
190191
```rust
191192
enum Option<T> {
192193
None,
@@ -210,7 +211,7 @@ that makes `unwrap` ergonomic to use. Unfortunately, that `panic!` means that
210211

211212
### Composing `Option<T>` values
212213

213-
In [`option-ex-string-find`](#code-option-ex-string-find-2)
214+
In [`option-ex-string-find`](#code-option-ex-string-find)
214215
we saw how to use `find` to discover the extension in a file name. Of course,
215216
not all file names have a `.` in them, so it's possible that the file name has
216217
no extension. This *possibility of absence* is encoded into the types using
@@ -252,6 +253,8 @@ option is `None`, in which case, just return `None`.
252253
Rust has parametric polymorphism, so it is very easy to define a combinator
253254
that abstracts this pattern:
254255

256+
<a name="code-option-map"></a>
257+
255258
```rust
256259
fn map<F, T, A>(option: Option<T>, f: F) -> Option<A> where F: FnOnce(T) -> A {
257260
match option {
@@ -391,6 +394,8 @@ remove choices because they will panic if `Option<T>` is `None`.
391394
The `Result` type is also
392395
[defined in the standard library][6]:
393396

397+
<a name="code-result-def-1"></a>
398+
394399
```rust
395400
enum Result<T, E> {
396401
Ok(T),
@@ -667,6 +672,8 @@ with both an `Option` and a `Result`, the solution is *usually* to convert the
667672
(from `env::args()`) means the user didn't invoke the program correctly. We
668673
could just use a `String` to describe the error. Let's try:
669674

675+
<a name="code-error-double-string"></a>
676+
670677
```rust
671678
use std::env;
672679

@@ -899,6 +906,8 @@ seen above.
899906

900907
Here is a simplified definition of a `try!` macro:
901908

909+
<a nama name="code-try-def-simple"></a>
910+
902911
```rust
903912
macro_rules! try {
904913
($e:expr) => (match $e {
@@ -1159,6 +1168,8 @@ The `std::convert::From` trait is
11591168
[defined in the standard
11601169
library](../std/convert/trait.From.html):
11611170

1171+
<a name="code-from-def"></a>
1172+
11621173
```rust
11631174
trait From<T> {
11641175
fn from(T) -> Self;
@@ -1236,9 +1247,11 @@ macro_rules! try {
12361247
}
12371248
```
12381249

1239-
This is not it's real definition. It's real definition is
1250+
This is not its real definition. Its real definition is
12401251
[in the standard library](../std/macro.try!.html):
12411252

1253+
<a name="code-try-def"></a>
1254+
12421255
```rust
12431256
macro_rules! try {
12441257
($e:expr) => (match $e {
@@ -1457,7 +1470,7 @@ representation. But certainly, this will vary depending on use cases.
14571470
At a minimum, you should probably implement the
14581471
[`Error`](../std/error/trait.Error.html)
14591472
trait. This will give users of your library some minimum flexibility for
1460-
[composing errors](#the-real-try-macro). Implementing the `Error` trait also
1473+
[composing errors](#the-real-try!-macro). Implementing the `Error` trait also
14611474
means that users are guaranteed the ability to obtain a string representation
14621475
of an error (because it requires impls for both `fmt::Debug` and
14631476
`fmt::Display`).

branches/tmp/src/doc/trpl/guessing-game.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ a few tricks up their sleeves.
147147

148148
For example, they’re [immutable][immutable] by default. That’s why our example
149149
uses `mut`: it makes a binding mutable, rather than immutable. `let` doesn’t
150-
take a name on the left hand side, it actually accepts a
150+
take a name on the left hand side of the assignment, it actually accepts a
151151
[pattern][patterns]’. We’ll use patterns later. It’s easy enough
152152
to use for now:
153153

branches/tmp/src/etc/mklldeps.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
components = sys.argv[2].split() # splits on whitespace
1818
enable_static = sys.argv[3]
1919
llvm_config = sys.argv[4]
20+
stdcpp_name = sys.argv[5]
2021

2122
f.write("""// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2223
// file at the top-level directory of this distribution and at
@@ -77,15 +78,15 @@ def run(args):
7778
out = run([llvm_config, '--cxxflags'])
7879
if enable_static == '1':
7980
assert('stdlib=libc++' not in out)
80-
f.write("#[link(name = \"stdc++\", kind = \"static\")]\n")
81+
f.write("#[link(name = \"" + stdcpp_name + "\", kind = \"static\")]\n")
8182
else:
8283
# Note that we use `cfg_attr` here because on MSVC the C++ standard library
8384
# is not c++ or stdc++, but rather the linker takes care of linking the
8485
# right standard library.
8586
if 'stdlib=libc++' in out:
8687
f.write("#[cfg_attr(not(target_env = \"msvc\"), link(name = \"c++\"))]\n")
8788
else:
88-
f.write("#[cfg_attr(not(target_env = \"msvc\"), link(name = \"stdc++\"))]\n")
89+
f.write("#[cfg_attr(not(target_env = \"msvc\"), link(name = \"" + stdcpp_name + "\"))]\n")
8990

9091
# Attach everything to an extern block
9192
f.write("extern {}\n")

0 commit comments

Comments
 (0)