Skip to content

Commit 8def137

Browse files
committed
---
yaml --- r: 55988 b: refs/heads/auto c: eaa8bbb h: refs/heads/master v: v3
1 parent ec4d0b2 commit 8def137

File tree

185 files changed

+3725
-6358
lines changed

Some content is hidden

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

185 files changed

+3725
-6358
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 30dbbe17c9189fed32d0f5f332b4f6ff8f7cc4aa
17+
refs/heads/auto: eaa8bbbb2e23cf68d4f6ea961af025ab4ac67eca
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/doc/rust.md

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,10 @@ expression context, the final namespace qualifier is omitted.
441441
Two examples of paths with type arguments:
442442

443443
~~~~
444-
# use core::hashmap::HashMap;
444+
# use core::hashmap::linear::LinearMap;
445445
# fn f() {
446446
# fn id<T:Copy>(t: T) -> T { t }
447-
type t = HashMap<int,~str>; // Type arguments used in a type expression
447+
type t = LinearMap<int,~str>; // Type arguments used in a type expression
448448
let x = id::<int>(10); // Type arguments used in a call expression
449449
# }
450450
~~~~
@@ -1653,12 +1653,11 @@ Path expressions are [lvalues](#lvalues-rvalues-and-temporaries).
16531653

16541654
### Tuple expressions
16551655

1656-
Tuples are written by enclosing one or more comma-separated
1656+
Tuples are written by enclosing two or more comma-separated
16571657
expressions in parentheses. They are used to create [tuple-typed](#tuple-types)
16581658
values.
16591659

16601660
~~~~~~~~ {.tuple}
1661-
(0,);
16621661
(0f, 4.5f);
16631662
("a", 4u, true);
16641663
~~~~~~~~
@@ -2579,7 +2578,7 @@ to the record type-constructor. The differences are as follows:
25792578

25802579
Tuple types and values are denoted by listing the types or values of their
25812580
elements, respectively, in a parenthesized, comma-separated
2582-
list.
2581+
list. Single-element tuples are not legal; all tuples have two or more values.
25832582

25842583
The members of a tuple are laid out in memory contiguously, like a record, in
25852584
order specified by the tuple type.
@@ -3252,28 +3251,6 @@ of runtime logging modules follows.
32523251
* `::rt::backtrace` Log a backtrace on task failure
32533252
* `::rt::callback` Unused
32543253

3255-
#### Logging Expressions
3256-
3257-
Rust provides several macros to log information. Here's a simple Rust program
3258-
that demonstrates all four of them:
3259-
3260-
```rust
3261-
fn main() {
3262-
error!("This is an error log")
3263-
warn!("This is a warn log")
3264-
info!("this is an info log")
3265-
debug!("This is a debug log")
3266-
}
3267-
```
3268-
3269-
These four log levels correspond to levels 1-4, as controlled by `RUST_LOG`:
3270-
3271-
```bash
3272-
$ RUST_LOG=rust=3 ./rust
3273-
rust: ~"\"This is an error log\""
3274-
rust: ~"\"This is a warn log\""
3275-
rust: ~"\"this is an info log\""
3276-
```
32773254

32783255
# Appendix: Rationales and design tradeoffs
32793256

branches/auto/doc/tutorial-tasks.md

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,63 +2,74 @@
22

33
# Introduction
44

5-
Rust provides safe concurrency through a combination
6-
of lightweight, memory-isolated tasks and message passing.
7-
This tutorial will describe the concurrency model in Rust, how it
8-
relates to the Rust type system, and introduce
9-
the fundamental library abstractions for constructing concurrent programs.
10-
11-
Rust tasks are not the same as traditional threads: rather,
12-
they are considered _green threads_, lightweight units of execution that the Rust
13-
runtime schedules cooperatively onto a small number of operating system threads.
14-
On a multi-core system Rust tasks will be scheduled in parallel by default.
15-
Because tasks are significantly
5+
The designers of Rust designed the language from the ground up to support pervasive
6+
and safe concurrency through lightweight, memory-isolated tasks and
7+
message passing.
8+
9+
Rust tasks are not the same as traditional threads: rather, they are more like
10+
_green threads_. The Rust runtime system schedules tasks cooperatively onto a
11+
small number of operating system threads. Because tasks are significantly
1612
cheaper to create than traditional threads, Rust can create hundreds of
1713
thousands of concurrent tasks on a typical 32-bit system.
18-
In general, all Rust code executes inside a task, including the `main` function.
19-
20-
In order to make efficient use of memory Rust tasks have dynamically sized stacks.
21-
A task begins its life with a small
22-
amount of stack space (currently in the low thousands of bytes, depending on
23-
platform), and acquires more stack as needed.
24-
Unlike in languages such as C, a Rust task cannot accidentally write to
25-
memory beyond the end of the stack, causing crashes or worse.
2614

27-
Tasks provide failure isolation and recovery. When a fatal error occurs in Rust
28-
code as a result of an explicit call to `fail!()`, an assertion failure, or
29-
another invalid operation, the runtime system destroys the entire
15+
Tasks provide failure isolation and recovery. When an exception occurs in Rust
16+
code (as a result of an explicit call to `fail!()`, an assertion failure, or
17+
another invalid operation), the runtime system destroys the entire
3018
task. Unlike in languages such as Java and C++, there is no way to `catch` an
3119
exception. Instead, tasks may monitor each other for failure.
3220

21+
Rust tasks have dynamically sized stacks. A task begins its life with a small
22+
amount of stack space (currently in the low thousands of bytes, depending on
23+
platform), and acquires more stack as needed. Unlike in languages such as C, a
24+
Rust task cannot run off the end of the stack. However, tasks do have a stack
25+
budget. If a Rust task exceeds its stack budget, then it will fail safely:
26+
with a checked exception.
27+
3328
Tasks use Rust's type system to provide strong memory safety guarantees. In
3429
particular, the type system guarantees that tasks cannot share mutable state
3530
with each other. Tasks communicate with each other by transferring _owned_
3631
data through the global _exchange heap_.
3732

33+
This tutorial explains the basics of tasks and communication in Rust,
34+
explores some typical patterns in concurrent Rust code, and finally
35+
discusses some of the more unusual synchronization types in the standard
36+
library.
37+
38+
> ***Warning:*** This tutorial is incomplete
39+
3840
## A note about the libraries
3941

4042
While Rust's type system provides the building blocks needed for safe
4143
and efficient tasks, all of the task functionality itself is implemented
4244
in the core and standard libraries, which are still under development
43-
and do not always present a consistent or complete interface.
45+
and do not always present a consistent interface.
46+
47+
In particular, there are currently two independent modules that provide a
48+
message passing interface to Rust code: `core::comm` and `core::pipes`.
49+
`core::comm` is an older, less efficient system that is being phased out in
50+
favor of `pipes`. At some point, we will remove the existing `core::comm` API
51+
and move the user-facing portions of `core::pipes` to `core::comm`. In this
52+
tutorial, we discuss `pipes` and ignore the `comm` API.
4453

4554
For your reference, these are the standard modules involved in Rust
4655
concurrency at this writing.
4756

4857
* [`core::task`] - All code relating to tasks and task scheduling
49-
* [`core::comm`] - The message passing interface
50-
* [`core::pipes`] - The underlying messaging infrastructure
51-
* [`std::comm`] - Additional messaging types based on `core::pipes`
58+
* [`core::comm`] - The deprecated message passing API
59+
* [`core::pipes`] - The new message passing infrastructure and API
60+
* [`std::comm`] - Higher level messaging types based on `core::pipes`
5261
* [`std::sync`] - More exotic synchronization tools, including locks
53-
* [`std::arc`] - The ARC (atomically reference counted) type,
54-
for safely sharing immutable data
62+
* [`std::arc`] - The ARC (atomic reference counted) type, for safely sharing
63+
immutable data
64+
* [`std::par`] - Some basic tools for implementing parallel algorithms
5565

5666
[`core::task`]: core/task.html
5767
[`core::comm`]: core/comm.html
5868
[`core::pipes`]: core/pipes.html
5969
[`std::comm`]: std/comm.html
6070
[`std::sync`]: std/sync.html
6171
[`std::arc`]: std/arc.html
72+
[`std::par`]: std/par.html
6273

6374
# Basics
6475

branches/auto/doc/tutorial.md

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ omitted.
495495

496496
A powerful application of pattern matching is *destructuring*:
497497
matching in order to bind names to the contents of data
498-
types. Assuming that `(float, float)` is a tuple of two floats:
498+
types. Remember that `(float, float)` is a tuple of two floats:
499499

500500
~~~~
501501
fn angle(vector: (float, float)) -> float {
@@ -747,7 +747,7 @@ fn area(sh: Shape) -> float {
747747

748748
Tuples in Rust behave exactly like structs, except that their fields
749749
do not have names. Thus, you cannot access their fields with dot notation.
750-
Tuples can have any arity except for 0 (though you may consider
750+
Tuples can have any arity except for 0 or 1 (though you may consider
751751
unit, `()`, as the empty tuple if you like).
752752

753753
~~~~
@@ -988,7 +988,7 @@ custom destructors.
988988

989989
# Boxes
990990

991-
Many modern languages represent values as pointers to heap memory by
991+
Many modern languages represent values as as pointers to heap memory by
992992
default. In contrast, Rust, like C and C++, represents such types directly.
993993
Another way to say this is that aggregate data in Rust are *unboxed*. This
994994
means that if you `let x = Point { x: 1f, y: 1f };`, you are creating a struct
@@ -1067,28 +1067,6 @@ let mut d = @mut 5; // mutable variable, mutable box
10671067
d = @mut 15;
10681068
~~~~
10691069

1070-
A mutable variable and an immutable variable can refer to the same box, given
1071-
that their types are compatible. Mutability of a box is a property of its type,
1072-
however, so for example a mutable handle to an immutable box cannot be
1073-
assigned a reference to a mutable box.
1074-
1075-
~~~~
1076-
let a = @1; // immutable box
1077-
let b = @mut 2; // mutable box
1078-
1079-
let mut c : @int; // declare a variable with type managed immutable int
1080-
let mut d : @mut int; // and one of type managed mutable int
1081-
1082-
c = a; // box type is the same, okay
1083-
d = b; // box type is the same, okay
1084-
~~~~
1085-
1086-
~~~~ {.xfail-test}
1087-
// but b cannot be assigned to c, or a to d
1088-
c = b; // error
1089-
~~~~
1090-
1091-
10921070
# Move semantics
10931071

10941072
Rust uses a shallow copy for parameter passing, assignment and returning values
@@ -1103,16 +1081,6 @@ let y = x.clone(); // y is a newly allocated box
11031081
let z = x; // no new memory allocated, x can no longer be used
11041082
~~~~
11051083

1106-
Since in owned boxes mutability is a property of the owner, not the
1107-
box, mutable boxes may become immutable when they are moved, and vice-versa.
1108-
1109-
~~~~
1110-
let r = ~13;
1111-
let mut s = r; // box becomes mutable
1112-
*s += 1;
1113-
let t = s; // box becomes immutable
1114-
~~~~
1115-
11161084
# Borrowed pointers
11171085

11181086
Rust's borrowed pointers are a general purpose reference type. In contrast with
@@ -1223,7 +1191,7 @@ they are frozen:
12231191
let x = @mut 5;
12241192
let y = x;
12251193
{
1226-
let z = &*y; // the managed box is now frozen
1194+
let y = &*y; // the managed box is now frozen
12271195
// modifying it through x or y will cause a task failure
12281196
}
12291197
// the box is now unfrozen again
@@ -1920,8 +1888,8 @@ illegal to copy and pass by value.
19201888
Generic `type`, `struct`, and `enum` declarations follow the same pattern:
19211889

19221890
~~~~
1923-
# use core::hashmap::HashMap;
1924-
type Set<T> = HashMap<T, ()>;
1891+
# use core::hashmap::linear::LinearMap;
1892+
type Set<T> = LinearMap<T, ()>;
19251893
19261894
struct Stack<T> {
19271895
elements: ~[T]
@@ -2320,7 +2288,7 @@ impl Shape for CircleStruct {
23202288
Notice that methods of `Circle` can call methods on `Shape`, as our
23212289
`radius` implementation calls the `area` method.
23222290
This is a silly way to compute the radius of a circle
2323-
(since we could just return the `radius` field), but you get the idea.
2291+
(since we could just return the `circle` field), but you get the idea.
23242292

23252293
In type-parameterized functions,
23262294
methods of the supertrait may be called on values of subtrait-bound type parameters.

branches/auto/man/rustc.1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,5 @@ See \fBAUTHORS.txt\fR in the rust source distribution. Graydon Hoare
170170
<\fI[email protected]\fR> is the project leader.
171171

172172
.SH "COPYRIGHT"
173-
This work is dual-licensed under Apache 2.0 and MIT terms. See \fBCOPYRIGHT\fR
174-
file in the rust source distribution.
173+
This work is licensed under MIT-like terms. See \fBLICENSE.txt\fR
174+
in the rust source distribution.

branches/auto/mk/dist.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ PKG_FILES := \
1818
$(S)COPYRIGHT \
1919
$(S)LICENSE-APACHE \
2020
$(S)LICENSE-MIT \
21-
$(S)AUTHORS.txt \
2221
$(S)README.md \
2322
$(S)configure $(S)Makefile.in \
2423
$(S)man \

branches/auto/mk/install.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ install-host: $(CSREQ$(ISTAGE)_T_$(CFG_BUILD_TRIPLE)_H_$(CFG_BUILD_TRIPLE))
119119
$(Q)$(call INSTALL_LIB,$(HL),$(PHL),$(LIBSYNTAX_GLOB_$(CFG_BUILD_TRIPLE)))
120120
$(Q)$(call INSTALL_LIB,$(HL),$(PHL),$(LIBRUSTI_GLOB_$(CFG_BUILD_TRIPLE)))
121121
$(Q)$(call INSTALL_LIB,$(HL),$(PHL),$(LIBRUST_GLOB_$(CFG_BUILD_TRIPLE)))
122-
$(Q)$(call INSTALL_LIB,$(HL),$(PHL),$(LIBRUSTPKG_GLOB_$(CFG_BUILD_TRIPLE)))
123-
$(Q)$(call INSTALL_LIB,$(HL),$(PHL),$(LIBRUSTDOC_GLOB_$(CFG_BUILD_TRIPLE)))
124122
$(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_RUNTIME_$(CFG_BUILD_TRIPLE)))
125123
$(Q)$(call INSTALL,$(HL),$(PHL),$(CFG_RUSTLLVM_$(CFG_BUILD_TRIPLE)))
126124
$(Q)$(call INSTALL,$(S)/man, \

branches/auto/mk/platform.mk

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -239,31 +239,6 @@ CFG_RUN_arm-linux-androideabi=
239239
CFG_RUN_TARG_arm-linux-androideabi=
240240
RUSTC_FLAGS_arm-linux-androideabi :=--android-cross-path=$(CFG_ANDROID_CROSS_PATH)
241241

242-
# mips-unknown-linux-gnu configuration
243-
CC_mips-unknown-linux-gnu=mips-linux-gnu-gcc
244-
CXX_mips-unknown-linux-gnu=mips-linux-gnu-g++
245-
CPP_mips-unknown-linux-gnu=mips-linux-gnu-gcc -E
246-
AR_mips-unknown-linux-gnu=mips-linux-gnu-ar
247-
CFG_LIB_NAME_mips-unknown-linux-gnu=lib$(1).so
248-
CFG_LIB_GLOB_mips-unknown-linux-gnu=lib$(1)-*.so
249-
CFG_LIB_DSYM_GLOB_mips-unknown-linux-gnu=lib$(1)-*.dylib.dSYM
250-
CFG_GCCISH_CFLAGS_mips-unknown-linux-gnu := -Wall -g -fPIC -mips32r2 -msoft-float -mabi=32
251-
CFG_GCCISH_CXXFLAGS_mips-unknown-linux-gnu := -fno-rtti
252-
CFG_GCCISH_LINK_FLAGS_mips-unknown-linux-gnu := -shared -fPIC -g -mips32r2 -msoft-float -mabi=32
253-
CFG_GCCISH_DEF_FLAG_mips-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list=
254-
CFG_GCCISH_PRE_LIB_FLAGS_mips-unknown-linux-gnu := -Wl,-whole-archive
255-
CFG_GCCISH_POST_LIB_FLAGS_mips-unknown-linux-gnu := -Wl,-no-whole-archive -Wl,-znoexecstack
256-
CFG_DEF_SUFFIX_mips-unknown-linux-gnu := .linux.def
257-
CFG_INSTALL_NAME_mips-unknown-linux-gnu =
258-
CFG_LIBUV_LINK_FLAGS_mips-unknown-linux-gnu =
259-
CFG_EXE_SUFFIX_mips-unknown-linux-gnu :=
260-
CFG_WINDOWSY_mips-unknown-linux-gnu :=
261-
CFG_UNIXY_mips-unknown-linux-gnu := 1
262-
CFG_PATH_MUNGE_mips-unknown-linux-gnu := true
263-
CFG_LDPATH_mips-unknown-linux-gnu :=
264-
CFG_RUN_mips-unknown-linux-gnu=
265-
CFG_RUN_TARG_mips-unknown-linux-gnu=
266-
267242
# i686-pc-mingw32 configuration
268243
CC_i686-pc-mingw32=$(CC)
269244
CXX_i686-pc-mingw32=$(CXX)

branches/auto/mk/rt.mk

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
LIBUV_FLAGS_i386 = -m32 -fPIC
2828
LIBUV_FLAGS_x86_64 = -m64 -fPIC
2929
LIBUV_FLAGS_arm = -fPIC -DANDROID -std=gnu99
30-
LIBUV_FLAGS_mips = -fPIC -mips32r2 -msoft-float -mabi=32
3130

3231
# when we're doing a snapshot build, we intentionally degrade as many
3332
# features in libuv and the runtime as possible, to ease portability.
@@ -181,10 +180,6 @@ else
181180
$$(LIBUV_LIB_$(1)): $$(LIBUV_DEPS)
182181
$$(Q)$$(MAKE) -C $$(S)src/libuv/ \
183182
CFLAGS="$$(LIBUV_FLAGS_$$(HOST_$(1))) $$(SNAP_DEFINES)" \
184-
LDFLAGS="$$(LIBUV_FLAGS_$$(HOST_$(1)))" \
185-
CC="$$(CC_$(1))" \
186-
CXX="$$(CXX_$(1))" \
187-
AR="$$(AR_$(1))" \
188183
builddir_name="$$(CFG_BUILD_DIR)/rt/$(1)/libuv" \
189184
V=$$(VERBOSE)
190185
endif

branches/auto/src/compiletest/procsrv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn target_env(lib_path: ~str, prog: ~str) -> ~[(~str,~str)] {
2626

2727
// Make sure we include the aux directory in the path
2828
assert!(prog.ends_with(~".exe"));
29-
let aux_path = prog.slice(0u, prog.len() - 4u).to_owned() + ~".libaux";
29+
let aux_path = prog.slice(0u, prog.len() - 4u) + ~".libaux";
3030
3131
env = do vec::map(env) |pair| {
3232
let (k,v) = *pair;

branches/auto/src/etc/vim/syntax/rust.vim

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,8 @@ syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\%([eE][+-]\=[0-9
110110
syn match rustLifetime display "\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*"
111111
syn match rustCharacter "'\([^'\\]\|\\\(['nrt\\\"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'"
112112

113-
syn region rustCommentDoc start="/\*\*" end="\*/"
114-
syn region rustCommentDoc start="///" skip="\\$" end="$" keepend
115-
syn match rustComment "/\*\*/"
116-
syn region rustComment start="/\*\([^\*]\|$\)" end="\*/" contains=rustTodo
117-
syn region rustComment start="//\([^/]\|$\)" skip="\\$" end="$" contains=rustTodo keepend
113+
syn region rustComment start="/\*" end="\*/" contains=rustComment,rustTodo
114+
syn region rustComment start="//" skip="\\$" end="$" contains=rustTodo keepend
118115

119116
syn keyword rustTodo contained TODO FIXME XXX NB
120117

@@ -137,7 +134,6 @@ hi def link rustConditional Conditional
137134
hi def link rustIdentifier Identifier
138135
hi def link rustModPath Include
139136
hi def link rustFuncName Function
140-
hi def link rustCommentDoc SpecialComment
141137
hi def link rustComment Comment
142138
hi def link rustMacro Macro
143139
hi def link rustType Type

0 commit comments

Comments
 (0)