Skip to content

Commit 161054c

Browse files
committed
---
yaml --- r: 42229 b: refs/heads/master c: f6c8412 h: refs/heads/master i: 42227: 0c964df v: v3
1 parent fd2ebc7 commit 161054c

File tree

105 files changed

+638
-510
lines changed

Some content is hidden

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

105 files changed

+638
-510
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: 6052d6747448ec3d83976147de4948a10f43379e
2+
refs/heads/master: f6c84129b40f25dd7846bfe169bf4c3a022d66e5
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

trunk/doc/lib/codemirror-rust.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CodeMirror.defineMode("rust", function() {
22
var indentUnit = 4, altIndentUnit = 2;
33
var valKeywords = {
44
"if": "if-style", "while": "if-style", "loop": "if-style", "else": "else-style",
5-
"do": "else-style", "return": "else-style", "fail": "else-style",
5+
"do": "else-style", "return": "else-style",
66
"break": "atom", "cont": "atom", "const": "let", "resource": "fn",
77
"let": "let", "fn": "fn", "for": "for", "match": "match", "trait": "trait",
88
"impl": "impl", "type": "type", "enum": "enum", "struct": "atom", "mod": "mod",

trunk/doc/rust.md

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ break
216216
const copy
217217
do drop
218218
else enum extern
219-
fail false fn for
219+
false fn for
220220
if impl
221221
let log loop
222222
match mod move mut
@@ -692,15 +692,15 @@ mod math {
692692
type complex = (f64, f64);
693693
fn sin(f: f64) -> f64 {
694694
...
695-
# fail;
695+
# die!();
696696
}
697697
fn cos(f: f64) -> f64 {
698698
...
699-
# fail;
699+
# die!();
700700
}
701701
fn tan(f: f64) -> f64 {
702702
...
703-
# fail;
703+
# die!();
704704
}
705705
}
706706
~~~~~~~~
@@ -851,6 +851,9 @@ mod quux {
851851

852852
In this example, the module `quux` re-exports all of the public names defined in `foo`.
853853

854+
Also note that the paths contained in `use` items are relative to the crate root; so, in the previous
855+
example, the use refers to `quux::foo::*`, and not simply to `foo::*`.
856+
854857
### Functions
855858

856859
A _function item_ defines a sequence of [statements](#statements) and an optional final [expression](#expressions), along with a name and a set of parameters.
@@ -989,13 +992,13 @@ output slot type would normally be. For example:
989992
~~~~
990993
fn my_err(s: &str) -> ! {
991994
log(info, s);
992-
fail;
995+
die!();
993996
}
994997
~~~~
995998

996999
We call such functions "diverging" because they never return a value to the
9971000
caller. Every control path in a diverging function must end with a
998-
[`fail`](#fail-expressions) or a call to another diverging function on every
1001+
`fail!()` or a call to another diverging function on every
9991002
control path. The `!` annotation does *not* denote a type. Rather, the result
10001003
type of a diverging function is a special type called $\bot$ ("bottom") that
10011004
unifies with any type. Rust has no syntax for $\bot$.
@@ -1007,7 +1010,7 @@ were declared without the `!` annotation, the following code would not
10071010
typecheck:
10081011

10091012
~~~~
1010-
# fn my_err(s: &str) -> ! { fail }
1013+
# fn my_err(s: &str) -> ! { die!() }
10111014
10121015
fn f(i: int) -> int {
10131016
if i == 42 {
@@ -2291,9 +2294,9 @@ enum List<X> { Nil, Cons(X, @List<X>) }
22912294
let x: List<int> = Cons(10, @Cons(11, @Nil));
22922295
22932296
match x {
2294-
Cons(_, @Nil) => fail ~"singleton list",
2297+
Cons(_, @Nil) => die!(~"singleton list"),
22952298
Cons(*) => return,
2296-
Nil => fail ~"empty list"
2299+
Nil => die!(~"empty list")
22972300
}
22982301
~~~~
22992302

@@ -2330,7 +2333,7 @@ match x {
23302333
return;
23312334
}
23322335
_ => {
2333-
fail;
2336+
die!();
23342337
}
23352338
}
23362339
~~~~
@@ -2418,23 +2421,10 @@ guard may refer to the variables bound within the pattern they follow.
24182421
let message = match maybe_digit {
24192422
Some(x) if x < 10 => process_digit(x),
24202423
Some(x) => process_other(x),
2421-
None => fail
2424+
None => die!()
24222425
};
24232426
~~~~
24242427

2425-
2426-
### Fail expressions
2427-
2428-
~~~~~~~~{.ebnf .gram}
2429-
fail_expr : "fail" expr ? ;
2430-
~~~~~~~~
2431-
2432-
Evaluating a `fail` expression causes a task to enter the *failing* state. In
2433-
the *failing* state, a task unwinds its stack, destroying all frames and
2434-
running all destructors until it reaches its entry frame, at which point it
2435-
halts execution in the *dead* state.
2436-
2437-
24382428
### Return expressions
24392429

24402430
~~~~~~~~{.ebnf .gram}
@@ -3154,7 +3144,7 @@ unblock and transition back to *running*.
31543144

31553145
A task may transition to the *failing* state at any time, due being
31563146
killed by some external event or internally, from the evaluation of a
3157-
`fail` expression. Once *failing*, a task unwinds its stack and
3147+
`fail!()` macro. Once *failing*, a task unwinds its stack and
31583148
transitions to the *dead* state. Unwinding the stack of a task is done by
31593149
the task itself, on its own control stack. If a value with a destructor is
31603150
freed during unwinding, the code for the destructor is run, also on the task's

trunk/doc/tutorial-macros.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ match x {
218218
// complicated stuff goes here
219219
return result + val;
220220
},
221-
_ => fail ~"Didn't get good_2"
221+
_ => die!(~"Didn't get good_2")
222222
}
223223
}
224224
_ => return 0 // default value
@@ -260,7 +260,7 @@ macro_rules! biased_match (
260260
biased_match!((x) ~ (good_1(g1, val)) else { return 0 };
261261
binds g1, val )
262262
biased_match!((g1.body) ~ (good_2(result) )
263-
else { fail ~"Didn't get good_2" };
263+
else { die!(~"Didn't get good_2") };
264264
binds result )
265265
// complicated stuff goes here
266266
return result + val;
@@ -362,7 +362,7 @@ macro_rules! biased_match (
362362
# fn f(x: t1) -> uint {
363363
biased_match!(
364364
(x) ~ (good_1(g1, val)) else { return 0 };
365-
(g1.body) ~ (good_2(result) ) else { fail ~"Didn't get good_2" };
365+
(g1.body) ~ (good_2(result) ) else { die!(~"Didn't get good_2") };
366366
binds val, result )
367367
// complicated stuff goes here
368368
return result + val;

trunk/doc/tutorial-tasks.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cheaper to create than traditional threads, Rust can create hundreds of
1313
thousands of concurrent tasks on a typical 32-bit system.
1414

1515
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
16+
code (as a result of an explicit call to `fail!()`, an assertion failure, or
1717
another invalid operation), the runtime system destroys the entire
1818
task. Unlike in languages such as Java and C++, there is no way to `catch` an
1919
exception. Instead, tasks may monitor each other for failure.
@@ -296,9 +296,9 @@ let result = ports.foldl(0, |accum, port| *accum + port.recv() );
296296

297297
# Handling task failure
298298

299-
Rust has a built-in mechanism for raising exceptions. The `fail` construct
300-
(which can also be written with an error string as an argument: `fail
301-
~reason`) and the `assert` construct (which effectively calls `fail` if a
299+
Rust has a built-in mechanism for raising exceptions. The `fail!()` macro
300+
(which can also be written with an error string as an argument: `fail!(
301+
~reason)`) and the `assert` construct (which effectively calls `fail!()` if a
302302
boolean expression is false) are both ways to raise exceptions. When a task
303303
raises an exception the task unwinds its stack---running destructors and
304304
freeing memory along the way---and then exits. Unlike exceptions in C++,
@@ -313,7 +313,7 @@ of all tasks are intertwined: if one fails, so do all the others.
313313
# fn do_some_work() { loop { task::yield() } }
314314
# do task::try {
315315
// Create a child task that fails
316-
do spawn { fail }
316+
do spawn { die!() }
317317
318318
// This will also fail because the task we spawned failed
319319
do_some_work();
@@ -337,7 +337,7 @@ let result: Result<int, ()> = do task::try {
337337
if some_condition() {
338338
calculate_result()
339339
} else {
340-
fail ~"oops!";
340+
die!(~"oops!");
341341
}
342342
};
343343
assert result.is_err();
@@ -354,7 +354,7 @@ an `Error` result.
354354
> ***Note:*** A failed task does not currently produce a useful error
355355
> value (`try` always returns `Err(())`). In the
356356
> future, it may be possible for tasks to intercept the value passed to
357-
> `fail`.
357+
> `fail!()`.
358358
359359
TODO: Need discussion of `future_result` in order to make failure
360360
modes useful.
@@ -377,7 +377,7 @@ either task dies, it kills the other one.
377377
# do task::try {
378378
do task::spawn {
379379
do task::spawn {
380-
fail; // All three tasks will die.
380+
die!(); // All three tasks will die.
381381
}
382382
sleep_forever(); // Will get woken up by force, then fail
383383
}
@@ -432,7 +432,7 @@ do task::spawn_supervised {
432432
// Intermediate task immediately exits
433433
}
434434
wait_for_a_while();
435-
fail; // Will kill grandchild even if child has already exited
435+
die!(); // Will kill grandchild even if child has already exited
436436
# };
437437
~~~
438438

@@ -446,10 +446,10 @@ other at all, using `task::spawn_unlinked` for _isolated failure_.
446446
let (time1, time2) = (random(), random());
447447
do task::spawn_unlinked {
448448
sleep_for(time2); // Won't get forced awake
449-
fail;
449+
die!();
450450
}
451451
sleep_for(time1); // Won't get forced awake
452-
fail;
452+
die!();
453453
// It will take MAX(time1,time2) for the program to finish.
454454
# };
455455
~~~

trunk/src/README.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ rt/sync - Concurrency utils
1717
rt/util - Small utility classes for the runtime.
1818
rt/vg - Valgrind headers
1919
rt/msvc - MSVC support
20+
rt/linenoise - a readline-like line editing library
2021

2122
test/ Testsuite
2223
test/compile-fail - Tests that should fail to compile

trunk/src/etc/vim/syntax/rust.vim

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,25 @@ endif
1212

1313
syn match rustAssert "\<assert\(\w\)*"
1414
syn keyword rustKeyword as break
15-
syn keyword rustKeyword copy do drop else extern fail
15+
syn keyword rustKeyword const copy do drop else export extern fail
1616
syn keyword rustKeyword for if impl let log
17-
syn keyword rustKeyword loop match mod move once priv pub pure
17+
syn keyword rustKeyword loop match mod move mut once priv pure
18+
syn match rustKeyword "\<pub\>"
1819
syn keyword rustKeyword ref return static
19-
syn keyword rustKeyword unsafe use while
20+
syn match rustKeyword "\<unsafe\>" " Allows also matching unsafe::foo()
21+
syn keyword rustKeyword use while
2022
" FIXME: Scoped impl's name is also fallen in this category
2123
syn keyword rustKeyword mod trait struct enum type nextgroup=rustIdentifier skipwhite
2224
syn keyword rustKeyword fn nextgroup=rustFuncName skipwhite
23-
syn keyword rustStorage const mut
2425

2526
syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
2627
syn match rustFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
2728

2829
" Reserved words
29-
syn keyword rustKeyword m32 m64 m128 f80 f16 f128 be
30+
syn keyword rustKeyword m32 m64 m128 f80 f16 f128
3031

3132
syn keyword rustType int uint float char bool u8 u16 u32 u64 f32
32-
syn keyword rustType f64 i8 i16 i32 i64 str Self
33+
syn keyword rustType f64 i8 i16 i32 i64 str
3334
syn keyword rustType Option Either
3435

3536
" Types from libc
@@ -133,7 +134,6 @@ hi def link rustMacro Macro
133134
hi def link rustType Type
134135
hi def link rustTodo Todo
135136
hi def link rustAttribute PreProc
136-
hi def link rustStorage StorageClass
137137

138138
" Other Suggestions:
139139
" hi rustAssert ctermfg=yellow

trunk/src/libcargo/cargo.rc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ pub fn load_link(mis: ~[@ast::meta_item]) -> (Option<~str>,
286286
let mut uuid = None;
287287
for mis.each |a| {
288288
match a.node {
289-
ast::meta_name_value(v, ast::spanned { node: ast::lit_str(s),
289+
ast::meta_name_value(v, codemap::spanned { node: ast::lit_str(s),
290290
_ }) => {
291291
match v {
292292
~"name" => name = Some(*s),
@@ -314,7 +314,7 @@ pub fn load_crate(filename: &Path) -> Option<Crate> {
314314

315315
for c.node.attrs.each |a| {
316316
match a.node.value.node {
317-
ast::meta_name_value(v, ast::spanned { node: ast::lit_str(_),
317+
ast::meta_name_value(v, codemap::spanned { node: ast::lit_str(_),
318318
_ }) => {
319319
match v {
320320
~"desc" => desc = Some(v),
@@ -460,7 +460,7 @@ pub fn parse_source(name: ~str, j: &json::Json) -> @Source {
460460
json::Object(j) => {
461461
let mut url = match j.find(&~"url") {
462462
Some(&json::String(u)) => copy u,
463-
_ => fail ~"needed 'url' field in source"
463+
_ => die!(~"needed 'url' field in source")
464464
};
465465
let method = match j.find(&~"method") {
466466
Some(&json::String(u)) => copy u,

trunk/src/libcore/dvec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl<A> DVec<A> {
179179
let mut data = cast::reinterpret_cast(&null::<()>());
180180
data <-> self.data;
181181
let data_ptr: *() = cast::reinterpret_cast(&data);
182-
if data_ptr.is_null() { fail ~"Recursive use of dvec"; }
182+
if data_ptr.is_null() { die!(~"Recursive use of dvec"); }
183183
self.data = move ~[move t];
184184
self.data.push_all_move(move data);
185185
}

trunk/src/libcore/hashmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ pub mod linear {
386386
pure fn get(&self, k: &K) -> &self/V {
387387
match self.find(k) {
388388
Some(v) => v,
389-
None => fail fmt!("No entry found for key: %?", k),
389+
None => die!(fmt!("No entry found for key: %?", k)),
390390
}
391391
}
392392
}

trunk/src/libcore/pipes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ pub fn send<T,Tbuffer>(p: SendPacketBuffered<T,Tbuffer>, payload: T) -> bool {
549549
//unsafe { forget(p); }
550550
return true;
551551
}
552-
Full => fail ~"duplicate send",
552+
Full => die!(~"duplicate send"),
553553
Blocked => {
554554
debug!("waking up task for %?", p_);
555555
let old_task = swap_task(&mut p.header.blocked_task, ptr::null());
@@ -1020,7 +1020,7 @@ impl<T:Owned,Tbuffer:Owned> SendPacketBuffered<T,Tbuffer> {
10201020
//forget(packet);
10211021
header
10221022
},
1023-
None => fail ~"packet already consumed"
1023+
None => die!(~"packet already consumed")
10241024
}
10251025
}
10261026

trunk/src/libcore/private/finally.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn test_fail() {
7171
let mut i = 0;
7272
do (|| {
7373
i = 10;
74-
fail;
74+
die!();
7575
}).finally {
7676
assert failing();
7777
assert i == 10;
@@ -95,4 +95,4 @@ fn test_compact() {
9595
fn but_always_run_this_function() { }
9696
do_some_fallible_work.finally(
9797
but_always_run_this_function);
98-
}
98+
}

trunk/src/libcore/private/global.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ fn test_modify() {
269269
Some(~shared_mutable_state(10))
270270
}
271271
}
272-
_ => fail
272+
_ => die!()
273273
}
274274
}
275275

@@ -280,7 +280,7 @@ fn test_modify() {
280280
assert *v == 10;
281281
None
282282
},
283-
_ => fail
283+
_ => die!()
284284
}
285285
}
286286

@@ -291,7 +291,7 @@ fn test_modify() {
291291
Some(~shared_mutable_state(10))
292292
}
293293
}
294-
_ => fail
294+
_ => die!()
295295
}
296296
}
297297
}

0 commit comments

Comments
 (0)