Skip to content

Commit 1d46cb0

Browse files
committed
---
yaml --- r: 42003 b: refs/heads/master c: aff3db2 h: refs/heads/master i: 42001: 1ebe3ab 41999: 86f379d v: v3
1 parent 4f2ae41 commit 1d46cb0

File tree

344 files changed

+10838
-7675
lines changed

Some content is hidden

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

344 files changed

+10838
-7675
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: 19aa88cd64c81b77b874f9396a43fedfa28f14ee
2+
refs/heads/master: aff3db26aa6e427b68fea577548a270cacdd0153
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

trunk/AUTHORS.txt

Lines changed: 6 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]>
@@ -143,4 +148,5 @@ Vincent Belliard <[email protected]>
143148
Wade Mealing <[email protected]>
144149
William Ting <[email protected]>
145150
Yasuhiro Fujii <[email protected]>
151+
Youngsoo Son <[email protected]>
146152
Zack Corr <[email protected]>

trunk/doc/rust.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ let log loop
222222
match mod move mut
223223
priv pub pure
224224
ref return
225-
self static struct
225+
self static struct super
226226
true trait type
227227
unsafe use
228228
while
@@ -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-ffi.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ fn as_hex(data: ~[u8]) -> ~str {
2626
return acc;
2727
}
2828
29-
fn sha1(data: ~str) -> ~str unsafe {
30-
let bytes = str::to_bytes(data);
31-
let hash = crypto::SHA1(vec::raw::to_ptr(bytes),
32-
vec::len(bytes) as c_uint, ptr::null());
33-
return as_hex(vec::from_buf(hash, 20));
29+
fn sha1(data: ~str) -> ~str {
30+
unsafe {
31+
let bytes = str::to_bytes(data);
32+
let hash = crypto::SHA1(vec::raw::to_ptr(bytes),
33+
vec::len(bytes) as c_uint,
34+
ptr::null());
35+
return as_hex(vec::from_buf(hash, 20));
36+
}
3437
}
3538
3639
fn main() {
@@ -225,13 +228,15 @@ struct timeval {
225228
extern mod lib_c {
226229
fn gettimeofday(tv: *timeval, tz: *()) -> i32;
227230
}
228-
fn unix_time_in_microseconds() -> u64 unsafe {
229-
let x = timeval {
230-
mut tv_sec: 0 as c_ulonglong,
231-
mut tv_usec: 0 as c_ulonglong
232-
};
233-
lib_c::gettimeofday(ptr::addr_of(&x), ptr::null());
234-
return (x.tv_sec as u64) * 1000_000_u64 + (x.tv_usec as u64);
231+
fn unix_time_in_microseconds() -> u64 {
232+
unsafe {
233+
let x = timeval {
234+
mut tv_sec: 0 as c_ulonglong,
235+
mut tv_usec: 0 as c_ulonglong
236+
};
237+
lib_c::gettimeofday(ptr::addr_of(&x), ptr::null());
238+
return (x.tv_sec as u64) * 1000_000_u64 + (x.tv_usec as u64);
239+
}
235240
}
236241
237242
# fn main() { assert fmt!("%?", unix_time_in_microseconds()) != ~""; }

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/compiletest.rc

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,10 @@ fn run_tests(config: config) {
158158
}
159159

160160
fn test_opts(config: config) -> test::TestOpts {
161-
{filter:
162-
match config.filter {
163-
option::Some(s) => option::Some(s),
164-
option::None => option::None
165-
},
166-
run_ignored: config.run_ignored,
167-
logfile:
168-
match config.logfile {
169-
option::Some(s) => option::Some(s.to_str()),
170-
option::None => option::None
171-
}
161+
test::TestOpts {
162+
filter: config.filter,
163+
run_ignored: config.run_ignored,
164+
logfile: config.logfile.map(|s| s.to_str()),
172165
}
173166
}
174167

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
}

0 commit comments

Comments
 (0)