Skip to content

Commit a12eb3d

Browse files
committed
---
yaml --- r: 41431 b: refs/heads/snap-stage3 c: dffc3f8 h: refs/heads/master i: 41429: c77a092 41427: d2bee6c 41423: 41549be v: v3
1 parent cc0ece7 commit a12eb3d

File tree

105 files changed

+510
-638
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

+510
-638
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 09bb07bed9166105ea961a42b5fff7739ae0d2e9
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: b2c01b5892f9f2ae8d779e4dd69a352e1ff138dd
4+
refs/heads/snap-stage3: dffc3f82b25dc8a5398ecb3a40bb7057cb2e7c5e
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/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",
5+
"do": "else-style", "return": "else-style", "fail": "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",

branches/snap-stage3/doc/rust.md

Lines changed: 25 additions & 15 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-
false fn for
219+
fail 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-
# die!();
695+
# fail;
696696
}
697697
fn cos(f: f64) -> f64 {
698698
...
699-
# die!();
699+
# fail;
700700
}
701701
fn tan(f: f64) -> f64 {
702702
...
703-
# die!();
703+
# fail;
704704
}
705705
}
706706
~~~~~~~~
@@ -851,9 +851,6 @@ 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-
857854
### Functions
858855

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

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

10121009
~~~~
1013-
# fn my_err(s: &str) -> ! { die!() }
1010+
# fn my_err(s: &str) -> ! { fail }
10141011
10151012
fn f(i: int) -> int {
10161013
if i == 42 {
@@ -2294,9 +2291,9 @@ enum List<X> { Nil, Cons(X, @List<X>) }
22942291
let x: List<int> = Cons(10, @Cons(11, @Nil));
22952292
22962293
match x {
2297-
Cons(_, @Nil) => die!(~"singleton list"),
2294+
Cons(_, @Nil) => fail ~"singleton list",
22982295
Cons(*) => return,
2299-
Nil => die!(~"empty list")
2296+
Nil => fail ~"empty list"
23002297
}
23012298
~~~~
23022299

@@ -2333,7 +2330,7 @@ match x {
23332330
return;
23342331
}
23352332
_ => {
2336-
die!();
2333+
fail;
23372334
}
23382335
}
23392336
~~~~
@@ -2421,10 +2418,23 @@ guard may refer to the variables bound within the pattern they follow.
24212418
let message = match maybe_digit {
24222419
Some(x) if x < 10 => process_digit(x),
24232420
Some(x) => process_other(x),
2424-
None => die!()
2421+
None => fail
24252422
};
24262423
~~~~
24272424

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+
24282438
### Return expressions
24292439

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

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

branches/snap-stage3/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-
_ => die!(~"Didn't get good_2")
221+
_ => fail ~"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 { die!(~"Didn't get good_2") };
263+
else { fail ~"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 { die!(~"Didn't get good_2") };
365+
(g1.body) ~ (good_2(result) ) else { fail ~"Didn't get good_2" };
366366
binds val, result )
367367
// complicated stuff goes here
368368
return result + val;

branches/snap-stage3/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!()` 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
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
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 { die!() }
316+
do spawn { fail }
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-
die!(~"oops!");
340+
fail ~"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-
die!(); // All three tasks will die.
380+
fail; // 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-
die!(); // Will kill grandchild even if child has already exited
435+
fail; // 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-
die!();
449+
fail;
450450
}
451451
sleep_for(time1); // Won't get forced awake
452-
die!();
452+
fail;
453453
// It will take MAX(time1,time2) for the program to finish.
454454
# };
455455
~~~

branches/snap-stage3/src/README.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ 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
2120

2221
test/ Testsuite
2322
test/compile-fail - Tests that should fail to compile

branches/snap-stage3/src/etc/vim/syntax/rust.vim

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

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

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

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

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

3635
" Types from libc
@@ -134,6 +133,7 @@ hi def link rustMacro Macro
134133
hi def link rustType Type
135134
hi def link rustTodo Todo
136135
hi def link rustAttribute PreProc
136+
hi def link rustStorage StorageClass
137137

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

branches/snap-stage3/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, codemap::spanned { node: ast::lit_str(s),
289+
ast::meta_name_value(v, ast::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, codemap::spanned { node: ast::lit_str(_),
317+
ast::meta_name_value(v, ast::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-
_ => die!(~"needed 'url' field in source")
463+
_ => fail ~"needed 'url' field in source"
464464
};
465465
let method = match j.find(&~"method") {
466466
Some(&json::String(u)) => copy u,

branches/snap-stage3/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() { die!(~"Recursive use of dvec"); }
182+
if data_ptr.is_null() { fail ~"Recursive use of dvec"; }
183183
self.data = move ~[move t];
184184
self.data.push_all_move(move data);
185185
}

branches/snap-stage3/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 => die!(fmt!("No entry found for key: %?", k)),
389+
None => fail fmt!("No entry found for key: %?", k),
390390
}
391391
}
392392
}

branches/snap-stage3/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 => die!(~"duplicate send"),
552+
Full => fail ~"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 => die!(~"packet already consumed")
1023+
None => fail ~"packet already consumed"
10241024
}
10251025
}
10261026

branches/snap-stage3/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-
die!();
74+
fail;
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+
}

branches/snap-stage3/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-
_ => die!()
272+
_ => fail
273273
}
274274
}
275275

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

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

0 commit comments

Comments
 (0)