Skip to content

remove die definition and use in doc tests #4941

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -686,15 +686,15 @@ mod math {
type complex = (f64, f64);
fn sin(f: f64) -> f64 {
...
# die!();
# fail!();
}
fn cos(f: f64) -> f64 {
...
# die!();
# fail!();
}
fn tan(f: f64) -> f64 {
...
# die!();
# fail!();
}
}
~~~~~~~~
Expand Down Expand Up @@ -986,7 +986,7 @@ output slot type would normally be. For example:
~~~~
fn my_err(s: &str) -> ! {
log(info, s);
die!();
fail!();
}
~~~~

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

~~~~
# fn my_err(s: &str) -> ! { die!() }
# fn my_err(s: &str) -> ! { fail!() }

fn f(i: int) -> int {
if i == 42 {
Expand Down Expand Up @@ -2284,9 +2284,9 @@ enum List<X> { Nil, Cons(X, @List<X>) }
let x: List<int> = Cons(10, @Cons(11, @Nil));

match x {
Cons(_, @Nil) => die!(~"singleton list"),
Cons(_, @Nil) => fail!(~"singleton list"),
Cons(*) => return,
Nil => die!(~"empty list")
Nil => fail!(~"empty list")
}
~~~~

Expand Down Expand Up @@ -2323,7 +2323,7 @@ match x {
return;
}
_ => {
die!();
fail!();
}
}
~~~~
Expand Down Expand Up @@ -2411,7 +2411,7 @@ guard may refer to the variables bound within the pattern they follow.
let message = match maybe_digit {
Some(x) if x < 10 => process_digit(x),
Some(x) => process_other(x),
None => die!()
None => fail!()
};
~~~~

Expand Down
6 changes: 3 additions & 3 deletions doc/tutorial-macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ match x {
// complicated stuff goes here
return result + val;
},
_ => die!(~"Didn't get good_2")
_ => fail!(~"Didn't get good_2")
}
}
_ => return 0 // default value
Expand Down Expand Up @@ -260,7 +260,7 @@ macro_rules! biased_match (
biased_match!((x) ~ (good_1(g1, val)) else { return 0 };
binds g1, val )
biased_match!((g1.body) ~ (good_2(result) )
else { die!(~"Didn't get good_2") };
else { fail!(~"Didn't get good_2") };
binds result )
// complicated stuff goes here
return result + val;
Expand Down Expand Up @@ -362,7 +362,7 @@ macro_rules! biased_match (
# fn f(x: t1) -> uint {
biased_match!(
(x) ~ (good_1(g1, val)) else { return 0 };
(g1.body) ~ (good_2(result) ) else { die!(~"Didn't get good_2") };
(g1.body) ~ (good_2(result) ) else { fail!(~"Didn't get good_2") };
binds val, result )
// complicated stuff goes here
return result + val;
Expand Down
16 changes: 8 additions & 8 deletions doc/tutorial-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ of all tasks are intertwined: if one fails, so do all the others.
# fn do_some_work() { loop { task::yield() } }
# do task::try {
// Create a child task that fails
do spawn { die!() }
do spawn { fail!() }

// This will also fail because the task we spawned failed
do_some_work();
Expand All @@ -337,7 +337,7 @@ let result: Result<int, ()> = do task::try {
if some_condition() {
calculate_result()
} else {
die!(~"oops!");
fail!(~"oops!");
}
};
assert result.is_err();
Expand Down Expand Up @@ -370,14 +370,14 @@ proceed). Hence, you will need different _linked failure modes_.
## Failure modes

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

~~~
# fn sleep_forever() { loop { task::yield() } }
# do task::try {
do task::spawn {
do task::spawn {
die!(); // All three tasks will die.
fail!(); // All three tasks will fail.
}
sleep_forever(); // Will get woken up by force, then fail
}
Expand All @@ -386,7 +386,7 @@ sleep_forever(); // Will get woken up by force, then fail
~~~

If you want parent tasks to be able to kill their children, but do not want a
parent to die automatically if one of its child task dies, you can call
parent to fail automatically if one of its child task fails, you can call
`task::spawn_supervised` for _unidirectionally linked_ failure. The
function `task::try`, which we saw previously, uses `spawn_supervised`
internally, with additional logic to wait for the child task to finish
Expand Down Expand Up @@ -432,7 +432,7 @@ do task::spawn_supervised {
// Intermediate task immediately exits
}
wait_for_a_while();
die!(); // Will kill grandchild even if child has already exited
fail!(); // Will kill grandchild even if child has already exited
# };
~~~

Expand All @@ -446,10 +446,10 @@ other at all, using `task::spawn_unlinked` for _isolated failure_.
let (time1, time2) = (random(), random());
do task::spawn_unlinked {
sleep_for(time2); // Won't get forced awake
die!();
fail!();
}
sleep_for(time1); // Won't get forced awake
die!();
fail!();
// It will take MAX(time1,time2) for the program to finish.
# };
~~~
Expand Down
9 changes: 0 additions & 9 deletions src/libsyntax/ext/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,6 @@ pub fn core_macros() -> ~str {
macro_rules! debug ( ($( $arg:expr ),+) => (
log(::core::debug, fmt!( $($arg),+ )) ))

macro_rules! die(
($msg: expr) => (
::core::sys::begin_unwind($msg, file!().to_owned(), line!())
);
() => (
fail!(~\"explicit failure\")
)
)

macro_rules! fail(
($msg: expr) => (
::core::sys::begin_unwind($msg, file!().to_owned(), line!())
Expand Down