Skip to content

Commit 13fe167

Browse files
author
Nick Desaulniers
committed
remove die definition and use in doc tests
1 parent 4699ac6 commit 13fe167

File tree

4 files changed

+20
-29
lines changed

4 files changed

+20
-29
lines changed

doc/rust.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -686,15 +686,15 @@ mod math {
686686
type complex = (f64, f64);
687687
fn sin(f: f64) -> f64 {
688688
...
689-
# die!();
689+
# fail!();
690690
}
691691
fn cos(f: f64) -> f64 {
692692
...
693-
# die!();
693+
# fail!();
694694
}
695695
fn tan(f: f64) -> f64 {
696696
...
697-
# die!();
697+
# fail!();
698698
}
699699
}
700700
~~~~~~~~
@@ -986,7 +986,7 @@ output slot type would normally be. For example:
986986
~~~~
987987
fn my_err(s: &str) -> ! {
988988
log(info, s);
989-
die!();
989+
fail!();
990990
}
991991
~~~~
992992

@@ -1004,7 +1004,7 @@ were declared without the `!` annotation, the following code would not
10041004
typecheck:
10051005

10061006
~~~~
1007-
# fn my_err(s: &str) -> ! { die!() }
1007+
# fn my_err(s: &str) -> ! { fail!() }
10081008
10091009
fn f(i: int) -> int {
10101010
if i == 42 {
@@ -2284,9 +2284,9 @@ enum List<X> { Nil, Cons(X, @List<X>) }
22842284
let x: List<int> = Cons(10, @Cons(11, @Nil));
22852285
22862286
match x {
2287-
Cons(_, @Nil) => die!(~"singleton list"),
2287+
Cons(_, @Nil) => fail!(~"singleton list"),
22882288
Cons(*) => return,
2289-
Nil => die!(~"empty list")
2289+
Nil => fail!(~"empty list")
22902290
}
22912291
~~~~
22922292

@@ -2323,7 +2323,7 @@ match x {
23232323
return;
23242324
}
23252325
_ => {
2326-
die!();
2326+
fail!();
23272327
}
23282328
}
23292329
~~~~
@@ -2411,7 +2411,7 @@ guard may refer to the variables bound within the pattern they follow.
24112411
let message = match maybe_digit {
24122412
Some(x) if x < 10 => process_digit(x),
24132413
Some(x) => process_other(x),
2414-
None => die!()
2414+
None => fail!()
24152415
};
24162416
~~~~
24172417

doc/tutorial-macros.md

+3-3
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;

doc/tutorial-tasks.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -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();
@@ -370,14 +370,14 @@ proceed). Hence, you will need different _linked failure modes_.
370370
## Failure modes
371371

372372
By default, task failure is _bidirectionally linked_, which means that if
373-
either task dies, it kills the other one.
373+
either task fails, it kills the other one.
374374

375375
~~~
376376
# fn sleep_forever() { loop { task::yield() } }
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 fail.
381381
}
382382
sleep_forever(); // Will get woken up by force, then fail
383383
}
@@ -386,7 +386,7 @@ sleep_forever(); // Will get woken up by force, then fail
386386
~~~
387387

388388
If you want parent tasks to be able to kill their children, but do not want a
389-
parent to die automatically if one of its child task dies, you can call
389+
parent to fail automatically if one of its child task fails, you can call
390390
`task::spawn_supervised` for _unidirectionally linked_ failure. The
391391
function `task::try`, which we saw previously, uses `spawn_supervised`
392392
internally, with additional logic to wait for the child task to finish
@@ -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
~~~

src/libsyntax/ext/expand.rs

-9
Original file line numberDiff line numberDiff line change
@@ -287,15 +287,6 @@ pub fn core_macros() -> ~str {
287287
macro_rules! debug ( ($( $arg:expr ),+) => (
288288
log(::core::debug, fmt!( $($arg),+ )) ))
289289

290-
macro_rules! die(
291-
($msg: expr) => (
292-
::core::sys::begin_unwind($msg, file!().to_owned(), line!())
293-
);
294-
() => (
295-
fail!(~\"explicit failure\")
296-
)
297-
)
298-
299290
macro_rules! fail(
300291
($msg: expr) => (
301292
::core::sys::begin_unwind($msg, file!().to_owned(), line!())

0 commit comments

Comments
 (0)