Skip to content

Commit f29ebc5

Browse files
committed
---
yaml --- r: 41422 b: refs/heads/snap-stage3 c: 9dc6938 h: refs/heads/master v: v3
1 parent 5608604 commit f29ebc5

Some content is hidden

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

58 files changed

+159
-195
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: a05bbb2013679b4ce48a65124ad30045079f68d3
4+
refs/heads/snap-stage3: 9dc69382922227964ab3f38a5343ba39dfcbc0c0
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", "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",

branches/snap-stage3/doc/rust.md

Lines changed: 12 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
~~~~~~~~
@@ -992,13 +992,13 @@ output slot type would normally be. For example:
992992
~~~~
993993
fn my_err(s: &str) -> ! {
994994
log(info, s);
995-
fail;
995+
die!();
996996
}
997997
~~~~
998998

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

10121012
~~~~
1013-
# fn my_err(s: &str) -> ! { fail }
1013+
# fn my_err(s: &str) -> ! { die!() }
10141014
10151015
fn f(i: int) -> int {
10161016
if i == 42 {
@@ -2294,9 +2294,9 @@ enum List<X> { Nil, Cons(X, @List<X>) }
22942294
let x: List<int> = Cons(10, @Cons(11, @Nil));
22952295
22962296
match x {
2297-
Cons(_, @Nil) => fail ~"singleton list",
2297+
Cons(_, @Nil) => die!(~"singleton list"),
22982298
Cons(*) => return,
2299-
Nil => fail ~"empty list"
2299+
Nil => die!(~"empty list")
23002300
}
23012301
~~~~
23022302

@@ -2333,7 +2333,7 @@ match x {
23332333
return;
23342334
}
23352335
_ => {
2336-
fail;
2336+
die!();
23372337
}
23382338
}
23392339
~~~~
@@ -2421,23 +2421,10 @@ guard may refer to the variables bound within the pattern they follow.
24212421
let message = match maybe_digit {
24222422
Some(x) if x < 10 => process_digit(x),
24232423
Some(x) => process_other(x),
2424-
None => fail
2424+
None => die!()
24252425
};
24262426
~~~~
24272427

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

24432430
~~~~~~~~{.ebnf .gram}
@@ -3157,7 +3144,7 @@ unblock and transition back to *running*.
31573144

31583145
A task may transition to the *failing* state at any time, due being
31593146
killed by some external event or internally, from the evaluation of a
3160-
`fail` expression. Once *failing*, a task unwinds its stack and
3147+
`fail!()` macro. Once *failing*, a task unwinds its stack and
31613148
transitions to the *dead* state. Unwinding the stack of a task is done by
31623149
the task itself, on its own control stack. If a value with a destructor is
31633150
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-
_ => 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;

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` 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
~~~

branches/snap-stage3/src/libcargo/cargo.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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,

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() { 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
}

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 => fail fmt!("No entry found for key: %?", k),
389+
None => die!(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 => 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

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-
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+
}

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-
_ => 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
}

branches/snap-stage3/src/libcore/private/weak_task.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ fn run_weak_task_service(port: Port<ServiceMsg>) {
112112
// nobody will receive this
113113
shutdown_chan.send(());
114114
}
115-
None => fail
115+
None => die!()
116116
}
117117
}
118118
Shutdown => break
@@ -195,7 +195,7 @@ fn test_select_stream_and_oneshot() {
195195
do weaken_task |signal| {
196196
match select2i(&port, &signal) {
197197
Left(*) => (),
198-
Right(*) => fail
198+
Right(*) => die!()
199199
}
200200
}
201201
}

branches/snap-stage3/src/libcore/repr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ impl ReprVisitor : TyVisitor {
594594
}
595595

596596
// Type no longer exists, vestigial function.
597-
fn visit_str(&self) -> bool { fail; }
597+
fn visit_str(&self) -> bool { die!(); }
598598

599599
fn visit_estr_box(&self) -> bool {
600600
do self.get::<@str> |s| {
@@ -616,7 +616,7 @@ impl ReprVisitor : TyVisitor {
616616

617617
// Type no longer exists, vestigial function.
618618
fn visit_estr_fixed(&self, _n: uint, _sz: uint,
619-
_align: uint) -> bool { fail; }
619+
_align: uint) -> bool { die!(); }
620620

621621
fn visit_box(&self, mtbl: uint, inner: *TyDesc) -> bool {
622622
self.writer.write_char('@');
@@ -652,7 +652,7 @@ impl ReprVisitor : TyVisitor {
652652
}
653653

654654
// Type no longer exists, vestigial function.
655-
fn visit_vec(&self, _mtbl: uint, _inner: *TyDesc) -> bool { fail; }
655+
fn visit_vec(&self, _mtbl: uint, _inner: *TyDesc) -> bool { die!(); }
656656

657657

658658
fn visit_unboxed_vec(&self, mtbl: uint, inner: *TyDesc) -> bool {
@@ -859,7 +859,7 @@ impl ReprVisitor : TyVisitor {
859859
}
860860

861861
// Type no longer exists, vestigial function.
862-
fn visit_constr(&self, _inner: *TyDesc) -> bool { fail; }
862+
fn visit_constr(&self, _inner: *TyDesc) -> bool { die!(); }
863863

864864
fn visit_closure_ptr(&self, _ck: uint) -> bool { true }
865865
}

branches/snap-stage3/src/libcore/task/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ fn test_spawn_linked_sup_fail_up() { // child fails; parent fails
733733
can_not_copy: None,
734734
.. b0
735735
};
736-
do b1.spawn { fail; }
736+
do b1.spawn { die!(); }
737737
po.recv(); // We should get punted awake
738738
}
739739
#[test] #[should_fail] #[ignore(cfg(windows))]
@@ -760,7 +760,7 @@ fn test_spawn_linked_sup_fail_down() { // parent fails; child fails
760760
fn test_spawn_linked_unsup_fail_up() { // child fails; parent fails
761761
let (po, _ch) = stream::<()>();
762762
// Default options are to spawn linked & unsupervised.
763-
do spawn { fail; }
763+
do spawn { die!(); }
764764
po.recv(); // We should get punted awake
765765
}
766766
#[test] #[should_fail] #[ignore(cfg(windows))]

0 commit comments

Comments
 (0)