Skip to content

Commit 1559fb3

Browse files
committed
---
yaml --- r: 41942 b: refs/heads/master c: 25184da h: refs/heads/master v: v3
1 parent bbab773 commit 1559fb3

File tree

266 files changed

+8033
-5547
lines changed

Some content is hidden

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

266 files changed

+8033
-5547
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: bc0c5bb447ac8eba0a80599305c23db6c8a1ed6a
2+
refs/heads/master: 25184da1e722095902725ef520590fc464faf082
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

trunk/AUTHORS.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ Other authors:
77

88
Adam Bozanich <[email protected]>
99
Aleksander Balicki <[email protected]>
10+
Alex Crichton <[email protected]>
1011
Alex Rønne Petersen <[email protected]>
1112
Alexander Stavonin <[email protected]>
1213
Andreas Gal <[email protected]>
1314
Andrew Dunham <[email protected]>
1415
Andrew Paseltiner <[email protected]>
1516
Arkaitz Jimenez <[email protected]>
1617
Armin Ronacher <[email protected]>
18+
Ashok Gautham <[email protected]>
1719
Austin Seipp <[email protected]>
1820
1921
Ben Alpert <[email protected]>
@@ -24,6 +26,7 @@ Benjamin Jackman <[email protected]>
2426
Benjamin Kircher <[email protected]>
2527
Benjamin Peterson <[email protected]>
2628
Bilal Husain <[email protected]>
29+
Bill Fallon <[email protected]>
2730
Brendan Eich <[email protected]>
2831
Brian Anderson <[email protected]>
2932
Brian J. Burg <[email protected]>
@@ -88,6 +91,7 @@ Kelly Wilson <[email protected]>
8891
Kevin Atkinson <[email protected]>
8992
Kevin Cantu <[email protected]>
9093
Kyeongwoon Lee <[email protected]>
94+
Laurent Bonnans <[email protected]>
9195
Lennart Kudling <[email protected]>
9296
Lindsey Kuper <[email protected]>
9397
Luca Bruno <[email protected]>
@@ -127,6 +131,7 @@ Sean Stangl <[email protected]>
127131
Sebastian N. Fernandez <[email protected]>
128132
Seo Sanghyeon <[email protected]>
129133
Simon Barber-Dueck <[email protected]>
134+
Simon Sapin <[email protected]>
130135
startling <[email protected]>
131136
Stefan Plantikow <[email protected]>
132137
Steve Klabnik <[email protected]>

trunk/doc/rust.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -594,16 +594,16 @@ and may optionally begin with any number of `attributes` that apply to the conta
594594
Atributes on the anonymous crate module define important metadata that influences
595595
the behavior of the compiler.
596596

597-
~~~~~~~~{.xfail-test}
597+
~~~~~~~~
598598
// Linkage attributes
599-
#[ link(name = "projx"
599+
#[ link(name = "projx",
600600
vers = "2.5",
601601
uuid = "9cccc5d5-aceb-4af5-8285-811211826b82") ];
602602
603603
// Additional metadata attributes
604-
#[ desc = "Project X",
605-
license = "BSD" ];
606-
author = "Jane Doe" ];
604+
#[ desc = "Project X" ];
605+
#[ license = "BSD" ];
606+
#[ author = "Jane Doe" ];
607607
608608
// Specify the output type
609609
#[ crate_type = "lib" ];
@@ -2472,7 +2472,7 @@ disabled dynamically at run-time on a per-task and per-item basis. See
24722472
Each `log` expression must be provided with a *level* argument in
24732473
addition to the value to log. The logging level is a `u32` value, where
24742474
lower levels indicate more-urgent levels of logging. By default, the lowest
2475-
four logging levels (`0_u32 ... 3_u32`) are predefined as the constants
2475+
four logging levels (`1_u32 ... 4_u32`) are predefined as the constants
24762476
`error`, `warn`, `info` and `debug` in the `core` library.
24772477

24782478
Additionally, the macros `error!`, `warn!`, `info!` and `debug!` are defined
@@ -3018,6 +3018,11 @@ Local variables are immutable unless declared with `let mut`. The
30183018
declaration (so `let mut x, y` declares two mutable variables, `x` and
30193019
`y`).
30203020

3021+
Function parameters are immutable unless declared with `mut`. The
3022+
`mut` keyword applies only to the following parameter (so `|mut x, y|`
3023+
and `fn f(mut x: ~int, y: ~int)` declare one mutable variable `x` and
3024+
one immutable variable `y`).
3025+
30213026
Local variables are not initialized when allocated; the entire frame worth of
30223027
local variables are allocated at once, on frame-entry, in an uninitialized
30233028
state. Subsequent statements within a function may or may not initialize the
@@ -3242,10 +3247,10 @@ level will be output to the console.
32423247
The path to a module consists of the crate name, any parent modules,
32433248
then the module itself, all separated by double colons (`::`). The
32443249
optional log level can be appended to the module path with an equals
3245-
sign (`=`) followed by the log level, from 0 to 3, inclusive. Level 0
3246-
is the error level, 1 is warning, 2 info, and 3 debug. Any logs
3250+
sign (`=`) followed by the log level, from 1 to 4, inclusive. Level 1
3251+
is the error level, 2 is warning, 3 info, and 4 debug. Any logs
32473252
less than or equal to the specified level will be output. If not
3248-
specified then log level 3 is assumed.
3253+
specified then log level 4 is assumed.
32493254

32503255
As an example, to see all the logs generated by the compiler, you would set
32513256
`RUST_LOG` to `rustc`, which is the crate name (as specified in its `link`

trunk/doc/tutorial-tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ let result = port.recv();
220220
The `Port` and `Chan` pair created by `stream` enables efficient communication
221221
between a single sender and a single receiver, but multiple senders cannot use
222222
a single `Chan`, and multiple receivers cannot use a single `Port`. What if our
223-
example needed to computer multiple results across a number of tasks? The
223+
example needed to compute multiple results across a number of tasks? The
224224
following program is ill-typed:
225225

226226
~~~ {.xfail-test}

trunk/doc/tutorial.md

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -863,11 +863,34 @@ allocating memory and indirecting through a pointer. But for big structs, or
863863
those with mutable fields, it can be useful to have a single copy on
864864
the stack or on the heap, and refer to that through a pointer.
865865

866-
Rust supports several types of pointers. The safe pointer types are
867-
`@T`, for managed boxes allocated on the local heap, `~T`, for
868-
uniquely-owned boxes allocated on the exchange heap, and `&T`, for
869-
borrowed pointers, which may point to any memory, and whose lifetimes
870-
are governed by the call stack.
866+
Whenever memory is allocated on the heap, the program needs a strategy to
867+
dispose of the memory when no longer needed. Most languages, such as Java or
868+
Python, use *garbage collection* for this, a strategy in which the program
869+
periodically searches for allocations that are no longer reachable in order
870+
to dispose of them. Other languages, such as C, use *manual memory
871+
management*, which relies on the programmer to specify when memory should be
872+
reclaimed.
873+
874+
Rust is in a different position. It differs from the garbage-collected
875+
environments in that allows the programmer to choose the disposal
876+
strategy on an object-by-object basis. Not only does this have benefits for
877+
performance, but we will later see that this model has benefits for
878+
concurrency as well, by making it possible for the Rust compiler to detect
879+
data races at compile time. Rust also differs from the manually managed
880+
languages in that it is *safe*—it uses a [pointer lifetime
881+
analysis][borrow] to ensure that manual memory management cannot cause memory
882+
errors at runtime.
883+
884+
[borrow]: tutorial-borrowed-ptr.html
885+
886+
The cornerstone of Rust's memory management is the concept of a *smart
887+
pointer*—a pointer type that indicates the lifetime of the object it points
888+
to. This solution is familiar to C++ programmers; Rust differs from C++,
889+
however, in that a small set of smart pointers are built into the language.
890+
The safe pointer types are `@T`, for *managed* boxes allocated on the *local
891+
heap*, `~T`, for *uniquely-owned* boxes allocated on the *exchange
892+
heap*, and `&T`, for *borrowed* pointers, which may point to any memory, and
893+
whose lifetimes are governed by the call stack.
871894

872895
All pointer types can be dereferenced with the `*` unary operator.
873896

@@ -919,7 +942,17 @@ node2.next = SomeNode(node3);
919942
node3.prev = SomeNode(node2);
920943
~~~
921944

922-
Managed boxes never cross task boundaries.
945+
Managed boxes never cross task boundaries. This has several benefits for
946+
performance:
947+
948+
* The Rust garbage collector does not need to stop multiple threads in order
949+
to collect garbage.
950+
951+
* You can separate your application into "real-time" tasks that do not use
952+
the garbage collector and "non-real-time" tasks that do, and the real-time
953+
tasks will not be interrupted by the non-real-time tasks.
954+
955+
C++ programmers will recognize `@T` as similar to `std::shared_ptr<T>`.
923956

924957
> ***Note:*** Currently, the Rust compiler generates code to reclaim
925958
> managed boxes through reference counting and a cycle collector, but
@@ -956,10 +989,19 @@ let z = *x + *y;
956989
assert z == 20;
957990
~~~~
958991

959-
Owned boxes, when they do not contain any managed boxes, can be sent
960-
to other tasks. The sending task will give up ownership of the box,
992+
When they do not contain any managed boxes, owned boxes can be sent
993+
to other tasks. The sending task will give up ownership of the box
961994
and won't be able to access it afterwards. The receiving task will
962-
become the sole owner of the box.
995+
become the sole owner of the box. This prevents *data races*—errors
996+
that could otherwise result from multiple tasks working on the same
997+
data without synchronization.
998+
999+
When an owned pointer goes out of scope or is overwritten, the object
1000+
it points to is immediately freed. Effective use of owned boxes can
1001+
therefore be an efficient alternative to garbage collection.
1002+
1003+
C++ programmers will recognize `~T` as similar to `std::unique_ptr<T>`
1004+
(or `std::auto_ptr<T>` in C++03 and below).
9631005

9641006
## Borrowed pointers
9651007

@@ -1184,6 +1226,18 @@ match crayons[0] {
11841226
}
11851227
~~~~
11861228
1229+
A vector can be destructured using pattern matching:
1230+
1231+
~~~~
1232+
let numbers: [int * 3] = [1, 2, 3];
1233+
let score = match numbers {
1234+
[] => 0,
1235+
[a] => a * 10,
1236+
[a, b] => a * 6 + b * 4,
1237+
[a, b, c, ..rest] => a * 5 + b * 3 + c * 2 + rest.len() as int
1238+
};
1239+
~~~~
1240+
11871241
The elements of a vector _inherit the mutability of the vector_,
11881242
and as such, individual elements may not be reassigned when the
11891243
vector lives in an immutable slot.
@@ -2351,7 +2405,7 @@ override the name used to search for the crate.
23512405

23522406
Our example crate declared this set of `link` attributes:
23532407

2354-
~~~~ {.xfail-test}
2408+
~~~~
23552409
#[link(name = "farm", vers = "2.5", author = "mjh")];
23562410
~~~~
23572411

trunk/src/compiletest/errors.rs

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,34 +33,36 @@ fn load_errors(testfile: &Path) -> ~[expected_error] {
3333
return error_patterns;
3434
}
3535

36-
fn parse_expected(line_num: uint, line: ~str) -> ~[expected_error] unsafe {
37-
let error_tag = ~"//~";
38-
let mut idx;
39-
match str::find_str(line, error_tag) {
40-
None => return ~[],
41-
Some(nn) => { idx = (nn as uint) + str::len(error_tag); }
42-
}
36+
fn parse_expected(line_num: uint, line: ~str) -> ~[expected_error] {
37+
unsafe {
38+
let error_tag = ~"//~";
39+
let mut idx;
40+
match str::find_str(line, error_tag) {
41+
None => return ~[],
42+
Some(nn) => { idx = (nn as uint) + str::len(error_tag); }
43+
}
4344

44-
// "//~^^^ kind msg" denotes a message expected
45-
// three lines above current line:
46-
let mut adjust_line = 0u;
47-
let len = str::len(line);
48-
while idx < len && line[idx] == ('^' as u8) {
49-
adjust_line += 1u;
50-
idx += 1u;
51-
}
45+
// "//~^^^ kind msg" denotes a message expected
46+
// three lines above current line:
47+
let mut adjust_line = 0u;
48+
let len = str::len(line);
49+
while idx < len && line[idx] == ('^' as u8) {
50+
adjust_line += 1u;
51+
idx += 1u;
52+
}
5253

53-
// Extract kind:
54-
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
55-
let start_kind = idx;
56-
while idx < len && line[idx] != (' ' as u8) { idx += 1u; }
57-
let kind = str::to_lower(str::slice(line, start_kind, idx));
54+
// Extract kind:
55+
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
56+
let start_kind = idx;
57+
while idx < len && line[idx] != (' ' as u8) { idx += 1u; }
58+
let kind = str::to_lower(str::slice(line, start_kind, idx));
5859

59-
// Extract msg:
60-
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
61-
let msg = str::slice(line, idx, len);
60+
// Extract msg:
61+
while idx < len && line[idx] == (' ' as u8) { idx += 1u; }
62+
let msg = str::slice(line, idx, len);
6263

63-
debug!("line=%u kind=%s msg=%s", line_num - adjust_line, kind, msg);
64+
debug!("line=%u kind=%s msg=%s", line_num - adjust_line, kind, msg);
6465

65-
return ~[{line: line_num - adjust_line, kind: kind, msg: msg}];
66+
return ~[{line: line_num - adjust_line, kind: kind, msg: msg}];
67+
}
6668
}

trunk/src/compiletest/header.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,17 @@ fn parse_name_directive(line: ~str, directive: ~str) -> bool {
146146
}
147147

148148
fn parse_name_value_directive(line: ~str,
149-
directive: ~str) -> Option<~str> unsafe {
150-
let keycolon = directive + ~":";
151-
match str::find_str(line, keycolon) {
152-
Some(colon) => {
153-
let value = str::slice(line, colon + str::len(keycolon),
154-
str::len(line));
155-
debug!("%s: %s", directive, value);
156-
Some(value)
149+
directive: ~str) -> Option<~str> {
150+
unsafe {
151+
let keycolon = directive + ~":";
152+
match str::find_str(line, keycolon) {
153+
Some(colon) => {
154+
let value = str::slice(line, colon + str::len(keycolon),
155+
str::len(line));
156+
debug!("%s: %s", directive, value);
157+
Some(value)
158+
}
159+
None => None
157160
}
158-
None => None
159161
}
160162
}

trunk/src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ fn check_expected_errors(expected_errors: ~[errors::expected_error],
273273
procres: procres) {
274274

275275
// true if we found the error in question
276-
let found_flags = vec::to_mut(vec::from_elem(
276+
let found_flags = vec::cast_to_mut(vec::from_elem(
277277
vec::len(expected_errors), false));
278278

279279
if procres.status == 0 {

trunk/src/etc/check-summary.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# xfail-license
23

34
import sys
45

trunk/src/etc/combine-tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# xfail-license
23

34
# this combines all the working run-pass tests into a single large crate so we
45
# can run it "fast": spawning zillions of windows processes is our major build

trunk/src/etc/extract-tests.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
# xfail-license
2+
13
# Script for extracting compilable fragments from markdown
24
# documentation. See prep.js for a description of the format
3-
# recognized by this tool. Expects a directory fragements/ to exist
5+
# recognized by this tool. Expects a directory fragments/ to exist
46
# under the current directory, and writes the fragments in there as
57
# individual .rs files.
68

7-
import sys, re;
9+
import sys, re
810

911
if len(sys.argv) < 3:
1012
print("Please provide an input filename")
@@ -24,7 +26,7 @@
2426
while cur < len(lines):
2527
line = lines[cur]
2628
cur += 1
27-
chap = re.match("# (.*)", line);
29+
chap = re.match("# (.*)", line)
2830
if chap:
2931
chapter = re.sub(r"\W", "_", chap.group(1)).lower()
3032
chapter_n = 1
@@ -49,14 +51,30 @@
4951
else:
5052
# Lines beginning with '# ' are turned into valid code
5153
line = re.sub("^# ", "", line)
52-
# Allow elipses in code snippets
54+
# Allow ellipses in code snippets
5355
line = re.sub("\.\.\.", "", line)
5456
block += line
5557
if not ignore:
5658
if not re.search(r"\bfn main\b", block):
5759
block = "fn main() {\n" + block + "\n}\n"
5860
if not re.search(r"\bextern mod std\b", block):
59-
block = "extern mod std;\n" + block;
61+
block = "extern mod std;\n" + block
62+
block = """#[ forbid(ctypes) ];
63+
#[ forbid(deprecated_mode) ];
64+
#[ forbid(deprecated_pattern) ];
65+
#[ forbid(implicit_copies) ];
66+
#[ forbid(non_implicitly_copyable_typarams) ];
67+
#[ forbid(path_statement) ];
68+
#[ forbid(type_limits) ];
69+
#[ forbid(unrecognized_lint) ];
70+
#[ forbid(unused_imports) ];
71+
#[ forbid(vecs_implicitly_copyable) ];
72+
#[ forbid(while_true) ];
73+
74+
#[ warn(deprecated_self) ];
75+
#[ warn(non_camel_case_types) ];
76+
#[ warn(structural_records) ];\n
77+
""" + block
6078
if xfail:
6179
block = "// xfail-test\n" + block
6280
filename = (dest + "/" + str(chapter)

trunk/src/etc/extract_grammar.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# xfail-license
23

34
# This script is for extracting the grammar from the rust docs.
45

0 commit comments

Comments
 (0)