Replace most invocations of fail keyword with die! macro

This commit is contained in:
Nick Desaulniers 2013-01-31 17:51:01 -08:00 committed by Brian Anderson
parent 2db3175c76
commit aee7929469
331 changed files with 914 additions and 908 deletions

View file

@ -69,7 +69,7 @@ pub fn parse_config(args: ~[~str]) -> config {
let matches = let matches =
&match getopts::getopts(args_, opts) { &match getopts::getopts(args_, opts) {
Ok(m) => m, Ok(m) => m,
Err(f) => fail getopts::fail_str(f) Err(f) => die!(getopts::fail_str(f))
}; };
fn opt_path(m: &getopts::Matches, nm: ~str) -> Path { fn opt_path(m: &getopts::Matches, nm: ~str) -> Path {
@ -131,7 +131,7 @@ pub fn str_mode(s: ~str) -> mode {
~"run-fail" => mode_run_fail, ~"run-fail" => mode_run_fail,
~"run-pass" => mode_run_pass, ~"run-pass" => mode_run_pass,
~"pretty" => mode_pretty, ~"pretty" => mode_pretty,
_ => fail ~"invalid mode" _ => die!(~"invalid mode")
} }
} }
@ -148,7 +148,7 @@ pub fn run_tests(config: config) {
let opts = test_opts(config); let opts = test_opts(config);
let tests = make_tests(config); let tests = make_tests(config);
let res = test::run_tests_console(&opts, tests); let res = test::run_tests_console(&opts, tests);
if !res { fail ~"Some tests failed"; } if !res { die!(~"Some tests failed"); }
} }
pub fn test_opts(config: config) -> test::TestOpts { pub fn test_opts(config: config) -> test::TestOpts {

View file

@ -119,7 +119,7 @@ fn parse_exec_env(line: ~str) -> Option<(~str, ~str)> {
match strs.len() { match strs.len() {
1u => (strs[0], ~""), 1u => (strs[0], ~""),
2u => (strs[0], strs[1]), 2u => (strs[0], strs[1]),
n => fail fmt!("Expected 1 or 2 strings, not %u", n) n => die!(fmt!("Expected 1 or 2 strings, not %u", n))
} }
} }
} }

View file

@ -71,7 +71,7 @@ pub fn run(lib_path: ~str,
os::close(pipe_in.out); os::close(pipe_in.out);
os::close(pipe_out.in); os::close(pipe_out.in);
os::close(pipe_err.in); os::close(pipe_err.in);
fail; die!();
} }
@ -99,7 +99,7 @@ pub fn run(lib_path: ~str,
(2, s) => { (2, s) => {
errs = s; errs = s;
} }
_ => { fail } _ => { die!() }
}; };
count -= 1; count -= 1;
}; };

View file

@ -200,7 +200,7 @@ actual:\n\
\n", \n",
expected, actual); expected, actual);
io::stdout().write_str(msg); io::stdout().write_str(msg);
fail; die!();
} }
} }
@ -467,7 +467,7 @@ fn compose_and_run_compiler(
fn ensure_dir(path: &Path) { fn ensure_dir(path: &Path) {
if os::path_is_dir(path) { return; } if os::path_is_dir(path) { return; }
if !os::make_dir(path, 0x1c0i32) { if !os::make_dir(path, 0x1c0i32) {
fail fmt!("can't make dir %s", path.to_str()); die!(fmt!("can't make dir %s", path.to_str()));
} }
} }
@ -617,7 +617,7 @@ fn maybe_dump_to_stdout(config: config, out: ~str, err: ~str) {
fn error(err: ~str) { io::stdout().write_line(fmt!("\nerror: %s", err)); } fn error(err: ~str) { io::stdout().write_line(fmt!("\nerror: %s", err)); }
fn fatal(err: ~str) -> ! { error(err); fail; } fn fatal(err: ~str) -> ! { error(err); die!(); }
fn fatal_ProcRes(err: ~str, ProcRes: ProcRes) -> ! { fn fatal_ProcRes(err: ~str, ProcRes: ProcRes) -> ! {
let msg = let msg =
@ -635,5 +635,5 @@ stderr:\n\
\n", \n",
err, ProcRes.cmdline, ProcRes.stdout, ProcRes.stderr); err, ProcRes.cmdline, ProcRes.stdout, ProcRes.stderr);
io::stdout().write_str(msg); io::stdout().write_str(msg);
fail; die!();
} }

View file

@ -295,7 +295,7 @@ pub fn load_link(mis: ~[@ast::meta_item]) -> (Option<~str>,
_ => { } _ => { }
} }
} }
_ => fail ~"load_link: meta items must be name-values" _ => die!(~"load_link: meta items must be name-values")
} }
} }
(name, vers, uuid) (name, vers, uuid)
@ -332,8 +332,8 @@ pub fn load_crate(filename: &Path) -> Option<Crate> {
} }
} }
_ => { _ => {
fail ~"crate attributes may not contain " + die!(~"crate attributes may not contain " +
~"meta_words"; ~"meta_words");
} }
} }
} }
@ -435,7 +435,7 @@ pub fn rest(s: ~str, start: uint) -> ~str {
pub fn need_dir(s: &Path) { pub fn need_dir(s: &Path) {
if os::path_is_dir(s) { return; } if os::path_is_dir(s) { return; }
if !os::make_dir(s, 493_i32 /* oct: 755 */) { if !os::make_dir(s, 493_i32 /* oct: 755 */) {
fail fmt!("can't make_dir %s", s.to_str()); die!(fmt!("can't make_dir %s", s.to_str()));
} }
} }
@ -453,7 +453,7 @@ pub fn valid_pkg_name(s: &str) -> bool {
pub fn parse_source(name: ~str, j: &json::Json) -> @Source { pub fn parse_source(name: ~str, j: &json::Json) -> @Source {
if !valid_pkg_name(name) { if !valid_pkg_name(name) {
fail fmt!("'%s' is an invalid source name", name); die!(fmt!("'%s' is an invalid source name", name));
} }
match *j { match *j {
@ -485,7 +485,7 @@ pub fn parse_source(name: ~str, j: &json::Json) -> @Source {
mut keyfp: keyfp, mut keyfp: keyfp,
packages: DVec() }; packages: DVec() };
} }
_ => fail ~"needed dict value in source" _ => die!(~"needed dict value in source")
}; };
} }
@ -500,8 +500,8 @@ pub fn try_parse_sources(filename: &Path,
debug!("source: %s", *k); debug!("source: %s", *k);
} }
} }
Ok(_) => fail ~"malformed sources.json", Ok(_) => die!(~"malformed sources.json"),
Err(e) => fail fmt!("%s:%s", filename.to_str(), e.to_str()) Err(e) => die!(fmt!("%s:%s", filename.to_str(), e.to_str()))
} }
} }
@ -662,7 +662,7 @@ pub fn build_cargo_options(argv: ~[~str]) -> Options {
let matches = &match getopts::getopts(argv, opts()) { let matches = &match getopts::getopts(argv, opts()) {
result::Ok(m) => m, result::Ok(m) => m,
result::Err(f) => { result::Err(f) => {
fail fmt!("%s", getopts::fail_str(f)); die!(fmt!("%s", getopts::fail_str(f)));
} }
}; };
@ -675,10 +675,10 @@ pub fn build_cargo_options(argv: ~[~str]) -> Options {
let is_install = len > 1u && matches.free[1] == ~"install"; let is_install = len > 1u && matches.free[1] == ~"install";
let is_uninstall = len > 1u && matches.free[1] == ~"uninstall"; let is_uninstall = len > 1u && matches.free[1] == ~"uninstall";
if G && g { fail ~"-G and -g both provided"; } if G && g { die!(~"-G and -g both provided"); }
if !is_install && !is_uninstall && (g || G) { if !is_install && !is_uninstall && (g || G) {
fail ~"-g and -G are only valid for `install` and `uninstall|rm`"; die!(~"-g and -G are only valid for `install` and `uninstall|rm`");
} }
let mode = let mode =
@ -845,7 +845,7 @@ pub fn install_source(c: &Cargo, path: &Path) {
} }
if vec::is_empty(cratefiles) { if vec::is_empty(cratefiles) {
fail ~"this doesn't look like a rust package (no .rc files)"; die!(~"this doesn't look like a rust package (no .rc files)");
} }
for cratefiles.each |cf| { for cratefiles.each |cf| {
@ -888,7 +888,7 @@ pub fn install_curl(c: &Cargo, wd: &Path, url: ~str) {
let p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o", let p = run::program_output(~"curl", ~[~"-f", ~"-s", ~"-o",
tarpath.to_str(), url]); tarpath.to_str(), url]);
if p.status != 0 { if p.status != 0 {
fail fmt!("fetch of %s failed: %s", url, p.err); die!(fmt!("fetch of %s failed: %s", url, p.err));
} }
run::run_program(~"tar", ~[~"-x", ~"--strip-components=1", run::run_program(~"tar", ~[~"-x", ~"--strip-components=1",
~"-C", wd.to_str(), ~"-C", wd.to_str(),
@ -1123,8 +1123,8 @@ pub fn install_query(c: &Cargo, wd: &Path, target: ~str) {
pub fn get_temp_workdir(c: &Cargo) -> Path { pub fn get_temp_workdir(c: &Cargo) -> Path {
match tempfile::mkdtemp(&c.workdir, "cargo") { match tempfile::mkdtemp(&c.workdir, "cargo") {
Some(wd) => wd, Some(wd) => wd,
None => fail fmt!("needed temp dir: %s", None => die!(fmt!("needed temp dir: %s",
c.workdir.to_str()) c.workdir.to_str()))
} }
} }
@ -1138,7 +1138,7 @@ pub fn cmd_install(c: &Cargo) {
wd.to_str()]); wd.to_str()]);
if status != 0 { if status != 0 {
fail fmt!("could not copy directory: %s", cwd.to_str()); die!(fmt!("could not copy directory: %s", cwd.to_str()));
} }
install_source(c, &wd); install_source(c, &wd);

View file

@ -87,7 +87,7 @@ pub fn init(root: &Path) {
p.input().write_str(signing_key()); p.input().write_str(signing_key());
let s = p.finish(); let s = p.finish();
if s != 0 { if s != 0 {
fail ~"pgp init failed"; die!(~"pgp init failed");
} }
} }
} }
@ -98,7 +98,7 @@ pub fn add(root: &Path, key: &Path) {
run::program_output(~"gpg", ~[~"--homedir", path.to_str(), run::program_output(~"gpg", ~[~"--homedir", path.to_str(),
~"--import", key.to_str()]); ~"--import", key.to_str()]);
if p.status != 0 { if p.status != 0 {
fail ~"pgp add failed: " + p.out; die!(~"pgp add failed: " + p.out);
} }
} }

View file

@ -37,7 +37,7 @@ impl<T, U> Condition<T, U> {
fn raise(t: T) -> U { fn raise(t: T) -> U {
let msg = fmt!("Unhandled condition: %s: %?", self.name, t); let msg = fmt!("Unhandled condition: %s: %?", self.name, t);
self.raise_default(t, || fail copy msg) self.raise_default(t, || die!(copy msg))
} }
fn raise_default(t: T, default: &fn() -> U) -> U { fn raise_default(t: T, default: &fn() -> U) -> U {

View file

@ -251,6 +251,7 @@ pub mod core {
pub use condition; pub use condition;
pub use option; pub use option;
pub use kinds; pub use kinds;
pub use sys;
} }

View file

@ -48,18 +48,18 @@ priv impl<T> DListNode<T> {
match self.next { match self.next {
Some(neighbour) => match neighbour.prev { Some(neighbour) => match neighbour.prev {
Some(me) => if !managed::ptr_eq(self, me) { Some(me) => if !managed::ptr_eq(self, me) {
fail ~"Asymmetric next-link in dlist node." die!(~"Asymmetric next-link in dlist node.")
}, },
None => fail ~"One-way next-link in dlist node." None => die!(~"One-way next-link in dlist node.")
}, },
None => () None => ()
} }
match self.prev { match self.prev {
Some(neighbour) => match neighbour.next { Some(neighbour) => match neighbour.next {
Some(me) => if !managed::ptr_eq(me, self) { Some(me) => if !managed::ptr_eq(me, self) {
fail ~"Asymmetric prev-link in dlist node." die!(~"Asymmetric prev-link in dlist node.")
}, },
None => fail ~"One-way prev-link in dlist node." None => die!(~"One-way prev-link in dlist node.")
}, },
None => () None => ()
} }
@ -76,7 +76,7 @@ impl<T> DListNode<T> {
pure fn next_node(@self) -> @DListNode<T> { pure fn next_node(@self) -> @DListNode<T> {
match self.next_link() { match self.next_link() {
Some(nobe) => nobe, Some(nobe) => nobe,
None => fail ~"This dlist node has no next neighbour." None => die!(~"This dlist node has no next neighbour.")
} }
} }
/// Get the previous node in the list, if there is one. /// Get the previous node in the list, if there is one.
@ -88,7 +88,7 @@ impl<T> DListNode<T> {
pure fn prev_node(@self) -> @DListNode<T> { pure fn prev_node(@self) -> @DListNode<T> {
match self.prev_link() { match self.prev_link() {
Some(nobe) => nobe, Some(nobe) => nobe,
None => fail ~"This dlist node has no previous neighbour." None => die!(~"This dlist node has no previous neighbour.")
} }
} }
} }
@ -135,21 +135,21 @@ priv impl<T> DList<T> {
// These asserts could be stronger if we had node-root back-pointers, // These asserts could be stronger if we had node-root back-pointers,
// but those wouldn't allow for O(1) append. // but those wouldn't allow for O(1) append.
if self.size == 0 { if self.size == 0 {
fail ~"This dlist is empty; that node can't be on it." die!(~"This dlist is empty; that node can't be on it.")
} }
if !nobe.linked { fail ~"That node isn't linked to any dlist." } if !nobe.linked { die!(~"That node isn't linked to any dlist.") }
if !((nobe.prev.is_some() if !((nobe.prev.is_some()
|| managed::ptr_eq(self.hd.expect(~"headless dlist?"), || managed::ptr_eq(self.hd.expect(~"headless dlist?"),
nobe)) && nobe)) &&
(nobe.next.is_some() (nobe.next.is_some()
|| managed::ptr_eq(self.tl.expect(~"tailless dlist?"), || managed::ptr_eq(self.tl.expect(~"tailless dlist?"),
nobe))) { nobe))) {
fail ~"That node isn't on this dlist." die!(~"That node isn't on this dlist.")
} }
} }
fn make_mine(nobe: @DListNode<T>) { fn make_mine(nobe: @DListNode<T>) {
if nobe.prev.is_some() || nobe.next.is_some() || nobe.linked { if nobe.prev.is_some() || nobe.next.is_some() || nobe.linked {
fail ~"Cannot insert node that's already on a dlist!" die!(~"Cannot insert node that's already on a dlist!")
} }
nobe.linked = true; nobe.linked = true;
} }
@ -313,14 +313,16 @@ impl<T> DList<T> {
pure fn head_n(@self) -> @DListNode<T> { pure fn head_n(@self) -> @DListNode<T> {
match self.hd { match self.hd {
Some(nobe) => nobe, Some(nobe) => nobe,
None => fail ~"Attempted to get the head of an empty dlist." None => die!(
~"Attempted to get the head of an empty dlist.")
} }
} }
/// Get the node at the list's tail, failing if empty. O(1). /// Get the node at the list's tail, failing if empty. O(1).
pure fn tail_n(@self) -> @DListNode<T> { pure fn tail_n(@self) -> @DListNode<T> {
match self.tl { match self.tl {
Some(nobe) => nobe, Some(nobe) => nobe,
None => fail ~"Attempted to get the tail of an empty dlist." None => die!(
~"Attempted to get the tail of an empty dlist.")
} }
} }
@ -333,7 +335,7 @@ impl<T> DList<T> {
*/ */
fn append(@self, them: @DList<T>) { fn append(@self, them: @DList<T>) {
if managed::ptr_eq(self, them) { if managed::ptr_eq(self, them) {
fail ~"Cannot append a dlist to itself!" die!(~"Cannot append a dlist to itself!")
} }
if them.len() > 0 { if them.len() > 0 {
self.link(self.tl, them.hd); self.link(self.tl, them.hd);
@ -350,7 +352,7 @@ impl<T> DList<T> {
*/ */
fn prepend(@self, them: @DList<T>) { fn prepend(@self, them: @DList<T>) {
if managed::ptr_eq(self, them) { if managed::ptr_eq(self, them) {
fail ~"Cannot prepend a dlist to itself!" die!(~"Cannot prepend a dlist to itself!")
} }
if them.len() > 0 { if them.len() > 0 {
self.link(them.tl, self.hd); self.link(them.tl, self.hd);

View file

@ -91,7 +91,7 @@ priv impl<A> DVec<A> {
unsafe { unsafe {
let data: *() = cast::reinterpret_cast(&self.data); let data: *() = cast::reinterpret_cast(&self.data);
if data.is_null() { if data.is_null() {
fail ~"Recursive use of dvec"; die!(~"Recursive use of dvec");
} }
} }
} }
@ -102,7 +102,7 @@ priv impl<A> DVec<A> {
let mut data = cast::reinterpret_cast(&null::<()>()); let mut data = cast::reinterpret_cast(&null::<()>());
data <-> self.data; data <-> self.data;
let data_ptr: *() = cast::reinterpret_cast(&data); let data_ptr: *() = cast::reinterpret_cast(&data);
if data_ptr.is_null() { fail ~"Recursive use of dvec"; } if data_ptr.is_null() { die!(~"Recursive use of dvec"); }
return f(move data); return f(move data);
} }
} }
@ -329,7 +329,7 @@ impl<A: Copy> DVec<A> {
let length = self.len(); let length = self.len();
if length == 0 { if length == 0 {
fail ~"attempt to retrieve the last element of an empty vector"; die!(~"attempt to retrieve the last element of an empty vector");
} }
return self.data[length - 1]; return self.data[length - 1];

View file

@ -136,7 +136,7 @@ pub pure fn unwrap_left<T,U>(eith: Either<T,U>) -> T {
//! Retrieves the value in the left branch. Fails if the either is Right. //! Retrieves the value in the left branch. Fails if the either is Right.
match move eith { match move eith {
Left(move x) => move x, Right(_) => fail ~"either::unwrap_left Right" Left(move x) => move x, Right(_) => die!(~"either::unwrap_left Right")
} }
} }
@ -145,7 +145,7 @@ pub pure fn unwrap_right<T,U>(eith: Either<T,U>) -> U {
//! Retrieves the value in the right branch. Fails if the either is Left. //! Retrieves the value in the right branch. Fails if the either is Left.
match move eith { match move eith {
Right(move x) => move x, Left(_) => fail ~"either::unwrap_right Left" Right(move x) => move x, Left(_) => die!(~"either::unwrap_right Left")
} }
} }

View file

@ -342,7 +342,7 @@ pub mod ct {
} }
#[cfg(test)] #[cfg(test)]
fn die(s: &str) -> ! { fail s.to_owned() } fn die(s: &str) -> ! { die!(s.to_owned()) }
#[test] #[test]
fn test_parse_count() { fn test_parse_count() {

View file

@ -516,7 +516,7 @@ pub fn test_from_str() {
// note: NaN != NaN, hence this slightly complex test // note: NaN != NaN, hence this slightly complex test
match from_str(~"NaN") { match from_str(~"NaN") {
Some(f) => assert is_NaN(f), Some(f) => assert is_NaN(f),
None => fail None => die!()
} }
assert from_str(~"").is_none(); assert from_str(~"").is_none();

View file

@ -312,7 +312,7 @@ fn expect_sentinel() -> bool { false }
// heap and stack allocations requiring drop, and runs all // heap and stack allocations requiring drop, and runs all
// destructors. // destructors.
// //
// This should only be called from fail, as it will drop the roots // This should only be called from fail!, as it will drop the roots
// which are *live* on the stack, rather than dropping those that are // which are *live* on the stack, rather than dropping those that are
// dead. // dead.
pub fn cleanup_stack_for_failure() { pub fn cleanup_stack_for_failure() {

View file

@ -286,7 +286,7 @@ impl SipState : io::Writer {
} }
fn seek(&self, _x: int, _s: io::SeekStyle) { fn seek(&self, _x: int, _s: io::SeekStyle) {
fail; die!();
} }
fn tell(&self) -> uint { fn tell(&self) -> uint {
self.length self.length

View file

@ -167,7 +167,7 @@ pub mod linear {
/// True if there was no previous entry with that key /// True if there was no previous entry with that key
fn insert_internal(&mut self, hash: uint, k: K, v: V) -> bool { fn insert_internal(&mut self, hash: uint, k: K, v: V) -> bool {
match self.bucket_for_key_with_hash(self.buckets, hash, &k) { match self.bucket_for_key_with_hash(self.buckets, hash, &k) {
TableFull => { fail ~"Internal logic error"; } TableFull => { die!(~"Internal logic error"); }
FoundHole(idx) => { FoundHole(idx) => {
debug!("insert fresh (%?->%?) at idx %?, hash %?", debug!("insert fresh (%?->%?) at idx %?, hash %?",
k, v, idx, hash); k, v, idx, hash);
@ -301,7 +301,7 @@ pub mod linear {
Some(&bkt.value) Some(&bkt.value)
} }
None => { None => {
fail ~"LinearMap::find: internal logic error" die!(~"LinearMap::find: internal logic error")
} }
} }
} }
@ -623,7 +623,7 @@ mod test_map {
assert m.find(&1).is_none(); assert m.find(&1).is_none();
m.insert(1, 2); m.insert(1, 2);
match m.find(&1) { match m.find(&1) {
None => fail, None => die!(),
Some(v) => assert *v == 2 Some(v) => assert *v == 2
} }
} }

View file

@ -112,7 +112,7 @@ pub pure fn is_nonnegative(x: T) -> bool { x >= 0 as T }
pub pure fn range_step(start: T, stop: T, step: T, it: fn(T) -> bool) { pub pure fn range_step(start: T, stop: T, step: T, it: fn(T) -> bool) {
let mut i = start; let mut i = start;
if step == 0 { if step == 0 {
fail ~"range_step called with step == 0"; die!(~"range_step called with step == 0");
} else if step > 0 { // ascending } else if step > 0 { // ascending
while i < stop { while i < stop {
if !it(i) { break } if !it(i) { break }
@ -359,16 +359,16 @@ pub fn test_ranges() {
// None of the `fail`s should execute. // None of the `fail`s should execute.
for range(10,0) |_i| { for range(10,0) |_i| {
fail ~"unreachable"; die!(~"unreachable");
} }
for range_rev(0,10) |_i| { for range_rev(0,10) |_i| {
fail ~"unreachable"; die!(~"unreachable");
} }
for range_step(10,0,1) |_i| { for range_step(10,0,1) |_i| {
fail ~"unreachable"; die!(~"unreachable");
} }
for range_step(0,10,-1) |_i| { for range_step(0,10,-1) |_i| {
fail ~"unreachable"; die!(~"unreachable");
} }
} }

View file

@ -611,7 +611,7 @@ impl *libc::FILE: Writer {
if nout != len as size_t { if nout != len as size_t {
error!("error writing buffer"); error!("error writing buffer");
log(error, os::last_os_error()); log(error, os::last_os_error());
fail; die!();
} }
} }
} }
@ -661,7 +661,7 @@ impl fd_t: Writer {
if nout < 0 as ssize_t { if nout < 0 as ssize_t {
error!("error writing buffer"); error!("error writing buffer");
log(error, os::last_os_error()); log(error, os::last_os_error());
fail; die!();
} }
count += nout as uint; count += nout as uint;
} }
@ -670,11 +670,11 @@ impl fd_t: Writer {
} }
fn seek(&self, _offset: int, _whence: SeekStyle) { fn seek(&self, _offset: int, _whence: SeekStyle) {
error!("need 64-bit foreign calls for seek, sorry"); error!("need 64-bit foreign calls for seek, sorry");
fail; die!();
} }
fn tell(&self) -> uint { fn tell(&self) -> uint {
error!("need 64-bit foreign calls for tell, sorry"); error!("need 64-bit foreign calls for tell, sorry");
fail; die!();
} }
fn flush(&self) -> int { 0 } fn flush(&self) -> int { 0 }
fn get_type(&self) -> WriterType { fn get_type(&self) -> WriterType {
@ -1279,7 +1279,7 @@ mod tests {
result::Err(copy e) => { result::Err(copy e) => {
assert e == ~"error opening not a file"; assert e == ~"error opening not a file";
} }
result::Ok(_) => fail result::Ok(_) => die!()
} }
} }
@ -1320,7 +1320,7 @@ mod tests {
result::Err(copy e) => { result::Err(copy e) => {
assert str::starts_with(e, "error opening"); assert str::starts_with(e, "error opening");
} }
result::Ok(_) => fail result::Ok(_) => die!()
} }
} }
@ -1330,7 +1330,7 @@ mod tests {
result::Err(copy e) => { result::Err(copy e) => {
assert str::starts_with(e, "error opening"); assert str::starts_with(e, "error opening");
} }
result::Ok(_) => fail result::Ok(_) => die!()
} }
} }

View file

@ -33,7 +33,7 @@ mod inst {
if !f(&nobe.data) { break; } if !f(&nobe.data) { break; }
// Check (weakly) that the user didn't do a remove. // Check (weakly) that the user didn't do a remove.
if self.size == 0 { if self.size == 0 {
fail ~"The dlist became empty during iteration??" die!(~"The dlist became empty during iteration??")
} }
if !nobe.linked || if !nobe.linked ||
(!((nobe.prev.is_some() (!((nobe.prev.is_some()
@ -42,7 +42,7 @@ mod inst {
&& (nobe.next.is_some() && (nobe.next.is_some()
|| managed::ptr_eq(self.tl.expect(~"tailless dlist?"), || managed::ptr_eq(self.tl.expect(~"tailless dlist?"),
nobe)))) { nobe)))) {
fail ~"Removing a dlist node during iteration is forbidden!" die!(~"Removing a dlist node during iteration is forbidden!")
} }
link = nobe.next_link(); link = nobe.next_link();
} }

View file

@ -220,7 +220,7 @@ pub pure fn min<A:Copy Ord,IA:BaseIter<A>>(self: &IA) -> A {
} }
} { } {
Some(move val) => val, Some(move val) => val,
None => fail ~"min called on empty iterator" None => die!(~"min called on empty iterator")
} }
} }
@ -235,7 +235,7 @@ pub pure fn max<A:Copy Ord,IA:BaseIter<A>>(self: &IA) -> A {
} }
} { } {
Some(move val) => val, Some(move val) => val,
None => fail ~"max called on empty iterator" None => die!(~"max called on empty iterator")
} }
} }

View file

@ -48,8 +48,8 @@ pub fn unwrap<T>(m: Mut<T>) -> T {
impl<T> Data<T> { impl<T> Data<T> {
fn borrow_mut<R>(op: &fn(t: &mut T) -> R) -> R { fn borrow_mut<R>(op: &fn(t: &mut T) -> R) -> R {
match self.mode { match self.mode {
Immutable => fail fmt!("%? currently immutable", Immutable => die!(fmt!("%? currently immutable",
self.value), self.value)),
ReadOnly | Mutable => {} ReadOnly | Mutable => {}
} }
@ -64,8 +64,8 @@ impl<T> Data<T> {
fn borrow_imm<R>(op: &fn(t: &T) -> R) -> R { fn borrow_imm<R>(op: &fn(t: &T) -> R) -> R {
match self.mode { match self.mode {
Mutable => fail fmt!("%? currently mutable", Mutable => die!(fmt!("%? currently mutable",
self.value), self.value)),
ReadOnly | Immutable => {} ReadOnly | Immutable => {}
} }

View file

@ -183,9 +183,9 @@ fn as_raw_port<T: Owned, U>(ch: Chan<T>, f: fn(*rust_port) -> U) -> U {
let p = PortRef(rustrt::rust_port_take(*ch)); let p = PortRef(rustrt::rust_port_take(*ch));
if ptr::is_null(p.p) { if ptr::is_null(p.p) {
fail ~"unable to locate port for channel" die!(~"unable to locate port for channel")
} else if rustrt::get_task_id() != rustrt::rust_port_task(p.p) { } else if rustrt::get_task_id() != rustrt::rust_port_task(p.p) {
fail ~"unable to access unowned port" die!(~"unable to access unowned port")
} }
f(p.p) f(p.p)
@ -298,7 +298,7 @@ pub fn select2<A: Owned, B: Owned>(p_a: Port<A>, p_b: Port<B>)
} else if resport == (**p_b).po { } else if resport == (**p_b).po {
either::Right(recv(p_b)) either::Right(recv(p_b))
} else { } else {
fail ~"unexpected result from rust_port_select"; die!(~"unexpected result from rust_port_select");
} }
} }
} }
@ -466,7 +466,7 @@ fn test_select2_stress() {
match select2(po_a, po_b) { match select2(po_a, po_b) {
either::Left(~"a") => as_ += 1, either::Left(~"a") => as_ += 1,
either::Right(~"b") => bs += 1, either::Right(~"b") => bs += 1,
_ => fail ~"test_select_2_stress failed" _ => die!(~"test_select_2_stress failed")
} }
} }
@ -536,7 +536,7 @@ fn test_port_detach_fail() {
let ch = po.chan(); let ch = po.chan();
do task::spawn { do task::spawn {
fail; die!();
} }
do task::spawn { do task::spawn {

View file

@ -78,7 +78,7 @@ pub pure fn get<T: Copy>(opt: Option<T>) -> T {
match opt { match opt {
Some(copy x) => return x, Some(copy x) => return x,
None => fail ~"option::get none" None => die!(~"option::get none")
} }
} }
@ -100,7 +100,7 @@ pub pure fn get_ref<T>(opt: &r/Option<T>) -> &r/T {
*/ */
match *opt { match *opt {
Some(ref x) => x, Some(ref x) => x,
None => fail ~"option::get_ref none" None => die!(~"option::get_ref none")
} }
} }
@ -229,7 +229,7 @@ pub pure fn unwrap<T>(opt: Option<T>) -> T {
*/ */
match move opt { match move opt {
Some(move x) => move x, Some(move x) => move x,
None => fail ~"option::unwrap none" None => die!(~"option::unwrap none")
} }
} }
@ -243,7 +243,7 @@ pub fn swap_unwrap<T>(opt: &mut Option<T>) -> T {
Fails if the value equals `None`. Fails if the value equals `None`.
*/ */
if opt.is_none() { fail ~"option::swap_unwrap none" } if opt.is_none() { die!(~"option::swap_unwrap none") }
unwrap(util::replace(opt, None)) unwrap(util::replace(opt, None))
} }
@ -252,7 +252,7 @@ pub pure fn expect<T>(opt: Option<T>, reason: &str) -> T {
//! As unwrap, but with a specified failure message. //! As unwrap, but with a specified failure message.
match move opt { match move opt {
Some(move val) => val, Some(move val) => val,
None => fail reason.to_owned(), None => die!(reason.to_owned()),
} }
} }

View file

@ -1212,7 +1212,7 @@ mod tests {
assert (libc::fclose(ostream) == (0u as c_int)); assert (libc::fclose(ostream) == (0u as c_int));
let rs = os::copy_file(&in, &out); let rs = os::copy_file(&in, &out);
if (!os::path_exists(&in)) { if (!os::path_exists(&in)) {
fail (fmt!("%s doesn't exist", in.to_str())); die!(fmt!("%s doesn't exist", in.to_str()));
} }
assert(rs); assert(rs);
let rslt = run::run_program(~"diff", ~[in.to_str(), out.to_str()]); let rslt = run::run_program(~"diff", ~[in.to_str(), out.to_str()]);

View file

@ -384,7 +384,7 @@ fn wait_event(this: *rust_task) -> *libc::c_void {
let killed = rustrt::task_wait_event(this, &mut event); let killed = rustrt::task_wait_event(this, &mut event);
if killed && !task::failing() { if killed && !task::failing() {
fail ~"killed" die!(~"killed")
} }
event event
} }
@ -506,7 +506,7 @@ pub fn send<T: Owned, Tbuffer: Owned>(p: SendPacketBuffered<T, Tbuffer>,
//unsafe { forget(p); } //unsafe { forget(p); }
return true; return true;
} }
Full => fail ~"duplicate send", Full => die!(~"duplicate send"),
Blocked => { Blocked => {
debug!("waking up task for %?", p_); debug!("waking up task for %?", p_);
let old_task = swap_task(&mut p.header.blocked_task, ptr::null()); let old_task = swap_task(&mut p.header.blocked_task, ptr::null());
@ -667,7 +667,7 @@ pub fn try_recv<T: Owned, Tbuffer: Owned>(p: RecvPacketBuffered<T, Tbuffer>)
debug!("woke up, p.state = %?", copy p.header.state); debug!("woke up, p.state = %?", copy p.header.state);
} }
Blocked => if first { Blocked => if first {
fail ~"blocking on already blocked packet" die!(~"blocking on already blocked packet")
}, },
Full => { Full => {
let mut payload = None; let mut payload = None;
@ -703,7 +703,7 @@ pub fn try_recv<T: Owned, Tbuffer: Owned>(p: RecvPacketBuffered<T, Tbuffer>)
pub pure fn peek<T: Owned, Tb: Owned>(p: &RecvPacketBuffered<T, Tb>) -> bool { pub pure fn peek<T: Owned, Tb: Owned>(p: &RecvPacketBuffered<T, Tb>) -> bool {
match unsafe {(*p.header()).state} { match unsafe {(*p.header()).state} {
Empty | Terminated => false, Empty | Terminated => false,
Blocked => fail ~"peeking on blocked packet", Blocked => die!(~"peeking on blocked packet"),
Full => true Full => true
} }
} }
@ -736,7 +736,7 @@ fn sender_terminate<T: Owned>(p: *Packet<T>) {
} }
Full => { Full => {
// This is impossible // This is impossible
fail ~"you dun goofed" die!(~"you dun goofed")
} }
Terminated => { Terminated => {
assert p.header.blocked_task.is_null(); assert p.header.blocked_task.is_null();
@ -799,7 +799,7 @@ fn wait_many<T: Selectable>(pkts: &[T]) -> uint {
(*p).state = old; (*p).state = old;
break; break;
} }
Blocked => fail ~"blocking on blocked packet", Blocked => die!(~"blocking on blocked packet"),
Empty => () Empty => ()
} }
} }
@ -872,7 +872,7 @@ pub fn select2<A: Owned, Ab: Owned, B: Owned, Bb: Owned>(
match i { match i {
0 => Left((try_recv(move a), move b)), 0 => Left((try_recv(move a), move b)),
1 => Right((move a, try_recv(move b))), 1 => Right((move a, try_recv(move b))),
_ => fail ~"select2 return an invalid packet" _ => die!(~"select2 return an invalid packet")
} }
} }
@ -896,7 +896,7 @@ pub fn select2i<A: Selectable, B: Selectable>(a: &A, b: &B) ->
match wait_many([a.header(), b.header()]) { match wait_many([a.header(), b.header()]) {
0 => Left(()), 0 => Left(()),
1 => Right(()), 1 => Right(()),
_ => fail ~"wait returned unexpected index" _ => die!(~"wait returned unexpected index")
} }
} }
@ -1048,7 +1048,7 @@ impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> {
//forget(packet); //forget(packet);
header header
}, },
None => fail ~"packet already consumed" None => die!(~"packet already consumed")
} }
} }
@ -1147,7 +1147,7 @@ impl<T: Owned, Tbuffer: Owned> RecvPacketBuffered<T, Tbuffer> : Selectable {
//forget(packet); //forget(packet);
header header
}, },
None => fail ~"packet already consumed" None => die!(~"packet already consumed")
} }
} }
} }
@ -1391,7 +1391,7 @@ impl<T: Owned> Port<T>: Peekable<T> {
endp <-> self.endp; endp <-> self.endp;
let peek = match &endp { let peek = match &endp {
&Some(ref endp) => pipes::peek(endp), &Some(ref endp) => pipes::peek(endp),
&None => fail ~"peeking empty stream" &None => die!(~"peeking empty stream")
}; };
self.endp <-> endp; self.endp <-> endp;
peek peek
@ -1404,7 +1404,7 @@ impl<T: Owned> Port<T>: Selectable {
unsafe { unsafe {
match self.endp { match self.endp {
Some(ref endp) => endp.header(), Some(ref endp) => endp.header(),
None => fail ~"peeking empty stream" None => die!(~"peeking empty stream")
} }
} }
} }
@ -1639,7 +1639,7 @@ pub mod test {
c1.send(~"abc"); c1.send(~"abc");
match (move p1, move p2).select() { match (move p1, move p2).select() {
Right(_) => fail, Right(_) => die!(),
_ => () _ => ()
} }

View file

@ -225,7 +225,7 @@ pub unsafe fn unwrap_shared_mutable_state<T: Owned>(rc: SharedMutableState<T>)
cast::forget(move ptr); cast::forget(move ptr);
// Also we have to free the (rejected) server endpoints. // Also we have to free the (rejected) server endpoints.
let _server: UnwrapProto = cast::transmute(move serverp); let _server: UnwrapProto = cast::transmute(move serverp);
fail ~"Another task is already unwrapping this ARC!"; die!(~"Another task is already unwrapping this ARC!");
} }
} }
} }
@ -371,7 +371,7 @@ impl<T: Owned> Exclusive<T> {
let rec = unsafe { get_shared_mutable_state(&self.x) }; let rec = unsafe { get_shared_mutable_state(&self.x) };
do rec.lock.lock { do rec.lock.lock {
if rec.failed { if rec.failed {
fail ~"Poisoned exclusive - another task failed inside!"; die!(~"Poisoned exclusive - another task failed inside!");
} }
rec.failed = true; rec.failed = true;
let result = f(&mut rec.data); let result = f(&mut rec.data);
@ -513,7 +513,7 @@ pub mod tests {
let x2 = x.clone(); let x2 = x.clone();
do task::spawn { do task::spawn {
for 10.times { task::yield(); } // try to let the unwrapper go for 10.times { task::yield(); } // try to let the unwrapper go
fail; // punt it awake from its deadlock die!(); // punt it awake from its deadlock
} }
let _z = unwrap_exclusive(move x); let _z = unwrap_exclusive(move x);
do x2.with |_hello| { } do x2.with |_hello| { }

View file

@ -298,7 +298,7 @@ impl ReprVisitor : TyVisitor {
} }
// Type no longer exists, vestigial function. // Type no longer exists, vestigial function.
fn visit_str() -> bool { fail; } fn visit_str() -> bool { die!(); }
fn visit_estr_box() -> bool { fn visit_estr_box() -> bool {
do self.get::<@str> |s| { do self.get::<@str> |s| {
@ -320,7 +320,7 @@ impl ReprVisitor : TyVisitor {
// Type no longer exists, vestigial function. // Type no longer exists, vestigial function.
fn visit_estr_fixed(_n: uint, _sz: uint, fn visit_estr_fixed(_n: uint, _sz: uint,
_align: uint) -> bool { fail; } _align: uint) -> bool { die!(); }
fn visit_box(mtbl: uint, inner: *TyDesc) -> bool { fn visit_box(mtbl: uint, inner: *TyDesc) -> bool {
self.writer.write_char('@'); self.writer.write_char('@');
@ -356,7 +356,7 @@ impl ReprVisitor : TyVisitor {
} }
// Type no longer exists, vestigial function. // Type no longer exists, vestigial function.
fn visit_vec(_mtbl: uint, _inner: *TyDesc) -> bool { fail; } fn visit_vec(_mtbl: uint, _inner: *TyDesc) -> bool { die!(); }
fn visit_unboxed_vec(mtbl: uint, inner: *TyDesc) -> bool { fn visit_unboxed_vec(mtbl: uint, inner: *TyDesc) -> bool {
@ -555,7 +555,7 @@ impl ReprVisitor : TyVisitor {
} }
// Type no longer exists, vestigial function. // Type no longer exists, vestigial function.
fn visit_constr(_inner: *TyDesc) -> bool { fail; } fn visit_constr(_inner: *TyDesc) -> bool { die!(); }
fn visit_closure_ptr(_ck: uint) -> bool { true } fn visit_closure_ptr(_ck: uint) -> bool { true }
} }

View file

@ -44,7 +44,7 @@ pub pure fn get<T: Copy, U>(res: &Result<T, U>) -> T {
match *res { match *res {
Ok(copy t) => t, Ok(copy t) => t,
Err(ref the_err) => unsafe { Err(ref the_err) => unsafe {
fail fmt!("get called on error result: %?", *the_err) die!(fmt!("get called on error result: %?", *the_err))
} }
} }
} }
@ -61,7 +61,7 @@ pub pure fn get_ref<T, U>(res: &a/Result<T, U>) -> &a/T {
match *res { match *res {
Ok(ref t) => t, Ok(ref t) => t,
Err(ref the_err) => unsafe { Err(ref the_err) => unsafe {
fail fmt!("get_ref called on error result: %?", *the_err) die!(fmt!("get_ref called on error result: %?", *the_err))
} }
} }
} }
@ -77,7 +77,7 @@ pub pure fn get_ref<T, U>(res: &a/Result<T, U>) -> &a/T {
pub pure fn get_err<T, U: Copy>(res: &Result<T, U>) -> U { pub pure fn get_err<T, U: Copy>(res: &Result<T, U>) -> U {
match *res { match *res {
Err(copy u) => u, Err(copy u) => u,
Ok(_) => fail ~"get_err called on ok result" Ok(_) => die!(~"get_err called on ok result")
} }
} }
@ -382,7 +382,7 @@ pub fn iter_vec2<S,T,U:Copy>(ss: &[S], ts: &[T],
pub pure fn unwrap<T, U>(res: Result<T, U>) -> T { pub pure fn unwrap<T, U>(res: Result<T, U>) -> T {
match move res { match move res {
Ok(move t) => move t, Ok(move t) => move t,
Err(_) => fail ~"unwrap called on an err result" Err(_) => die!(~"unwrap called on an err result")
} }
} }
@ -391,7 +391,7 @@ pub pure fn unwrap<T, U>(res: Result<T, U>) -> T {
pub pure fn unwrap_err<T, U>(res: Result<T, U>) -> U { pub pure fn unwrap_err<T, U>(res: Result<T, U>) -> U {
match move res { match move res {
Err(move u) => move u, Err(move u) => move u,
Ok(_) => fail ~"unwrap called on an ok result" Ok(_) => die!(~"unwrap called on an ok result")
} }
} }

View file

@ -184,7 +184,7 @@ fn with_dirp<T>(d: &Option<~str>,
pub fn run_program(prog: &str, args: &[~str]) -> int { pub fn run_program(prog: &str, args: &[~str]) -> int {
let pid = spawn_process(prog, args, &None, &None, let pid = spawn_process(prog, args, &None, &None,
0i32, 0i32, 0i32); 0i32, 0i32, 0i32);
if pid == -1 as pid_t { fail; } if pid == -1 as pid_t { die!(); }
return waitpid(pid); return waitpid(pid);
} }
@ -214,7 +214,7 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program {
pipe_err.out); pipe_err.out);
unsafe { unsafe {
if pid == -1 as pid_t { fail; } if pid == -1 as pid_t { die!(); }
libc::close(pipe_input.in); libc::close(pipe_input.in);
libc::close(pipe_output.out); libc::close(pipe_output.out);
libc::close(pipe_err.out); libc::close(pipe_err.out);
@ -328,7 +328,7 @@ pub fn program_output(prog: &str, args: &[~str]) ->
os::close(pipe_in.out); os::close(pipe_in.out);
os::close(pipe_out.in); os::close(pipe_out.in);
os::close(pipe_err.in); os::close(pipe_err.in);
fail; die!();
} }
os::close(pipe_in.out); os::close(pipe_in.out);
@ -362,7 +362,7 @@ pub fn program_output(prog: &str, args: &[~str]) ->
errs = move s; errs = move s;
} }
(n, _) => { (n, _) => {
fail(fmt!("program_output received an unexpected file \ die!(fmt!("program_output received an unexpected file \
number: %u", n)); number: %u", n));
} }
}; };
@ -474,7 +474,7 @@ mod tests {
os::close(pipe_out.out); os::close(pipe_out.out);
os::close(pipe_err.out); os::close(pipe_err.out);
if pid == -1i32 { fail; } if pid == -1i32 { die!(); }
let expected = ~"test"; let expected = ~"test";
writeclose(pipe_in.out, copy expected); writeclose(pipe_in.out, copy expected);
let actual = readclose(pipe_out.in); let actual = readclose(pipe_out.in);

View file

@ -2990,7 +2990,7 @@ mod tests {
#[should_fail] #[should_fail]
fn test_as_bytes_fail() { fn test_as_bytes_fail() {
// Don't double free // Don't double free
as_bytes::<()>(&~"", |_bytes| fail ); as_bytes::<()>(&~"", |_bytes| die!() );
} }
#[test] #[test]
@ -3090,12 +3090,12 @@ mod tests {
0 => assert ch == 'x', 0 => assert ch == 'x',
1 => assert ch == '\u03c0', 1 => assert ch == '\u03c0',
2 => assert ch == 'y', 2 => assert ch == 'y',
_ => fail ~"test_chars_each failed" _ => die!(~"test_chars_each failed")
} }
i += 1; i += 1;
} }
chars_each(~"", |_ch| fail ); // should not fail chars_each(~"", |_ch| die!() ); // should not fail
} }
#[test] #[test]
@ -3107,7 +3107,7 @@ mod tests {
0 => assert bb == 'x' as u8, 0 => assert bb == 'x' as u8,
1 => assert bb == 'y' as u8, 1 => assert bb == 'y' as u8,
2 => assert bb == 'z' as u8, 2 => assert bb == 'z' as u8,
_ => fail ~"test_bytes_each failed" _ => die!(~"test_bytes_each failed")
} }
i += 1; i += 1;
} }
@ -3169,7 +3169,7 @@ mod tests {
ii += 1; ii += 1;
} }
words_each(~"", |_x| fail); // should not fail words_each(~"", |_x| die!()); // should not fail
} }
#[test] #[test]

View file

@ -133,15 +133,15 @@ fn test_tls_modify() {
fn my_key(_x: @~str) { } fn my_key(_x: @~str) { }
local_data_modify(my_key, |data| { local_data_modify(my_key, |data| {
match data { match data {
Some(@ref val) => fail ~"unwelcome value: " + *val, Some(@ref val) => die!(~"unwelcome value: " + *val),
None => Some(@~"first data") None => Some(@~"first data")
} }
}); });
local_data_modify(my_key, |data| { local_data_modify(my_key, |data| {
match data { match data {
Some(@~"first data") => Some(@~"next data"), Some(@~"first data") => Some(@~"next data"),
Some(@ref val) => fail ~"wrong value: " + *val, Some(@ref val) => die!(~"wrong value: " + *val),
None => fail ~"missing value" None => die!(~"missing value")
} }
}); });
assert *(local_data_pop(my_key).get()) == ~"next data"; assert *(local_data_pop(my_key).get()) == ~"next data";
@ -212,11 +212,11 @@ fn test_tls_cleanup_on_failure() {
local_data_set(str_key, @~"string data"); local_data_set(str_key, @~"string data");
local_data_set(box_key, @@()); local_data_set(box_key, @@());
local_data_set(int_key, @42); local_data_set(int_key, @42);
fail; die!();
} }
} }
// Not quite nondeterministic. // Not quite nondeterministic.
local_data_set(int_key, @31337); local_data_set(int_key, @31337);
fail; die!();
} }
} }

View file

@ -218,7 +218,7 @@ pub fn task() -> TaskBuilder {
priv impl TaskBuilder { priv impl TaskBuilder {
fn consume() -> TaskBuilder { fn consume() -> TaskBuilder {
if self.consumed { if self.consumed {
fail ~"Cannot copy a task_builder"; // Fake move mode on self die!(~"Cannot copy a task_builder"); // Fake move mode on self
} }
self.consumed = true; self.consumed = true;
let notify_chan = replace(&mut self.opts.notify_chan, None); let notify_chan = replace(&mut self.opts.notify_chan, None);
@ -314,7 +314,7 @@ impl TaskBuilder {
// sending out messages. // sending out messages.
if self.opts.notify_chan.is_some() { if self.opts.notify_chan.is_some() {
fail ~"Can't set multiple future_results for one task!"; die!(~"Can't set multiple future_results for one task!");
} }
// Construct the future and give it to the caller. // Construct the future and give it to the caller.
@ -548,7 +548,7 @@ pub fn yield() {
let task_ = rt::rust_get_task(); let task_ = rt::rust_get_task();
let killed = rt::rust_task_yield(task_); let killed = rt::rust_task_yield(task_);
if killed && !failing() { if killed && !failing() {
fail ~"killed"; die!(~"killed");
} }
} }
} }
@ -694,24 +694,24 @@ fn test_spawn_unlinked_unsup_no_fail_down() { // grandchild sends on a port
for iter::repeat(16) { task::yield(); } for iter::repeat(16) { task::yield(); }
ch.send(()); // If killed first, grandparent hangs. ch.send(()); // If killed first, grandparent hangs.
} }
fail; // Shouldn't kill either (grand)parent or (grand)child. die!(); // Shouldn't kill either (grand)parent or (grand)child.
} }
po.recv(); po.recv();
} }
#[test] #[ignore(cfg(windows))] #[test] #[ignore(cfg(windows))]
fn test_spawn_unlinked_unsup_no_fail_up() { // child unlinked fails fn test_spawn_unlinked_unsup_no_fail_up() { // child unlinked fails
do spawn_unlinked { fail; } do spawn_unlinked { die!(); }
} }
#[test] #[ignore(cfg(windows))] #[test] #[ignore(cfg(windows))]
fn test_spawn_unlinked_sup_no_fail_up() { // child unlinked fails fn test_spawn_unlinked_sup_no_fail_up() { // child unlinked fails
do spawn_supervised { fail; } do spawn_supervised { die!(); }
// Give child a chance to fail-but-not-kill-us. // Give child a chance to fail-but-not-kill-us.
for iter::repeat(16) { task::yield(); } for iter::repeat(16) { task::yield(); }
} }
#[test] #[should_fail] #[ignore(cfg(windows))] #[test] #[should_fail] #[ignore(cfg(windows))]
fn test_spawn_unlinked_sup_fail_down() { fn test_spawn_unlinked_sup_fail_down() {
do spawn_supervised { loop { task::yield(); } } do spawn_supervised { loop { task::yield(); } }
fail; // Shouldn't leave a child hanging around. die!(); // Shouldn't leave a child hanging around.
} }
#[test] #[should_fail] #[ignore(cfg(windows))] #[test] #[should_fail] #[ignore(cfg(windows))]
@ -754,7 +754,7 @@ fn test_spawn_linked_sup_fail_down() { // parent fails; child fails
.. b0 .. b0
}; };
do b1.spawn { loop { task::yield(); } } do b1.spawn { loop { task::yield(); } }
fail; // *both* mechanisms would be wrong if this didn't kill the child... die!(); // *both* mechanisms would be wrong if this didn't kill the child
} }
#[test] #[should_fail] #[ignore(cfg(windows))] #[test] #[should_fail] #[ignore(cfg(windows))]
fn test_spawn_linked_unsup_fail_up() { // child fails; parent fails fn test_spawn_linked_unsup_fail_up() { // child fails; parent fails
@ -767,13 +767,13 @@ fn test_spawn_linked_unsup_fail_up() { // child fails; parent fails
fn test_spawn_linked_unsup_fail_down() { // parent fails; child fails fn test_spawn_linked_unsup_fail_down() { // parent fails; child fails
// Default options are to spawn linked & unsupervised. // Default options are to spawn linked & unsupervised.
do spawn { loop { task::yield(); } } do spawn { loop { task::yield(); } }
fail; die!();
} }
#[test] #[should_fail] #[ignore(cfg(windows))] #[test] #[should_fail] #[ignore(cfg(windows))]
fn test_spawn_linked_unsup_default_opts() { // parent fails; child fails fn test_spawn_linked_unsup_default_opts() { // parent fails; child fails
// Make sure the above test is the same as this one. // Make sure the above test is the same as this one.
do task().linked().spawn { loop { task::yield(); } } do task().linked().spawn { loop { task::yield(); } }
fail; die!();
} }
// A couple bonus linked failure tests - testing for failure propagation even // A couple bonus linked failure tests - testing for failure propagation even
@ -788,7 +788,7 @@ fn test_spawn_failure_propagate_grandchild() {
} }
} }
for iter::repeat(16) { task::yield(); } for iter::repeat(16) { task::yield(); }
fail; die!();
} }
#[test] #[should_fail] #[ignore(cfg(windows))] #[test] #[should_fail] #[ignore(cfg(windows))]
@ -800,7 +800,7 @@ fn test_spawn_failure_propagate_secondborn() {
} }
} }
for iter::repeat(16) { task::yield(); } for iter::repeat(16) { task::yield(); }
fail; die!();
} }
#[test] #[should_fail] #[ignore(cfg(windows))] #[test] #[should_fail] #[ignore(cfg(windows))]
@ -812,7 +812,7 @@ fn test_spawn_failure_propagate_nephew_or_niece() {
} }
} }
for iter::repeat(16) { task::yield(); } for iter::repeat(16) { task::yield(); }
fail; die!();
} }
#[test] #[should_fail] #[ignore(cfg(windows))] #[test] #[should_fail] #[ignore(cfg(windows))]
@ -824,7 +824,7 @@ fn test_spawn_linked_sup_propagate_sibling() {
} }
} }
for iter::repeat(16) { task::yield(); } for iter::repeat(16) { task::yield(); }
fail; die!();
} }
#[test] #[test]
@ -868,7 +868,7 @@ fn test_future_result() {
result = None; result = None;
do task().future_result(|+r| do task().future_result(|+r|
{ result = Some(move r); }).unlinked().spawn { { result = Some(move r); }).unlinked().spawn {
fail; die!();
} }
assert option::unwrap(move result).recv() == Failure; assert option::unwrap(move result).recv() == Failure;
} }
@ -884,7 +884,7 @@ fn test_try_success() {
~"Success!" ~"Success!"
} { } {
result::Ok(~"Success!") => (), result::Ok(~"Success!") => (),
_ => fail _ => die!()
} }
} }
@ -892,10 +892,10 @@ fn test_try_success() {
#[ignore(cfg(windows))] #[ignore(cfg(windows))]
fn test_try_fail() { fn test_try_fail() {
match do try { match do try {
fail die!()
} { } {
result::Err(()) => (), result::Err(()) => (),
result::Ok(()) => fail result::Ok(()) => die!()
} }
} }
@ -1095,7 +1095,7 @@ fn test_unkillable() {
yield(); yield();
// We want to fail after the unkillable task // We want to fail after the unkillable task
// blocks on recv // blocks on recv
fail; die!();
} }
unsafe { unsafe {
@ -1130,7 +1130,7 @@ fn test_unkillable_nested() {
yield(); yield();
// We want to fail after the unkillable task // We want to fail after the unkillable task
// blocks on recv // blocks on recv
fail; die!();
} }
unsafe { unsafe {

View file

@ -697,7 +697,7 @@ fn test_spawn_raw_unsupervise() {
.. default_task_opts() .. default_task_opts()
}; };
do spawn_raw(move opts) { do spawn_raw(move opts) {
fail; die!();
} }
} }
@ -727,7 +727,7 @@ fn test_spawn_raw_notify_failure() {
.. default_task_opts() .. default_task_opts()
}; };
do spawn_raw(move opts) { do spawn_raw(move opts) {
fail; die!();
} }
assert notify_po.recv() == Failure; assert notify_po.recv() == Failure;
} }

View file

@ -76,7 +76,7 @@ pub pure fn is_nonnegative(x: T) -> bool { x >= 0 as T }
pub pure fn range_step(start: T, stop: T, step: T_SIGNED, it: fn(T) -> bool) { pub pure fn range_step(start: T, stop: T, step: T_SIGNED, it: fn(T) -> bool) {
let mut i = start; let mut i = start;
if step == 0 { if step == 0 {
fail ~"range_step called with step == 0"; die!(~"range_step called with step == 0");
} }
if step >= 0 { if step >= 0 {
while i < stop { while i < stop {
@ -243,7 +243,7 @@ pub pure fn to_str_bytes<U>(neg: bool, num: T, radix: uint,
} else if n <= 15u as T { } else if n <= 15u as T {
(n - 10 as T) as u8 + 'a' as u8 (n - 10 as T) as u8 + 'a' as u8
} else { } else {
fail; die!();
} }
} }
@ -357,16 +357,16 @@ pub fn test_ranges() {
// None of the `fail`s should execute. // None of the `fail`s should execute.
for range(0,0) |_i| { for range(0,0) |_i| {
fail ~"unreachable"; die!(~"unreachable");
} }
for range_rev(0,0) |_i| { for range_rev(0,0) |_i| {
fail ~"unreachable"; die!(~"unreachable");
} }
for range_step(10,0,1) |_i| { for range_step(10,0,1) |_i| {
fail ~"unreachable"; die!(~"unreachable");
} }
for range_step(0,1,-10) |_i| { for range_step(0,1,-10) |_i| {
fail ~"unreachable"; die!(~"unreachable");
} }
} }

View file

@ -100,7 +100,7 @@ fn choose_weighted_item(v: &[Item]) -> Item {
*/ */
pub fn unreachable() -> ! { pub fn unreachable() -> ! {
fail ~"internal error: entered unreachable code"; die!(~"internal error: entered unreachable code");
} }
mod tests { mod tests {

View file

@ -241,7 +241,7 @@ pub pure fn init<T: Copy>(v: &[const T]) -> ~[T] {
/// Returns the last element of the slice `v`, failing if the slice is empty. /// Returns the last element of the slice `v`, failing if the slice is empty.
pub pure fn last<T: Copy>(v: &[const T]) -> T { pub pure fn last<T: Copy>(v: &[const T]) -> T {
if len(v) == 0u { fail ~"last_unsafe: empty vector" } if len(v) == 0u { die!(~"last_unsafe: empty vector") }
v[len(v) - 1u] v[len(v) - 1u]
} }
@ -568,7 +568,7 @@ pub fn consume_mut<T>(v: ~[mut T], f: fn(uint, v: T)) {
pub fn pop<T>(v: &mut ~[T]) -> T { pub fn pop<T>(v: &mut ~[T]) -> T {
let ln = v.len(); let ln = v.len();
if ln == 0 { if ln == 0 {
fail ~"sorry, cannot vec::pop an empty vector" die!(~"sorry, cannot vec::pop an empty vector")
} }
let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]); let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]);
unsafe { unsafe {
@ -589,7 +589,7 @@ pub fn pop<T>(v: &mut ~[T]) -> T {
pub fn swap_remove<T>(v: &mut ~[T], index: uint) -> T { pub fn swap_remove<T>(v: &mut ~[T], index: uint) -> T {
let ln = v.len(); let ln = v.len();
if index >= ln { if index >= ln {
fail fmt!("vec::swap_remove - index %u >= length %u", index, ln); die!(fmt!("vec::swap_remove - index %u >= length %u", index, ln));
} }
if index < ln - 1 { if index < ln - 1 {
v[index] <-> v[ln - 1]; v[index] <-> v[ln - 1];
@ -831,7 +831,7 @@ pub pure fn flat_map<T, U>(v: &[T], f: fn(t: &T) -> ~[U]) -> ~[U] {
pub pure fn map2<T: Copy, U: Copy, V>(v0: &[T], v1: &[U], pub pure fn map2<T: Copy, U: Copy, V>(v0: &[T], v1: &[U],
f: fn(t: &T, v: &U) -> V) -> ~[V] { f: fn(t: &T, v: &U) -> V) -> ~[V] {
let v0_len = len(v0); let v0_len = len(v0);
if v0_len != len(v1) { fail; } if v0_len != len(v1) { die!(); }
let mut u: ~[V] = ~[]; let mut u: ~[V] = ~[];
let mut i = 0u; let mut i = 0u;
while i < v0_len { while i < v0_len {
@ -2859,7 +2859,7 @@ mod tests {
#[test] #[test]
fn test_each_empty() { fn test_each_empty() {
for each::<int>(~[]) |_v| { for each::<int>(~[]) |_v| {
fail; // should never be executed die!(); // should never be executed
} }
} }
@ -2886,7 +2886,7 @@ mod tests {
#[test] #[test]
fn test_reach_empty() { fn test_reach_empty() {
for rev_each::<int>(~[]) |_v| { for rev_each::<int>(~[]) |_v| {
fail; // should never execute die!(); // should never execute
} }
} }
@ -3388,7 +3388,7 @@ mod tests {
#[should_fail] #[should_fail]
fn test_from_fn_fail() { fn test_from_fn_fail() {
do from_fn(100) |v| { do from_fn(100) |v| {
if v == 50 { fail } if v == 50 { die!() }
(~0, @0) (~0, @0)
}; };
} }
@ -3402,7 +3402,7 @@ mod tests {
push((~0, @0)); push((~0, @0));
push((~0, @0)); push((~0, @0));
push((~0, @0)); push((~0, @0));
fail; die!();
}; };
} }
@ -3415,7 +3415,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do split(v) |_elt| { do split(v) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 1; i += 1;
@ -3432,7 +3432,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do split(v) |_elt| { do split(v) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 1; i += 1;
@ -3449,7 +3449,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do splitn(v, 100) |_elt| { do splitn(v, 100) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 1; i += 1;
@ -3466,7 +3466,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do split(v) |_elt| { do split(v) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 1; i += 1;
@ -3483,7 +3483,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do rsplit(v) |_elt| { do rsplit(v) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 1; i += 1;
@ -3500,7 +3500,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do rsplit(v) |_elt| { do rsplit(v) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 1; i += 1;
@ -3517,7 +3517,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do rsplitn(v, 100) |_elt| { do rsplitn(v, 100) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 1; i += 1;
@ -3534,7 +3534,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do rsplitn(v, 100) |_elt| { do rsplitn(v, 100) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 1; i += 1;
@ -3550,7 +3550,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do consume(v) |_i, _elt| { do consume(v) |_i, _elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 1; i += 1;
}; };
@ -3564,7 +3564,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do consume_mut(v) |_i, _elt| { do consume_mut(v) |_i, _elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 1; i += 1;
}; };
@ -3578,7 +3578,7 @@ mod tests {
let mut v = ~[]; let mut v = ~[];
do v.grow_fn(100) |i| { do v.grow_fn(100) |i| {
if i == 50 { if i == 50 {
fail die!()
} }
(~0, @0) (~0, @0)
} }
@ -3592,7 +3592,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do map(v) |_elt| { do map(v) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
~[(~0, @0)] ~[(~0, @0)]
@ -3607,7 +3607,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do map_consume(v) |_elt| { do map_consume(v) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
~[(~0, @0)] ~[(~0, @0)]
@ -3622,7 +3622,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do mapi(v) |_i, _elt| { do mapi(v) |_i, _elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
~[(~0, @0)] ~[(~0, @0)]
@ -3637,7 +3637,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do map(v) |_elt| { do map(v) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
~[(~0, @0)] ~[(~0, @0)]
@ -3653,7 +3653,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do map2(v, v) |_elt1, _elt2| { do map2(v, v) |_elt1, _elt2| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
~[(~0, @0)] ~[(~0, @0)]
@ -3669,7 +3669,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do filter_map(v) |_elt| { do filter_map(v) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
Some((~0, @0)) Some((~0, @0))
@ -3685,7 +3685,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do v.filtered |_elt| { do v.filtered |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
true true
@ -3701,7 +3701,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do foldl((~0, @0), v) |_a, _b| { do foldl((~0, @0), v) |_a, _b| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
(~0, @0) (~0, @0)
@ -3717,7 +3717,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do foldr(v, (~0, @0)) |_a, _b| { do foldr(v, (~0, @0)) |_a, _b| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
(~0, @0) (~0, @0)
@ -3732,7 +3732,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do any(v) |_elt| { do any(v) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
false false
@ -3747,7 +3747,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do any(v) |_elt| { do any(v) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
false false
@ -3762,7 +3762,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do all(v) |_elt| { do all(v) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
true true
@ -3777,7 +3777,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do alli(v) |_i, _elt| { do alli(v) |_i, _elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
true true
@ -3792,7 +3792,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do all2(v, v) |_elt1, _elt2| { do all2(v, v) |_elt1, _elt2| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
true true
@ -3808,7 +3808,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do find(v) |_elt| { do find(v) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
false false
@ -3823,7 +3823,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do position(v) |_elt| { do position(v) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
false false
@ -3838,7 +3838,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do rposition(v) |_elt| { do rposition(v) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
false false
@ -3853,7 +3853,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do each(v) |_elt| { do each(v) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
false false
@ -3868,7 +3868,7 @@ mod tests {
let mut i = 0; let mut i = 0;
do eachi(v) |_i, _elt| { do eachi(v) |_i, _elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
false false
@ -3884,7 +3884,7 @@ mod tests {
let mut i = 0; let mut i = 0;
for each_permutation(v) |_elt| { for each_permutation(v) |_elt| {
if i == 2 { if i == 2 {
fail die!()
} }
i += 0; i += 0;
} }
@ -3896,7 +3896,7 @@ mod tests {
fn test_as_imm_buf_fail() { fn test_as_imm_buf_fail() {
let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)]; let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
do as_imm_buf(v) |_buf, _i| { do as_imm_buf(v) |_buf, _i| {
fail die!()
} }
} }
@ -3906,7 +3906,7 @@ mod tests {
fn test_as_const_buf_fail() { fn test_as_const_buf_fail() {
let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)]; let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
do as_const_buf(v) |_buf, _i| { do as_const_buf(v) |_buf, _i| {
fail die!()
} }
} }
@ -3916,7 +3916,7 @@ mod tests {
fn test_as_mut_buf_fail() { fn test_as_mut_buf_fail() {
let v = [mut (~0, @0), (~0, @0), (~0, @0), (~0, @0)]; let v = [mut (~0, @0), (~0, @0), (~0, @0), (~0, @0)];
do as_mut_buf(v) |_buf, _i| { do as_mut_buf(v) |_buf, _i| {
fail die!()
} }
} }

View file

@ -573,7 +573,7 @@ pub fn check_roundtrip_convergence(code: @~str, maxIters: uint) {
run::run_program(~"diff", run::run_program(~"diff",
~[~"-w", ~"-u", ~"round-trip-a.rs", ~[~"-w", ~"-u", ~"round-trip-a.rs",
~"round-trip-b.rs"]); ~"round-trip-b.rs"]);
fail ~"Mismatch"; die!(~"Mismatch");
} }
} }

View file

@ -42,7 +42,7 @@ fn shuffled<T: copy>(r : rand::rng, v : ~[T]) -> ~[T] {
} }
// sample from a population without replacement // sample from a population without replacement
//fn sample<T>(r : rand::rng, pop : ~[T], k : uint) -> ~[T] { fail } //fn sample<T>(r : rand::rng, pop : ~[T], k : uint) -> ~[T] { die!() }
// Two ways to make a weighted choice. // Two ways to make a weighted choice.
// * weighted_choice is O(number of choices) time // * weighted_choice is O(number of choices) time

View file

@ -509,7 +509,7 @@ pub fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
} }
ast::meta_list(_, _) => { ast::meta_list(_, _) => {
// FIXME (#607): Implement this // FIXME (#607): Implement this
fail ~"unimplemented meta_item variant"; die!(~"unimplemented meta_item variant");
} }
} }
} }

View file

@ -179,7 +179,7 @@ pub fn get_install_prefix_rpath(target_triple: &str) -> Path {
let install_prefix = env!("CFG_PREFIX"); let install_prefix = env!("CFG_PREFIX");
if install_prefix == ~"" { if install_prefix == ~"" {
fail ~"rustc compiled without CFG_PREFIX environment variable"; die!(~"rustc compiled without CFG_PREFIX environment variable");
} }
let tlib = filesearch::relative_target_lib_path(target_triple); let tlib = filesearch::relative_target_lib_path(target_triple);

View file

@ -506,7 +506,7 @@ pub fn host_triple() -> ~str {
return if ht != ~"" { return if ht != ~"" {
ht ht
} else { } else {
fail ~"rustc built without CFG_HOST_TRIPLE" die!(~"rustc built without CFG_HOST_TRIPLE")
}; };
} }
@ -846,7 +846,7 @@ pub fn build_output_filenames(input: input,
pub fn early_error(emitter: diagnostic::emitter, msg: ~str) -> ! { pub fn early_error(emitter: diagnostic::emitter, msg: ~str) -> ! {
emitter(None, msg, diagnostic::fatal); emitter(None, msg, diagnostic::fatal);
fail; die!();
} }
pub fn list_metadata(sess: Session, path: &Path, out: io::Writer) { pub fn list_metadata(sess: Session, path: &Path, out: io::Writer) {
@ -874,8 +874,8 @@ pub mod test {
let matches = let matches =
&match getopts(~[~"--test"], optgroups()) { &match getopts(~[~"--test"], optgroups()) {
Ok(copy m) => m, Ok(copy m) => m,
Err(copy f) => fail ~"test_switch_implies_cfg_test: " + Err(copy f) => die!(~"test_switch_implies_cfg_test: " +
getopts::fail_str(f) getopts::fail_str(f))
}; };
let sessopts = build_session_options( let sessopts = build_session_options(
~"rustc", matches, diagnostic::emit); ~"rustc", matches, diagnostic::emit);
@ -892,8 +892,8 @@ pub mod test {
&match getopts(~[~"--test", ~"--cfg=test"], optgroups()) { &match getopts(~[~"--test", ~"--cfg=test"], optgroups()) {
Ok(copy m) => m, Ok(copy m) => m,
Err(copy f) => { Err(copy f) => {
fail ~"test_switch_implies_cfg_test_unless_cfg_test: " + die!(~"test_switch_implies_cfg_test_unless_cfg_test: " +
getopts::fail_str(f); getopts::fail_str(f));
} }
}; };
let sessopts = build_session_options( let sessopts = build_session_options(

View file

@ -1451,7 +1451,7 @@ pub fn float_width(llt: TypeRef) -> uint {
2 => 64u, 2 => 64u,
3 => 80u, 3 => 80u,
4 | 5 => 128u, 4 | 5 => 128u,
_ => fail ~"llvm_float_width called on a non-float type" _ => die!(~"llvm_float_width called on a non-float type")
}; };
} }
} }

View file

@ -91,7 +91,7 @@ fn find_item(item_id: int, items: ebml::Doc) -> ebml::Doc {
fn lookup_item(item_id: int, data: @~[u8]) -> ebml::Doc { fn lookup_item(item_id: int, data: @~[u8]) -> ebml::Doc {
let items = reader::get_doc(reader::Doc(data), tag_items); let items = reader::get_doc(reader::Doc(data), tag_items);
match maybe_find_item(item_id, items) { match maybe_find_item(item_id, items) {
None => fail(fmt!("lookup_item: id not found: %d", item_id)), None => die!(fmt!("lookup_item: id not found: %d", item_id)),
Some(d) => d Some(d) => d
} }
} }
@ -149,7 +149,7 @@ fn item_family(item: ebml::Doc) -> Family {
'g' => PublicField, 'g' => PublicField,
'j' => PrivateField, 'j' => PrivateField,
'N' => InheritedField, 'N' => InheritedField,
c => fail (fmt!("unexpected family char: %c", c)) c => die!(fmt!("unexpected family char: %c", c))
} }
} }
@ -396,7 +396,7 @@ pub fn struct_dtor(cdata: cmd, id: ast::node_id) -> Option<ast::def_id> {
let mut found = None; let mut found = None;
let cls_items = match maybe_find_item(id, items) { let cls_items = match maybe_find_item(id, items) {
Some(it) => it, Some(it) => it,
None => fail (fmt!("struct_dtor: class id not found \ None => die!(fmt!("struct_dtor: class id not found \
when looking up dtor for %d", id)) when looking up dtor for %d", id))
}; };
for reader::tagged_docs(cls_items, tag_item_dtor) |doc| { for reader::tagged_docs(cls_items, tag_item_dtor) |doc| {
@ -421,8 +421,8 @@ pub enum def_like {
fn def_like_to_def(def_like: def_like) -> ast::def { fn def_like_to_def(def_like: def_like) -> ast::def {
match def_like { match def_like {
dl_def(def) => return def, dl_def(def) => return def,
dl_impl(*) => fail ~"found impl in def_like_to_def", dl_impl(*) => die!(~"found impl in def_like_to_def"),
dl_field => fail ~"found field in def_like_to_def" dl_field => die!(~"found field in def_like_to_def")
} }
} }
@ -625,7 +625,7 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ {
'm' => { ast::m_mutbl } 'm' => { ast::m_mutbl }
'c' => { ast::m_const } 'c' => { ast::m_const }
_ => { _ => {
fail fmt!("unknown mutability character: `%c`", ch as char) die!(fmt!("unknown mutability character: `%c`", ch as char))
} }
} }
} }
@ -642,7 +642,7 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ {
'~' => { return ast::sty_uniq(get_mutability(string[1])); } '~' => { return ast::sty_uniq(get_mutability(string[1])); }
'&' => { return ast::sty_region(get_mutability(string[1])); } '&' => { return ast::sty_region(get_mutability(string[1])); }
_ => { _ => {
fail fmt!("unknown self type code: `%c`", self_ty_kind as char); die!(fmt!("unknown self type code: `%c`", self_ty_kind as char));
} }
} }
} }
@ -832,7 +832,7 @@ pub fn get_static_methods_if_impl(intr: @ident_interner,
StaticMethod => purity = ast::impure_fn, StaticMethod => purity = ast::impure_fn,
UnsafeStaticMethod => purity = ast::unsafe_fn, UnsafeStaticMethod => purity = ast::unsafe_fn,
PureStaticMethod => purity = ast::pure_fn, PureStaticMethod => purity = ast::pure_fn,
_ => fail _ => die!()
} }
static_impl_methods.push(StaticMethodInfo { static_impl_methods.push(StaticMethodInfo {
@ -865,7 +865,7 @@ pure fn family_to_visibility(family: Family) -> ast::visibility {
PublicField => ast::public, PublicField => ast::public,
PrivateField => ast::private, PrivateField => ast::private,
InheritedField => ast::inherited, InheritedField => ast::inherited,
_ => fail _ => die!()
} }
} }
@ -915,7 +915,7 @@ fn describe_def(items: ebml::Doc, id: ast::def_id) -> ~str {
if id.crate != ast::local_crate { return ~"external"; } if id.crate != ast::local_crate { return ~"external"; }
let it = match maybe_find_item(id.node, items) { let it = match maybe_find_item(id.node, items) {
Some(it) => it, Some(it) => it,
None => fail (fmt!("describe_def: item not found %?", id)) None => die!(fmt!("describe_def: item not found %?", id))
}; };
return item_family_to_str(item_family(it)); return item_family_to_str(item_family(it));
} }
@ -1100,7 +1100,7 @@ pub fn translate_def_id(cdata: cmd, did: ast::def_id) -> ast::def_id {
match cdata.cnum_map.find(did.crate) { match cdata.cnum_map.find(did.crate) {
option::Some(n) => ast::def_id { crate: n, node: did.node }, option::Some(n) => ast::def_id { crate: n, node: did.node },
option::None => fail ~"didn't find a crate in the cnum_map" option::None => die!(~"didn't find a crate in the cnum_map")
} }
} }

View file

@ -527,7 +527,7 @@ fn purity_static_method_family(p: purity) -> char {
unsafe_fn => 'U', unsafe_fn => 'U',
pure_fn => 'P', pure_fn => 'P',
impure_fn => 'F', impure_fn => 'F',
_ => fail ~"extern fn can't be static" _ => die!(~"extern fn can't be static")
} }
} }
@ -829,7 +829,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: writer::Encoder,
true, item.id, *m, /*bad*/copy m.tps); true, item.id, *m, /*bad*/copy m.tps);
} }
} }
item_mac(*) => fail ~"item macros unimplemented" item_mac(*) => die!(~"item macros unimplemented")
} }
} }

View file

@ -108,7 +108,7 @@ fn make_target_lib_path(sysroot: &Path,
fn get_or_default_sysroot() -> Path { fn get_or_default_sysroot() -> Path {
match os::self_exe_path() { match os::self_exe_path() {
option::Some(ref p) => (*p).pop(), option::Some(ref p) => (*p).pop(),
option::None => fail ~"can't determine value for sysroot" option::None => die!(~"can't determine value for sysroot")
} }
} }
@ -176,7 +176,7 @@ fn get_cargo_lib_path_nearest() -> Result<Path, ~str> {
pub fn libdir() -> ~str { pub fn libdir() -> ~str {
let libdir = env!("CFG_LIBDIR"); let libdir = env!("CFG_LIBDIR");
if str::is_empty(libdir) { if str::is_empty(libdir) {
fail ~"rustc compiled without CFG_LIBDIR environment variable"; die!(~"rustc compiled without CFG_LIBDIR environment variable");
} }
libdir libdir
} }

View file

@ -150,10 +150,10 @@ pub fn crate_name_from_metas(+metas: ~[@ast::meta_item]) -> ~str {
Some(ref n) => (/*bad*/copy *n), Some(ref n) => (/*bad*/copy *n),
// FIXME (#2406): Probably want a warning here since the user // FIXME (#2406): Probably want a warning here since the user
// is using the wrong type of meta item. // is using the wrong type of meta item.
_ => fail _ => die!()
} }
} }
None => fail ~"expected to find the crate name" None => die!(~"expected to find the crate name")
} }
} }

View file

@ -135,7 +135,7 @@ fn parse_proto(st: @pstate) -> ast::Proto {
'@' => ast::ProtoBox, '@' => ast::ProtoBox,
'~' => ast::ProtoUniq, '~' => ast::ProtoUniq,
'&' => ast::ProtoBorrowed, '&' => ast::ProtoBorrowed,
_ => fail ~"parse_proto(): bad input" _ => die!(~"parse_proto(): bad input")
} }
} }
@ -153,7 +153,7 @@ fn parse_vstore(st: @pstate) -> ty::vstore {
'~' => ty::vstore_uniq, '~' => ty::vstore_uniq,
'@' => ty::vstore_box, '@' => ty::vstore_box,
'&' => ty::vstore_slice(parse_region(st)), '&' => ty::vstore_slice(parse_region(st)),
_ => fail ~"parse_vstore: bad input" _ => die!(~"parse_vstore: bad input")
} }
} }
@ -188,7 +188,7 @@ fn parse_bound_region(st: @pstate) -> ty::bound_region {
assert next(st) == '|'; assert next(st) == '|';
ty::br_cap_avoid(id, @parse_bound_region(st)) ty::br_cap_avoid(id, @parse_bound_region(st))
}, },
_ => fail ~"parse_bound_region: bad input" _ => die!(~"parse_bound_region: bad input")
} }
} }
@ -213,7 +213,7 @@ fn parse_region(st: @pstate) -> ty::Region {
't' => { 't' => {
ty::re_static ty::re_static
} }
_ => fail ~"parse_region: bad input" _ => die!(~"parse_region: bad input")
} }
} }
@ -221,7 +221,7 @@ fn parse_opt<T>(st: @pstate, f: fn() -> T) -> Option<T> {
match next(st) { match next(st) {
'n' => None, 'n' => None,
's' => Some(f()), 's' => Some(f()),
_ => fail ~"parse_opt: bad input" _ => die!(~"parse_opt: bad input")
} }
} }
@ -254,7 +254,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
'D' => return ty::mk_mach_int(st.tcx, ast::ty_i64), 'D' => return ty::mk_mach_int(st.tcx, ast::ty_i64),
'f' => return ty::mk_mach_float(st.tcx, ast::ty_f32), 'f' => return ty::mk_mach_float(st.tcx, ast::ty_f32),
'F' => return ty::mk_mach_float(st.tcx, ast::ty_f64), 'F' => return ty::mk_mach_float(st.tcx, ast::ty_f64),
_ => fail ~"parse_ty: bad numeric type" _ => die!(~"parse_ty: bad numeric type")
} }
} }
'c' => return ty::mk_char(st.tcx), 'c' => return ty::mk_char(st.tcx),
@ -353,7 +353,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
assert (next(st) == ']'); assert (next(st) == ']');
return ty::mk_struct(st.tcx, did, substs); return ty::mk_struct(st.tcx, did, substs);
} }
c => { error!("unexpected char in type string: %c", c); fail;} c => { error!("unexpected char in type string: %c", c); die!();}
} }
} }
@ -405,7 +405,7 @@ fn parse_purity(c: char) -> purity {
'p' => pure_fn, 'p' => pure_fn,
'i' => impure_fn, 'i' => impure_fn,
'c' => extern_fn, 'c' => extern_fn,
_ => fail ~"parse_purity: bad purity" _ => die!(~"parse_purity: bad purity")
} }
} }
@ -413,7 +413,7 @@ fn parse_onceness(c: char) -> ast::Onceness {
match c { match c {
'o' => ast::Once, 'o' => ast::Once,
'm' => ast::Many, 'm' => ast::Many,
_ => fail ~"parse_onceness: bad onceness" _ => die!(~"parse_onceness: bad onceness")
} }
} }
@ -426,7 +426,7 @@ fn parse_mode(st: @pstate) -> ast::mode {
'+' => ast::by_copy, '+' => ast::by_copy,
'=' => ast::by_ref, '=' => ast::by_ref,
'#' => ast::by_val, '#' => ast::by_val,
_ => fail ~"bad mode" _ => die!(~"bad mode")
}); });
return m; return m;
} }
@ -464,7 +464,7 @@ pub fn parse_def_id(buf: &[u8]) -> ast::def_id {
while colon_idx < len && buf[colon_idx] != ':' as u8 { colon_idx += 1u; } while colon_idx < len && buf[colon_idx] != ':' as u8 { colon_idx += 1u; }
if colon_idx == len { if colon_idx == len {
error!("didn't find ':' when parsing def id"); error!("didn't find ':' when parsing def id");
fail; die!();
} }
let crate_part = vec::view(buf, 0u, colon_idx); let crate_part = vec::view(buf, 0u, colon_idx);
@ -472,12 +472,12 @@ pub fn parse_def_id(buf: &[u8]) -> ast::def_id {
let crate_num = match uint::parse_bytes(crate_part, 10u) { let crate_num = match uint::parse_bytes(crate_part, 10u) {
Some(cn) => cn as int, Some(cn) => cn as int,
None => fail (fmt!("internal error: parse_def_id: crate number \ None => die!(fmt!("internal error: parse_def_id: crate number \
expected, but found %?", crate_part)) expected, but found %?", crate_part))
}; };
let def_num = match uint::parse_bytes(def_part, 10u) { let def_num = match uint::parse_bytes(def_part, 10u) {
Some(dn) => dn as int, Some(dn) => dn as int,
None => fail (fmt!("internal error: parse_def_id: id expected, but \ None => die!(fmt!("internal error: parse_def_id: id expected, but \
found %?", def_part)) found %?", def_part))
}; };
ast::def_id { crate: crate_num, node: def_num } ast::def_id { crate: crate_num, node: def_num }
@ -500,7 +500,7 @@ fn parse_bounds(st: @pstate, conv: conv_did) -> @~[ty::param_bound] {
'O' => ty::bound_durable, 'O' => ty::bound_durable,
'I' => ty::bound_trait(parse_ty(st, conv)), 'I' => ty::bound_trait(parse_ty(st, conv)),
'.' => break, '.' => break,
_ => fail ~"parse_bounds: bad bounds" _ => die!(~"parse_bounds: bad bounds")
}); });
} }
@bounds @bounds

View file

@ -321,7 +321,7 @@ fn enc_sty(w: io::Writer, cx: @ctxt, +st: ty::sty) {
debug!("~~~~ %s", ~"]"); debug!("~~~~ %s", ~"]");
w.write_char(']'); w.write_char(']');
} }
ty::ty_err => fail ~"Shouldn't encode error type" ty::ty_err => die!(~"Shouldn't encode error type")
} }
} }

View file

@ -304,7 +304,7 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
span: _}, _) => true, span: _}, _) => true,
ast::stmt_decl(@ast::spanned { node: ast::decl_item(_), ast::stmt_decl(@ast::spanned { node: ast::decl_item(_),
span: _}, _) => false, span: _}, _) => false,
ast::stmt_mac(*) => fail ~"unexpanded macro in astencode" ast::stmt_mac(*) => die!(~"unexpanded macro in astencode")
} }
}; };
let blk_sans_items = ast::blk_ { let blk_sans_items = ast::blk_ {
@ -717,7 +717,7 @@ impl reader::Decoder: vtable_decoder_helpers {
) )
} }
// hard to avoid - user input // hard to avoid - user input
_ => fail ~"bad enum variant" _ => die!(~"bad enum variant")
} }
} }
} }
@ -1288,6 +1288,6 @@ fn test_simplification() {
assert pprust::item_to_str(item_out, ext_cx.parse_sess().interner) assert pprust::item_to_str(item_out, ext_cx.parse_sess().interner)
== pprust::item_to_str(item_exp, ext_cx.parse_sess().interner); == pprust::item_to_str(item_exp, ext_cx.parse_sess().interner);
} }
_ => fail _ => die!()
} }
} }

View file

@ -249,7 +249,7 @@ pub fn check_item_recursion(sess: Session,
ast_map::node_item(it, _) => { ast_map::node_item(it, _) => {
(v.visit_item)(it, env, v); (v.visit_item)(it, env, v);
} }
_ => fail ~"const not bound to an item" _ => die!(~"const not bound to an item")
} }
} }
_ => () _ => ()

View file

@ -148,11 +148,11 @@ pub fn check_exhaustive(cx: @MatchCheckCtxt, sp: span, pats: ~[@pat]) {
} }
ty::ty_enum(id, _) => { ty::ty_enum(id, _) => {
let vid = match (*ctor) { variant(id) => id, let vid = match (*ctor) { variant(id) => id,
_ => fail ~"check_exhaustive: non-variant ctor" }; _ => die!(~"check_exhaustive: non-variant ctor") };
match vec::find(*ty::enum_variants(cx.tcx, id), match vec::find(*ty::enum_variants(cx.tcx, id),
|v| v.id == vid) { |v| v.id == vid) {
Some(v) => Some(cx.tcx.sess.str_of(v.name)), Some(v) => Some(cx.tcx.sess.str_of(v.name)),
None => fail ~"check_exhaustive: bad variant in ctor" None => die!(~"check_exhaustive: bad variant in ctor")
} }
} }
ty::ty_unboxed_vec(*) | ty::ty_evec(*) => { ty::ty_unboxed_vec(*) | ty::ty_evec(*) => {
@ -367,7 +367,7 @@ pub fn missing_ctor(cx: @MatchCheckCtxt,
return Some(variant(v.id)); return Some(variant(v.id));
} }
} }
fail; die!();
} else { None } } else { None }
} }
ty::ty_nil => None, ty::ty_nil => None,
@ -378,7 +378,7 @@ pub fn missing_ctor(cx: @MatchCheckCtxt,
None => (), None => (),
Some(val(const_bool(true))) => true_found = true, Some(val(const_bool(true))) => true_found = true,
Some(val(const_bool(false))) => false_found = true, Some(val(const_bool(false))) => false_found = true,
_ => fail ~"impossible case" _ => die!(~"impossible case")
} }
} }
if true_found && false_found { None } if true_found && false_found { None }
@ -446,10 +446,10 @@ pub fn ctor_arity(cx: @MatchCheckCtxt, ctor: ctor, ty: ty::t) -> uint {
ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_rptr(*) => 1u, ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_rptr(*) => 1u,
ty::ty_enum(eid, _) => { ty::ty_enum(eid, _) => {
let id = match ctor { variant(id) => id, let id = match ctor { variant(id) => id,
_ => fail ~"impossible case" }; _ => die!(~"impossible case") };
match vec::find(*ty::enum_variants(cx.tcx, eid), |v| v.id == id ) { match vec::find(*ty::enum_variants(cx.tcx, eid), |v| v.id == id ) {
Some(v) => v.args.len(), Some(v) => v.args.len(),
None => fail ~"impossible case" None => die!(~"impossible case")
} }
} }
ty::ty_struct(cid, _) => ty::lookup_struct_fields(cx.tcx, cid).len(), ty::ty_struct(cid, _) => ty::lookup_struct_fields(cx.tcx, cid).len(),
@ -497,7 +497,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
compare_const_vals((*c_hi), e_v) <= 0 compare_const_vals((*c_hi), e_v) <= 0
} }
single => true, single => true,
_ => fail ~"type error" _ => die!(~"type error")
}; };
if match_ { Some(vec::tail(r)) } else { None } if match_ { Some(vec::tail(r)) } else { None }
} }
@ -530,7 +530,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
pat_rec(ref flds, _) => { pat_rec(ref flds, _) => {
let ty_flds = match /*bad*/copy ty::get(left_ty).sty { let ty_flds = match /*bad*/copy ty::get(left_ty).sty {
ty::ty_rec(flds) => flds, ty::ty_rec(flds) => flds,
_ => fail ~"bad type for pat_rec" _ => die!(~"bad type for pat_rec")
}; };
let args = vec::map(ty_flds, |ty_fld| { let args = vec::map(ty_flds, |ty_fld| {
match flds.find(|f| f.ident == ty_fld.ident) { match flds.find(|f| f.ident == ty_fld.ident) {
@ -596,7 +596,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
compare_const_vals((*c_hi), e_v) <= 0 compare_const_vals((*c_hi), e_v) <= 0
} }
single => true, single => true,
_ => fail ~"type error" _ => die!(~"type error")
}; };
if match_ { Some(vec::tail(r)) } else { None } if match_ { Some(vec::tail(r)) } else { None }
} }
@ -606,7 +606,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
range(ref lo, ref hi) => range(ref lo, ref hi) =>
((/*bad*/copy *lo), (/*bad*/copy *hi)), ((/*bad*/copy *lo), (/*bad*/copy *hi)),
single => return Some(vec::tail(r)), single => return Some(vec::tail(r)),
_ => fail ~"type error" _ => die!(~"type error")
}; };
let v_lo = eval_const_expr(cx.tcx, lo), let v_lo = eval_const_expr(cx.tcx, lo),
v_hi = eval_const_expr(cx.tcx, hi); v_hi = eval_const_expr(cx.tcx, hi);

View file

@ -233,7 +233,7 @@ pub enum const_val {
pub fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val { pub fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val {
match eval_const_expr_partial(tcx, e) { match eval_const_expr_partial(tcx, e) {
Ok(ref r) => (/*bad*/copy *r), Ok(ref r) => (/*bad*/copy *r),
Err(ref s) => fail (/*bad*/copy *s) Err(ref s) => die!(/*bad*/copy *s)
} }
} }
@ -459,7 +459,7 @@ pub fn compare_const_vals(a: const_val, b: const_val) -> int {
1 1
} }
} }
_ => fail ~"compare_const_vals: ill-typed comparison" _ => die!(~"compare_const_vals: ill-typed comparison")
} }
} }

View file

@ -59,7 +59,7 @@ fn collect_freevars(def_map: resolve::DefMap, blk: ast::blk)
ast::expr_path(*) => { ast::expr_path(*) => {
let mut i = 0; let mut i = 0;
match def_map.find(expr.id) { match def_map.find(expr.id) {
None => fail ~"path not found", None => die!(~"path not found"),
Some(df) => { Some(df) => {
let mut def = df; let mut def = df;
while i < depth { while i < depth {
@ -119,7 +119,7 @@ pub fn annotate_freevars(def_map: resolve::DefMap, crate: @ast::crate) ->
pub fn get_freevars(tcx: ty::ctxt, fid: ast::node_id) -> freevar_info { pub fn get_freevars(tcx: ty::ctxt, fid: ast::node_id) -> freevar_info {
match tcx.freevars.find(fid) { match tcx.freevars.find(fid) {
None => fail ~"get_freevars: " + int::str(fid) + ~" has no freevars", None => die!(~"get_freevars: " + int::str(fid) + ~" has no freevars"),
Some(d) => return d Some(d) => return d
} }
} }

View file

@ -213,11 +213,11 @@ pub fn check_expr(e: @expr, cx: ctx, v: visit::vt<ctx>) {
}; };
if vec::len(*ts) != vec::len(*bounds) { if vec::len(*ts) != vec::len(*bounds) {
// Fail earlier to make debugging easier // Fail earlier to make debugging easier
fail fmt!("internal error: in kind::check_expr, length \ die!(fmt!("internal error: in kind::check_expr, length \
mismatch between actual and declared bounds: actual = \ mismatch between actual and declared bounds: actual = \
%s (%u tys), declared = %? (%u tys)", %s (%u tys), declared = %? (%u tys)",
tys_to_str(cx.tcx, *ts), ts.len(), tys_to_str(cx.tcx, *ts), ts.len(),
*bounds, (*bounds).len()); *bounds, (*bounds).len()));
} }
for vec::each2(*ts, *bounds) |ty, bound| { for vec::each2(*ts, *bounds) |ty, bound| {
check_bounds(cx, type_parameter_id, e.span, *ty, *bound) check_bounds(cx, type_parameter_id, e.span, *ty, *bound)

View file

@ -481,7 +481,7 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) {
ast::gt => v >= min, ast::gt => v >= min,
ast::ge => v > min, ast::ge => v > min,
ast::eq | ast::ne => v >= min && v <= max, ast::eq | ast::ne => v >= min && v <= max,
_ => fail _ => die!()
} }
} }
@ -540,7 +540,7 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) {
ast::lit_int_unsuffixed(v) => v, ast::lit_int_unsuffixed(v) => v,
_ => return true _ => return true
}, },
_ => fail _ => die!()
}; };
is_valid(norm_binop, lit_val, min, max) is_valid(norm_binop, lit_val, min, max)
} }
@ -553,7 +553,7 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) {
ast::lit_int_unsuffixed(v) => v as u64, ast::lit_int_unsuffixed(v) => v as u64,
_ => return true _ => return true
}, },
_ => fail _ => die!()
}; };
is_valid(norm_binop, lit_val, min, max) is_valid(norm_binop, lit_val, min, max)
} }
@ -954,7 +954,7 @@ fn check_fn_deprecated_modes(tcx: ty::ctxt, fn_ty: ty::t, decl: ast::fn_decl,
ty_to_str(tcx, arg_ty.ty), ty_to_str(tcx, arg_ty.ty),
mode_to_str(arg_ast.mode)); mode_to_str(arg_ast.mode));
error!("%?",arg_ast.ty.node); error!("%?",arg_ast.ty.node);
fail die!()
} }
}; };
} }

View file

@ -322,7 +322,7 @@ pub fn namespace_for_duplicate_checking_mode(mode: DuplicateCheckingMode)
ForbidDuplicateModules | ForbidDuplicateTypes | ForbidDuplicateModules | ForbidDuplicateTypes |
ForbidDuplicateTypesAndValues => TypeNS, ForbidDuplicateTypesAndValues => TypeNS,
ForbidDuplicateValues => ValueNS, ForbidDuplicateValues => ValueNS,
OverwriteDuplicates => fail ~"OverwriteDuplicates has no namespace" OverwriteDuplicates => die!(~"OverwriteDuplicates has no namespace")
} }
} }
@ -604,8 +604,8 @@ pub impl NameBindings {
fn get_module() -> @Module { fn get_module() -> @Module {
match self.get_module_if_available() { match self.get_module_if_available() {
None => { None => {
fail ~"get_module called on a node with no module \ die!(~"get_module called on a node with no module \
definition!" definition!")
} }
Some(module_def) => module_def Some(module_def) => module_def
} }
@ -1326,7 +1326,7 @@ pub impl Resolver {
} }
item_mac(*) => { item_mac(*) => {
fail ~"item macros unimplemented" die!(~"item macros unimplemented")
} }
} }
} }
@ -1579,7 +1579,7 @@ pub impl Resolver {
match existing_module.parent_link { match existing_module.parent_link {
NoParentLink | NoParentLink |
BlockParentLink(*) => { BlockParentLink(*) => {
fail ~"can't happen"; die!(~"can't happen");
} }
ModuleParentLink(parent_module, ident) => { ModuleParentLink(parent_module, ident) => {
let name_bindings = parent_module.children.get(ident); let name_bindings = parent_module.children.get(ident);
@ -1645,7 +1645,7 @@ pub impl Resolver {
def_prim_ty(*) | def_ty_param(*) | def_binding(*) | def_prim_ty(*) | def_ty_param(*) | def_binding(*) |
def_use(*) | def_upvar(*) | def_region(*) | def_use(*) | def_upvar(*) | def_region(*) |
def_typaram_binder(*) | def_label(*) | def_self_ty(*) => { def_typaram_binder(*) | def_label(*) | def_self_ty(*) => {
fail fmt!("didn't expect `%?`", def); die!(fmt!("didn't expect `%?`", def));
} }
} }
} }
@ -2221,7 +2221,7 @@ pub impl Resolver {
} }
UnboundResult => { /* Continue. */ } UnboundResult => { /* Continue. */ }
UnknownResult => { UnknownResult => {
fail ~"value result should be known at this point"; die!(~"value result should be known at this point");
} }
} }
match type_result { match type_result {
@ -2231,7 +2231,7 @@ pub impl Resolver {
} }
UnboundResult => { /* Continue. */ } UnboundResult => { /* Continue. */ }
UnknownResult => { UnknownResult => {
fail ~"type result should be known at this point"; die!(~"type result should be known at this point");
} }
} }
@ -2384,7 +2384,7 @@ pub impl Resolver {
binding"); binding");
} }
UnknownResult => { UnknownResult => {
fail ~"module result should be known at this point"; die!(~"module result should be known at this point");
} }
} }
@ -2996,7 +2996,7 @@ pub impl Resolver {
allowable_namespaces = namespaces; allowable_namespaces = namespaces;
} }
GlobImport => { GlobImport => {
fail ~"found `import *`, which is invalid"; die!(~"found `import *`, which is invalid");
} }
} }
@ -3116,9 +3116,9 @@ pub impl Resolver {
// Otherwise, proceed and write in the bindings. // Otherwise, proceed and write in the bindings.
match module_.import_resolutions.find(target_name) { match module_.import_resolutions.find(target_name) {
None => { None => {
fail ~"(resolving one-level renaming import) reduced graph \ die!(~"(resolving one-level renaming import) reduced graph \
construction or glob importing should have created the \ construction or glob importing should have created the \
import resolution name by now"; import resolution name by now");
} }
Some(import_resolution) => { Some(import_resolution) => {
debug!("(resolving one-level renaming import) writing module \ debug!("(resolving one-level renaming import) writing module \
@ -3732,7 +3732,7 @@ pub impl Resolver {
} }
item_mac(*) => { item_mac(*) => {
fail ~"item macros unimplemented" die!(~"item macros unimplemented")
} }
} }
@ -4430,8 +4430,8 @@ pub impl Resolver {
Success(target) => { Success(target) => {
match target.bindings.value_def { match target.bindings.value_def {
None => { None => {
fail ~"resolved name in the value namespace to a set \ die!(~"resolved name in the value namespace to a set \
of name bindings with no def?!"; of name bindings with no def?!");
} }
Some(def) => { Some(def) => {
match def.def { match def.def {
@ -4450,7 +4450,7 @@ pub impl Resolver {
} }
Indeterminate => { Indeterminate => {
fail ~"unexpected indeterminate result"; die!(~"unexpected indeterminate result");
} }
Failed => { Failed => {
@ -4611,7 +4611,7 @@ pub impl Resolver {
} }
Indeterminate => { Indeterminate => {
fail ~"indeterminate unexpected"; die!(~"indeterminate unexpected");
} }
Success(resulting_module) => { Success(resulting_module) => {
@ -4658,7 +4658,7 @@ pub impl Resolver {
} }
Indeterminate => { Indeterminate => {
fail ~"indeterminate unexpected"; die!(~"indeterminate unexpected");
} }
Success(resulting_module) => { Success(resulting_module) => {
@ -4736,7 +4736,7 @@ pub impl Resolver {
} }
} }
Indeterminate => { Indeterminate => {
fail ~"unexpected indeterminate result"; die!(~"unexpected indeterminate result");
} }
Failed => { Failed => {
return None; return None;

View file

@ -209,8 +209,8 @@ pub fn opt_eq(tcx: ty::ctxt, a: &Opt, b: &Opt) -> bool {
a_expr = e.get(); a_expr = e.get();
} }
UnitLikeStructLit(_) => { UnitLikeStructLit(_) => {
fail ~"UnitLikeStructLit should have been handled \ die!(~"UnitLikeStructLit should have been handled \
above" above")
} }
} }
@ -222,8 +222,8 @@ pub fn opt_eq(tcx: ty::ctxt, a: &Opt, b: &Opt) -> bool {
b_expr = e.get(); b_expr = e.get();
} }
UnitLikeStructLit(_) => { UnitLikeStructLit(_) => {
fail ~"UnitLikeStructLit should have been handled \ die!(~"UnitLikeStructLit should have been handled \
above" above")
} }
} }

View file

@ -1888,7 +1888,7 @@ pub fn trans_enum_variant(ccx: @crate_ctxt,
// works. So we have to cast to the destination's view of the type. // works. So we have to cast to the destination's view of the type.
let llarg = match fcx.llargs.find(va.id) { let llarg = match fcx.llargs.find(va.id) {
Some(local_mem(x)) => x, Some(local_mem(x)) => x,
_ => fail ~"trans_enum_variant: how do we know this works?", _ => die!(~"trans_enum_variant: how do we know this works?"),
}; };
let arg_ty = arg_tys[i].ty; let arg_ty = arg_tys[i].ty;
memcpy_ty(bcx, lldestptr, llarg, arg_ty); memcpy_ty(bcx, lldestptr, llarg, arg_ty);
@ -2024,7 +2024,7 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) {
let path = match ccx.tcx.items.get(item.id) { let path = match ccx.tcx.items.get(item.id) {
ast_map::node_item(_, p) => p, ast_map::node_item(_, p) => p,
// tjc: ? // tjc: ?
_ => fail ~"trans_item", _ => die!(~"trans_item"),
}; };
match /*bad*/copy item.node { match /*bad*/copy item.node {
// XXX: Bad copies. // XXX: Bad copies.
@ -2280,7 +2280,7 @@ pub fn item_path(ccx: @crate_ctxt, i: @ast::item) -> path {
/*bad*/copy *match ccx.tcx.items.get(i.id) { /*bad*/copy *match ccx.tcx.items.get(i.id) {
ast_map::node_item(_, p) => p, ast_map::node_item(_, p) => p,
// separate map for paths? // separate map for paths?
_ => fail ~"item_path" _ => die!(~"item_path")
}, },
~[path_name(i.ident)]) ~[path_name(i.ident)])
} }
@ -2367,7 +2367,7 @@ pub fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
set_inline_hint_if_appr(/*bad*/copy i.attrs, llfn); set_inline_hint_if_appr(/*bad*/copy i.attrs, llfn);
llfn llfn
} }
_ => fail ~"get_item_val: weird result in table" _ => die!(~"get_item_val: weird result in table")
} }
} }
ast_map::node_trait_method(trait_method, _, pth) => { ast_map::node_trait_method(trait_method, _, pth) => {
@ -2448,14 +2448,14 @@ pub fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
ast::item_enum(_, _) => { ast::item_enum(_, _) => {
register_fn(ccx, (*v).span, pth, id, enm.attrs) register_fn(ccx, (*v).span, pth, id, enm.attrs)
} }
_ => fail ~"node_variant, shouldn't happen" _ => die!(~"node_variant, shouldn't happen")
}; };
} }
ast::struct_variant_kind(_) => { ast::struct_variant_kind(_) => {
fail ~"struct variant kind unexpected in get_item_val" die!(~"struct variant kind unexpected in get_item_val")
} }
ast::enum_variant_kind(_) => { ast::enum_variant_kind(_) => {
fail ~"enum variant kind unexpected in get_item_val" die!(~"enum variant kind unexpected in get_item_val")
} }
} }
set_inline_hint(llfn); set_inline_hint(llfn);

View file

@ -33,7 +33,7 @@ pub fn terminate(cx: block, _: &str) {
pub fn check_not_terminated(cx: block) { pub fn check_not_terminated(cx: block) {
if cx.terminated { if cx.terminated {
fail ~"already terminated!"; die!(~"already terminated!");
} }
} }

View file

@ -96,7 +96,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
let elt = llvm::LLVMGetElementType(ty); let elt = llvm::LLVMGetElementType(ty);
ty_align(elt) ty_align(elt)
} }
_ => fail ~"ty_size: unhandled type" _ => die!(~"ty_size: unhandled type")
}; };
} }
} }
@ -122,7 +122,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
let eltsz = ty_size(elt); let eltsz = ty_size(elt);
len * eltsz len * eltsz
} }
_ => fail ~"ty_size: unhandled type" _ => die!(~"ty_size: unhandled type")
}; };
} }
} }
@ -215,7 +215,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
i += 1u; i += 1u;
} }
} }
_ => fail ~"classify: unhandled type" _ => die!(~"classify: unhandled type")
} }
} }
} }
@ -315,7 +315,7 @@ fn llreg_ty(cls: &[x86_64_reg_class]) -> TypeRef {
sse_ds_class => { sse_ds_class => {
tys.push(T_f64()); tys.push(T_f64());
} }
_ => fail ~"llregtype: unhandled class" _ => die!(~"llregtype: unhandled class")
} }
i += 1u; i += 1u;
} }

View file

@ -383,7 +383,7 @@ pub fn trans_rtcall_or_lang_call_with_type_params(bcx: block,
llfnty = T_ptr(struct_elt(llfnty, 0)); llfnty = T_ptr(struct_elt(llfnty, 0));
new_llval = PointerCast(callee.bcx, fn_data.llfn, llfnty); new_llval = PointerCast(callee.bcx, fn_data.llfn, llfnty);
} }
_ => fail _ => die!()
} }
Callee { bcx: callee.bcx, data: Fn(FnData { llfn: new_llval }) } Callee { bcx: callee.bcx, data: Fn(FnData { llfn: new_llval }) }
}, },

View file

@ -268,7 +268,7 @@ fn create_block(cx: block) -> @metadata<block_md> {
while cx.node_info.is_none() { while cx.node_info.is_none() {
match cx.parent { match cx.parent {
Some(b) => cx = b, Some(b) => cx = b,
None => fail None => die!()
} }
} }
let sp = cx.node_info.get().span; let sp = cx.node_info.get().span;
@ -548,7 +548,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::Ty)
* elsewhere, not be self-contained. * elsewhere, not be self-contained.
*/ */
fail; die!();
/* /*
fn t_to_ty(cx: crate_ctxt, t: ty::t, span: span) -> @ast::ty { fn t_to_ty(cx: crate_ctxt, t: ty::t, span: span) -> @ast::ty {
let ty = match ty::get(t).struct { let ty = match ty::get(t).struct {
@ -664,7 +664,7 @@ pub fn create_local_var(bcx: block, local: @ast::local)
let name = match local.node.pat.node { let name = match local.node.pat.node {
ast::pat_ident(_, pth, _) => ast_util::path_to_ident(pth), ast::pat_ident(_, pth, _) => ast_util::path_to_ident(pth),
// FIXME this should be handled (#2533) // FIXME this should be handled (#2533)
_ => fail ~"no single variable name for local" _ => die!(~"no single variable name for local")
}; };
let loc = cx.sess.codemap.lookup_char_pos(local.span.lo); let loc = cx.sess.codemap.lookup_char_pos(local.span.lo);
let ty = node_id_type(bcx, local.node.id); let ty = node_id_type(bcx, local.node.id);

View file

@ -500,7 +500,7 @@ pub fn trans_intrinsic(ccx: @crate_ctxt,
if tp_sz != out_sz { if tp_sz != out_sz {
let sp = match ccx.tcx.items.get(ref_id.get()) { let sp = match ccx.tcx.items.get(ref_id.get()) {
ast_map::node_expr(e) => e.span, ast_map::node_expr(e) => e.span,
_ => fail ~"reinterpret_cast or forget has non-expr arg" _ => die!(~"reinterpret_cast or forget has non-expr arg")
}; };
ccx.sess.span_fatal( ccx.sess.span_fatal(
sp, fmt!("reinterpret_cast called on types \ sp, fmt!("reinterpret_cast called on types \
@ -958,7 +958,7 @@ fn abi_of_foreign_fn(ccx: @crate_ctxt, i: @ast::foreign_item)
None => match ccx.tcx.items.get(i.id) { None => match ccx.tcx.items.get(i.id) {
ast_map::node_foreign_item(_, abi, _) => abi, ast_map::node_foreign_item(_, abi, _) => abi,
// ?? // ??
_ => fail ~"abi_of_foreign_fn: not foreign" _ => die!(~"abi_of_foreign_fn: not foreign")
}, },
Some(_) => match attr::foreign_abi(i.attrs) { Some(_) => match attr::foreign_abi(i.attrs) {
either::Right(abi) => abi, either::Right(abi) => abi,

View file

@ -253,7 +253,7 @@ pub fn trans_method_callee(bcx: block,
trait_id, off, vtbl) trait_id, off, vtbl)
} }
// how to get rid of this? // how to get rid of this?
None => fail ~"trans_method_callee: missing param_substs" None => die!(~"trans_method_callee: missing param_substs")
} }
} }
typeck::method_trait(_, off, vstore) => { typeck::method_trait(_, off, vstore) => {
@ -311,13 +311,13 @@ pub fn trans_static_method_callee(bcx: block,
ast_map::node_trait_method(trait_method, _, _) => { ast_map::node_trait_method(trait_method, _, _) => {
ast_util::trait_method_to_ty_method(*trait_method).ident ast_util::trait_method_to_ty_method(*trait_method).ident
} }
_ => fail ~"callee is not a trait method" _ => die!(~"callee is not a trait method")
} }
} else { } else {
let path = csearch::get_item_path(bcx.tcx(), method_id); let path = csearch::get_item_path(bcx.tcx(), method_id);
match path[path.len()-1] { match path[path.len()-1] {
path_name(s) => { s } path_name(s) => { s }
path_mod(_) => { fail ~"path doesn't have a name?" } path_mod(_) => { die!(~"path doesn't have a name?") }
} }
}; };
debug!("trans_static_method_callee: method_id=%?, callee_id=%?, \ debug!("trans_static_method_callee: method_id=%?, callee_id=%?, \
@ -347,8 +347,8 @@ pub fn trans_static_method_callee(bcx: block,
FnData {llfn: PointerCast(bcx, lval, llty)} FnData {llfn: PointerCast(bcx, lval, llty)}
} }
_ => { _ => {
fail ~"vtable_param left in monomorphized \ die!(~"vtable_param left in monomorphized \
function's vtable substs"; function's vtable substs");
} }
} }
} }
@ -368,7 +368,7 @@ pub fn method_with_name(ccx: @crate_ctxt, impl_id: ast::def_id,
}, _) => { }, _) => {
method_from_methods(/*bad*/copy *ms, name).get() method_from_methods(/*bad*/copy *ms, name).get()
} }
_ => fail ~"method_with_name" _ => die!(~"method_with_name")
} }
} else { } else {
csearch::get_impl_method(ccx.sess.cstore, impl_id, name) csearch::get_impl_method(ccx.sess.cstore, impl_id, name)
@ -396,13 +396,13 @@ pub fn method_with_name_or_default(ccx: @crate_ctxt, impl_id: ast::def_id,
return pmi.method_info.did; return pmi.method_info.did;
} }
} }
fail die!()
} }
None => fail None => die!()
} }
} }
} }
_ => fail ~"method_with_name" _ => die!(~"method_with_name")
} }
} else { } else {
csearch::get_impl_method(ccx.sess.cstore, impl_id, name) csearch::get_impl_method(ccx.sess.cstore, impl_id, name)
@ -421,14 +421,14 @@ pub fn method_ty_param_count(ccx: @crate_ctxt, m_id: ast::def_id,
method_ty_param_count( method_ty_param_count(
ccx, source.method_id, source.impl_id) ccx, source.method_id, source.impl_id)
} }
None => fail None => die!()
} }
} }
Some(ast_map::node_trait_method(@ast::provided(@ref m), _, _)) Some(ast_map::node_trait_method(@ast::provided(@ref m), _, _))
=> { => {
m.tps.len() m.tps.len()
} }
copy e => fail fmt!("method_ty_param_count %?", e) copy e => die!(fmt!("method_ty_param_count %?", e))
} }
} else { } else {
csearch::get_type_param_count(ccx.sess.cstore, m_id) - csearch::get_type_param_count(ccx.sess.cstore, m_id) -
@ -493,7 +493,8 @@ pub fn trans_monomorphized_callee(bcx: block,
mentry.explicit_self) mentry.explicit_self)
} }
typeck::vtable_param(*) => { typeck::vtable_param(*) => {
fail ~"vtable_param left in monomorphized function's vtable substs"; die!(~"vtable_param left in monomorphized function's " +
"vtable substs");
} }
}; };
@ -768,7 +769,7 @@ pub fn vtable_id(ccx: @crate_ctxt,
} }
} }
// can't this be checked at the callee? // can't this be checked at the callee?
_ => fail ~"vtable_id" _ => die!(~"vtable_id")
} }
} }
@ -783,7 +784,7 @@ pub fn get_vtable(ccx: @crate_ctxt,
typeck::vtable_static(id, substs, sub_vtables) => { typeck::vtable_static(id, substs, sub_vtables) => {
make_impl_vtable(ccx, id, substs, sub_vtables) make_impl_vtable(ccx, id, substs, sub_vtables)
} }
_ => fail ~"get_vtable: expected a static origin" _ => die!(~"get_vtable: expected a static origin")
} }
} }
} }

View file

@ -135,7 +135,7 @@ fn traverse_public_item(cx: ctx, item: @item) {
} }
item_const(*) | item_const(*) |
item_enum(*) | item_trait(*) => (), item_enum(*) | item_trait(*) => (),
item_mac(*) => fail ~"item macros unimplemented" item_mac(*) => die!(~"item macros unimplemented")
} }
} }

View file

@ -147,7 +147,7 @@ pub fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
~"bswap16" | ~"bswap32" | ~"bswap64" => 0, ~"bswap16" | ~"bswap32" | ~"bswap64" => 0,
// would be cool to make these an enum instead of strings! // would be cool to make these an enum instead of strings!
_ => fail ~"unknown intrinsic in type_use" _ => die!(~"unknown intrinsic in type_use")
}; };
for uint::range(0u, n_tps) |n| { cx.uses[n] |= flags;} for uint::range(0u, n_tps) |n| { cx.uses[n] |= flags;}
} }

View file

@ -1568,7 +1568,7 @@ pub fn get_element_type(ty: t, i: uint) -> t {
match /*bad*/copy get(ty).sty { match /*bad*/copy get(ty).sty {
ty_rec(flds) => return flds[i].mt.ty, ty_rec(flds) => return flds[i].mt.ty,
ty_tup(ts) => return ts[i], ty_tup(ts) => return ts[i],
_ => fail ~"get_element_type called on invalid type" _ => die!(~"get_element_type called on invalid type")
} }
} }
@ -2823,28 +2823,28 @@ fn node_id_has_type_params(cx: ctxt, id: ast::node_id) -> bool {
pub fn ty_fn_args(fty: t) -> ~[arg] { pub fn ty_fn_args(fty: t) -> ~[arg] {
match get(fty).sty { match get(fty).sty {
ty_fn(ref f) => /*bad*/copy f.sig.inputs, ty_fn(ref f) => /*bad*/copy f.sig.inputs,
_ => fail ~"ty_fn_args() called on non-fn type" _ => die!(~"ty_fn_args() called on non-fn type")
} }
} }
pub fn ty_fn_proto(fty: t) -> Proto { pub fn ty_fn_proto(fty: t) -> Proto {
match get(fty).sty { match get(fty).sty {
ty_fn(ref f) => f.meta.proto, ty_fn(ref f) => f.meta.proto,
_ => fail ~"ty_fn_proto() called on non-fn type" _ => die!(~"ty_fn_proto() called on non-fn type")
} }
} }
pub fn ty_fn_purity(fty: t) -> ast::purity { pub fn ty_fn_purity(fty: t) -> ast::purity {
match get(fty).sty { match get(fty).sty {
ty_fn(ref f) => f.meta.purity, ty_fn(ref f) => f.meta.purity,
_ => fail ~"ty_fn_purity() called on non-fn type" _ => die!(~"ty_fn_purity() called on non-fn type")
} }
} }
pub pure fn ty_fn_ret(fty: t) -> t { pub pure fn ty_fn_ret(fty: t) -> t {
match get(fty).sty { match get(fty).sty {
ty_fn(ref f) => f.sig.output, ty_fn(ref f) => f.sig.output,
_ => fail ~"ty_fn_ret() called on non-fn type" _ => die!(~"ty_fn_ret() called on non-fn type")
} }
} }
@ -3239,7 +3239,7 @@ pub fn stmt_node_id(s: @ast::stmt) -> ast::node_id {
ast::stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) => { ast::stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) => {
return id; return id;
} }
ast::stmt_mac(*) => fail ~"unexpanded macro in trans" ast::stmt_mac(*) => die!(~"unexpanded macro in trans")
} }
} }
@ -3263,7 +3263,7 @@ pub fn get_field(tcx: ctxt, rec_ty: t, id: ast::ident) -> field {
match vec::find(get_fields(rec_ty), |f| f.ident == id) { match vec::find(get_fields(rec_ty), |f| f.ident == id) {
Some(f) => f, Some(f) => f,
// Do we only call this when we know the field is legit? // Do we only call this when we know the field is legit?
None => fail (fmt!("get_field: ty doesn't have a field %s", None => die!(fmt!("get_field: ty doesn't have a field %s",
tcx.sess.str_of(id))) tcx.sess.str_of(id)))
} }
} }
@ -3272,7 +3272,7 @@ pub fn get_fields(rec_ty:t) -> ~[field] {
match /*bad*/copy get(rec_ty).sty { match /*bad*/copy get(rec_ty).sty {
ty_rec(fields) => fields, ty_rec(fields) => fields,
// Can we check at the caller? // Can we check at the caller?
_ => fail ~"get_fields: not a record type" _ => die!(~"get_fields: not a record type")
} }
} }
@ -3929,10 +3929,10 @@ pub fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[VariantInfo] {
} }
} }
ast::struct_variant_kind(_) => { ast::struct_variant_kind(_) => {
fail ~"struct variant kinds unimpl in enum_variants" die!(~"struct variant kinds unimpl in enum_variants")
} }
ast::enum_variant_kind(_) => { ast::enum_variant_kind(_) => {
fail ~"enum variant kinds unimpl in enum_variants" die!(~"enum variant kinds unimpl in enum_variants")
} }
} }
}) })

View file

@ -2247,7 +2247,7 @@ pub fn check_expr_with_unifier(fcx: @fn_ctxt,
demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b)); demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b));
} }
// argh // argh
_ => fail ~"expr_fn_block" _ => die!(~"expr_fn_block")
} }
let block_ty = structurally_resolved_type( let block_ty = structurally_resolved_type(
fcx, expr.span, fcx.node_ty(b.id)); fcx, expr.span, fcx.node_ty(b.id));
@ -2287,7 +2287,7 @@ pub fn check_expr_with_unifier(fcx: @fn_ctxt,
demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b)); demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b));
} }
// argh // argh
_ => fail ~"expected fn ty" _ => die!(~"expected fn ty")
} }
fcx.write_ty(expr.id, fcx.node_ty(b.id)); fcx.write_ty(expr.id, fcx.node_ty(b.id));
} }

View file

@ -148,7 +148,7 @@ pub fn fixup_substs(vcx: &VtableContext, location_info: &LocationInfo,
do fixup_ty(vcx, location_info, t, is_early).map |t_f| { do fixup_ty(vcx, location_info, t, is_early).map |t_f| {
match ty::get(*t_f).sty { match ty::get(*t_f).sty {
ty::ty_trait(_, ref substs_f, _) => (/*bad*/copy *substs_f), ty::ty_trait(_, ref substs_f, _) => (/*bad*/copy *substs_f),
_ => fail ~"t_f should be a trait" _ => die!(~"t_f should be a trait")
} }
} }
} }

View file

@ -135,8 +135,8 @@ pub fn get_base_type_def_id(inference_context: @InferCtxt,
return Some(def_id); return Some(def_id);
} }
_ => { _ => {
fail ~"get_base_type() returned a type that wasn't an \ die!(~"get_base_type() returned a type that wasn't an \
enum, class, or trait"; enum, class, or trait");
} }
} }
} }

View file

@ -913,8 +913,8 @@ pub fn ty_of_item(ccx: @crate_ctxt, it: @ast::item)
return tpt; return tpt;
} }
ast::item_impl(*) | ast::item_mod(_) | ast::item_impl(*) | ast::item_mod(_) |
ast::item_foreign_mod(_) => fail, ast::item_foreign_mod(_) => die!(),
ast::item_mac(*) => fail ~"item macros unimplemented" ast::item_mac(*) => die!(~"item macros unimplemented")
} }
} }

View file

@ -102,7 +102,7 @@ impl Env {
return match search_mod(self, &self.crate.node.module, 0, names) { return match search_mod(self, &self.crate.node.module, 0, names) {
Some(id) => id, Some(id) => id,
None => { None => {
fail fmt!("No item found: `%s`", str::connect(names, "::")); die!(fmt!("No item found: `%s`", str::connect(names, "::")));
} }
}; };
@ -155,17 +155,17 @@ impl Env {
fn assert_subtype(&self, a: ty::t, b: ty::t) { fn assert_subtype(&self, a: ty::t, b: ty::t) {
if !self.is_subtype(a, b) { if !self.is_subtype(a, b) {
fail fmt!("%s is not a subtype of %s, but it should be", die!(fmt!("%s is not a subtype of %s, but it should be",
self.ty_to_str(a), self.ty_to_str(a),
self.ty_to_str(b)); self.ty_to_str(b)));
} }
} }
fn assert_not_subtype(&self, a: ty::t, b: ty::t) { fn assert_not_subtype(&self, a: ty::t, b: ty::t) {
if self.is_subtype(a, b) { if self.is_subtype(a, b) {
fail fmt!("%s is a subtype of %s, but it shouldn't be", die!(fmt!("%s is a subtype of %s, but it shouldn't be",
self.ty_to_str(a), self.ty_to_str(a),
self.ty_to_str(b)); self.ty_to_str(b)));
} }
} }
@ -240,7 +240,7 @@ impl Env {
fn check_lub(&self, t1: ty::t, t2: ty::t, t_lub: ty::t) { fn check_lub(&self, t1: ty::t, t2: ty::t, t_lub: ty::t) {
match self.lub().tys(t1, t2) { match self.lub().tys(t1, t2) {
Err(e) => { Err(e) => {
fail fmt!("Unexpected error computing LUB: %?", e) die!(fmt!("Unexpected error computing LUB: %?", e))
} }
Ok(t) => { Ok(t) => {
self.assert_eq(t, t_lub); self.assert_eq(t, t_lub);
@ -262,7 +262,7 @@ impl Env {
self.ty_to_str(t_glb)); self.ty_to_str(t_glb));
match self.glb().tys(t1, t2) { match self.glb().tys(t1, t2) {
Err(e) => { Err(e) => {
fail fmt!("Unexpected error computing LUB: %?", e) die!(fmt!("Unexpected error computing LUB: %?", e))
} }
Ok(t) => { Ok(t) => {
self.assert_eq(t, t_glb); self.assert_eq(t, t_glb);
@ -281,8 +281,8 @@ impl Env {
match self.lub().tys(t1, t2) { match self.lub().tys(t1, t2) {
Err(_) => {} Err(_) => {}
Ok(t) => { Ok(t) => {
fail fmt!("Unexpected success computing LUB: %?", die!(fmt!("Unexpected success computing LUB: %?",
self.ty_to_str(t)) self.ty_to_str(t)))
} }
} }
} }
@ -292,8 +292,8 @@ impl Env {
match self.glb().tys(t1, t2) { match self.glb().tys(t1, t2) {
Err(_) => {} Err(_) => {}
Ok(t) => { Ok(t) => {
fail fmt!("Unexpected success computing GLB: %?", die!(fmt!("Unexpected success computing GLB: %?",
self.ty_to_str(t)) self.ty_to_str(t)))
} }
} }
} }

View file

@ -368,7 +368,7 @@ pub fn monitor(+f: fn~(diagnostic::emitter)) {
} }
} }
// Fail so the process returns a failure code // Fail so the process returns a failure code
fail; die!();
} }
} }
} }

View file

@ -257,7 +257,7 @@ fn merge_method_attrs(
attr_parser::parse_desc(copy method.attrs)) attr_parser::parse_desc(copy method.attrs))
}) })
} }
_ => fail ~"unexpected item" _ => die!(~"unexpected item")
} }
}; };

View file

@ -71,7 +71,7 @@ fn take_my_order_please(
* This function is full of fail * This function is full of fail
*/ */
fail; die!();
} }
mod fortress_of_solitude { mod fortress_of_solitude {

View file

@ -322,7 +322,8 @@ fn structdoc_from_struct(
fields: do struct_def.fields.map |field| { fields: do struct_def.fields.map |field| {
match field.node.kind { match field.node.kind {
ast::named_field(ident, _, _) => to_str(ident), ast::named_field(ident, _, _) => to_str(ident),
ast::unnamed_field => fail ~"what is an unnamed struct field?" ast::unnamed_field => die!(
~"what is an unnamed struct field?")
} }
}, },
sig: None sig: None

View file

@ -543,7 +543,7 @@ fn write_sig(ctxt: &Ctxt, sig: Option<~str>) {
ctxt.w.write_line(code_block_indent(sig)); ctxt.w.write_line(code_block_indent(sig));
ctxt.w.write_line(~""); ctxt.w.write_line(~"");
} }
None => fail ~"unimplemented" None => die!(~"unimplemented")
} }
} }

View file

@ -145,7 +145,7 @@ fn pandoc_writer(
if status != 0 { if status != 0 {
error!("pandoc-out: %s", stdout); error!("pandoc-out: %s", stdout);
error!("pandoc-err: %s", stderr); error!("pandoc-err: %s", stderr);
fail ~"pandoc failed"; die!(~"pandoc failed");
} }
} }
} }
@ -293,7 +293,7 @@ fn write_file(path: &Path, s: ~str) {
result::Ok(writer) => { result::Ok(writer) => {
writer.write_str(s); writer.write_str(s);
} }
result::Err(e) => fail e result::Err(e) => die!(e)
} }
} }

View file

@ -79,7 +79,7 @@ fn get_fn_sig(srv: astsrv::Srv, fn_id: doc::AstId) -> Option<~str> {
Some(pprust::fun_to_str(*decl, ident, copy *tys, Some(pprust::fun_to_str(*decl, ident, copy *tys,
extract::interner())) extract::interner()))
} }
_ => fail ~"get_fn_sig: fn_id not bound to a fn item" _ => die!(~"get_fn_sig: fn_id not bound to a fn item")
} }
} }
} }
@ -228,7 +228,7 @@ fn get_method_sig(
} }
} }
} }
_ => fail ~"method not found" _ => die!(~"method not found")
} }
} }
ast_map::node_item(@ast::item { ast_map::node_item(@ast::item {
@ -245,10 +245,10 @@ fn get_method_sig(
extract::interner() extract::interner()
)) ))
} }
None => fail ~"method not found" None => die!(~"method not found")
} }
} }
_ => fail ~"get_method_sig: item ID not bound to trait or impl" _ => die!(~"get_method_sig: item ID not bound to trait or impl")
} }
} }
} }
@ -314,7 +314,7 @@ fn should_add_impl_self_ty() {
#[test] #[test]
fn should_add_impl_method_sigs() { fn should_add_impl_method_sigs() {
let doc = test::mk_doc(~"impl int { fn a<T>() -> int { fail } }"); let doc = test::mk_doc(~"impl int { fn a<T>() -> int { die!() } }");
assert doc.cratemod().impls()[0].methods[0].sig assert doc.cratemod().impls()[0].methods[0].sig
== Some(~"fn a<T>() -> int"); == Some(~"fn a<T>() -> int");
} }
@ -395,7 +395,7 @@ fn strip_struct_extra_stuff(item: @ast::item) -> @ast::item {
}; };
ast::item_struct(def, tys) ast::item_struct(def, tys)
} }
_ => fail ~"not a struct" _ => die!(~"not a struct")
}; };
@ast::item { @ast::item {

View file

@ -178,10 +178,10 @@ fn run(repl: Repl, input: ~str) -> Repl {
ast::expr_call(_, exprs, _) => { ast::expr_call(_, exprs, _) => {
match exprs[0].node { match exprs[0].node {
ast::expr_block(blk) => @blk, ast::expr_block(blk) => @blk,
_ => fail _ => die!()
} }
} }
_ => fail _ => die!()
}; };
debug!("recording input into repl history"); debug!("recording input into repl history");
record(repl, blk, sess.parse_sess.interner) record(repl, blk, sess.parse_sess.interner)
@ -320,7 +320,7 @@ fn run_cmd(repl: &mut Repl, _in: io::Reader, _out: io::Writer,
let mut end_multiline = false; let mut end_multiline = false;
while (!end_multiline) { while (!end_multiline) {
match get_line(~"rusti| ") { match get_line(~"rusti| ") {
None => fail ~"unterminated multiline command :{ .. :}", None => die!(~"unterminated multiline command :{ .. :}"),
Some(line) => { Some(line) => {
if str::trim(line) == ~":}" { if str::trim(line) == ~":}" {
end_multiline = true; end_multiline = true;

View file

@ -221,7 +221,7 @@ pub fn unwrap_mutex_arc<T: Owned>(arc: MutexARC<T>) -> T {
let inner = unsafe { unwrap_shared_mutable_state(move x) }; let inner = unsafe { unwrap_shared_mutable_state(move x) };
let MutexARCInner { failed: failed, data: data, _ } = move inner; let MutexARCInner { failed: failed, data: data, _ } = move inner;
if failed { if failed {
fail ~"Can't unwrap poisoned MutexARC - another task failed inside!" die!(~"Can't unwrap poisoned MutexARC - another task failed inside!")
} }
move data move data
} }
@ -232,9 +232,9 @@ pub fn unwrap_mutex_arc<T: Owned>(arc: MutexARC<T>) -> T {
fn check_poison(is_mutex: bool, failed: bool) { fn check_poison(is_mutex: bool, failed: bool) {
if failed { if failed {
if is_mutex { if is_mutex {
fail ~"Poisoned MutexARC - another task failed inside!"; die!(~"Poisoned MutexARC - another task failed inside!");
} else { } else {
fail ~"Poisoned rw_arc - another task failed inside!"; die!(~"Poisoned rw_arc - another task failed inside!");
} }
} }
} }
@ -410,7 +410,7 @@ pub fn unwrap_rw_arc<T: Const Owned>(arc: RWARC<T>) -> T {
let inner = unsafe { unwrap_shared_mutable_state(move x) }; let inner = unsafe { unwrap_shared_mutable_state(move x) };
let RWARCInner { failed: failed, data: data, _ } = move inner; let RWARCInner { failed: failed, data: data, _ } = move inner;
if failed { if failed {
fail ~"Can't unwrap poisoned RWARC - another task failed inside!" die!(~"Can't unwrap poisoned RWARC - another task failed inside!")
} }
move data move data
} }

View file

@ -305,6 +305,6 @@ fn test_arena_destructors_fail() {
// get freed too. // get freed too.
do arena.alloc { @20 }; do arena.alloc { @20 };
// Now fail. // Now fail.
fail; die!();
}; };
} }

View file

@ -65,7 +65,7 @@ impl &[u8]: ToBase64 {
str::push_char(&mut s, chars[(n >> 6u) & 63u]); str::push_char(&mut s, chars[(n >> 6u) & 63u]);
str::push_char(&mut s, '='); str::push_char(&mut s, '=');
} }
_ => fail ~"Algebra is broken, please alert the math police" _ => die!(~"Algebra is broken, please alert the math police")
} }
} }
s s
@ -84,7 +84,7 @@ pub trait FromBase64 {
impl ~[u8]: FromBase64 { impl ~[u8]: FromBase64 {
pure fn from_base64() -> ~[u8] { pure fn from_base64() -> ~[u8] {
if self.len() % 4u != 0u { fail ~"invalid base64 length"; } if self.len() % 4u != 0u { die!(~"invalid base64 length"); }
let len = self.len(); let len = self.len();
let mut padding = 0u; let mut padding = 0u;
@ -126,10 +126,10 @@ impl ~[u8]: FromBase64 {
r.push(((n >> 10u) & 0xFFu) as u8); r.push(((n >> 10u) & 0xFFu) as u8);
return copy r; return copy r;
} }
_ => fail ~"invalid base64 padding" _ => die!(~"invalid base64 padding")
} }
} else { } else {
fail ~"invalid base64 character"; die!(~"invalid base64 character");
} }
i += 1u; i += 1u;

View file

@ -332,7 +332,7 @@ pub impl BigUint {
} }
pure fn divmod(&self, other: &BigUint) -> (BigUint, BigUint) { pure fn divmod(&self, other: &BigUint) -> (BigUint, BigUint) {
if other.is_zero() { fail } if other.is_zero() { die!() }
if self.is_zero() { return (Zero::zero(), Zero::zero()); } if self.is_zero() { return (Zero::zero(), Zero::zero()); }
if *other == One::one() { return (copy *self, Zero::zero()); } if *other == One::one() { return (copy *self, Zero::zero()); }
@ -523,7 +523,7 @@ priv pure fn get_radix_base(radix: uint) -> (uint, uint) {
14 => (1475789056, 8), 14 => (1475789056, 8),
15 => (2562890625, 8), 15 => (2562890625, 8),
16 => (4294967296, 8), 16 => (4294967296, 8),
_ => fail _ => die!()
} }
} }
@ -547,7 +547,7 @@ priv pure fn get_radix_base(radix: uint) -> (uint, uint) {
14 => (38416, 4), 14 => (38416, 4),
15 => (50625, 4), 15 => (50625, 4),
16 => (65536, 4), 16 => (65536, 4),
_ => fail _ => die!()
} }
} }
@ -797,7 +797,7 @@ pub impl BigInt {
let d = BigInt::from_biguint(Plus, d_ui), let d = BigInt::from_biguint(Plus, d_ui),
m = BigInt::from_biguint(Plus, m_ui); m = BigInt::from_biguint(Plus, m_ui);
match (self.sign, other.sign) { match (self.sign, other.sign) {
(_, Zero) => fail, (_, Zero) => die!(),
(Plus, Plus) | (Zero, Plus) => (d, m), (Plus, Plus) | (Zero, Plus) => (d, m),
(Plus, Minus) | (Zero, Minus) => if m.is_zero() { (Plus, Minus) | (Zero, Minus) => if m.is_zero() {
(-d, Zero::zero()) (-d, Zero::zero())
@ -828,7 +828,7 @@ pub impl BigInt {
let q = BigInt::from_biguint(Plus, q_ui); let q = BigInt::from_biguint(Plus, q_ui);
let r = BigInt::from_biguint(Plus, r_ui); let r = BigInt::from_biguint(Plus, r_ui);
match (self.sign, other.sign) { match (self.sign, other.sign) {
(_, Zero) => fail, (_, Zero) => die!(),
(Plus, Plus) | (Zero, Plus) => ( q, r), (Plus, Plus) | (Zero, Plus) => ( q, r),
(Plus, Minus) | (Zero, Minus) => (-q, r), (Plus, Minus) | (Zero, Minus) => (-q, r),
(Minus, Plus) => (-q, -r), (Minus, Plus) => (-q, -r),
@ -1193,7 +1193,7 @@ mod biguint_tests {
~"2" + ~"2" +
str::from_chars(vec::from_elem(bits / 2 - 1, '0')) + "1"), str::from_chars(vec::from_elem(bits / 2 - 1, '0')) + "1"),
(10, match bits { (10, match bits {
32 => ~"8589934593", 16 => ~"131073", _ => fail 32 => ~"8589934593", 16 => ~"131073", _ => die!()
}), }),
(16, (16,
~"2" + ~"2" +
@ -1210,7 +1210,7 @@ mod biguint_tests {
(10, match bits { (10, match bits {
32 => ~"55340232229718589441", 32 => ~"55340232229718589441",
16 => ~"12885032961", 16 => ~"12885032961",
_ => fail _ => die!()
}), }),
(16, ~"3" + (16, ~"3" +
str::from_chars(vec::from_elem(bits / 4 - 1, '0')) + "2" + str::from_chars(vec::from_elem(bits / 4 - 1, '0')) + "2" +
@ -1257,7 +1257,7 @@ mod biguint_tests {
fn check(n: uint, s: &str) { fn check(n: uint, s: &str) {
let n = factor(n); let n = factor(n);
let ans = match BigUint::from_str_radix(s, 10) { let ans = match BigUint::from_str_radix(s, 10) {
Some(x) => x, None => fail Some(x) => x, None => die!()
}; };
assert n == ans; assert n == ans;
} }

View file

@ -242,7 +242,7 @@ pub fn Bitv (nbits: uint, init: bool) -> Bitv {
priv impl Bitv { priv impl Bitv {
fn die() -> ! { fn die() -> ! {
fail ~"Tried to do operation on bit vectors with different sizes"; die!(~"Tried to do operation on bit vectors with different sizes");
} }
#[inline(always)] #[inline(always)]

View file

@ -34,7 +34,7 @@ impl<T> Cell<T> {
/// Yields the value, failing if the cell is empty. /// Yields the value, failing if the cell is empty.
fn take() -> T { fn take() -> T {
if self.is_empty() { if self.is_empty() {
fail ~"attempt to take an empty cell"; die!(~"attempt to take an empty cell");
} }
let mut value = None; let mut value = None;
@ -45,7 +45,7 @@ impl<T> Cell<T> {
/// Returns the value, failing if the cell is full. /// Returns the value, failing if the cell is full.
fn put_back(value: T) { fn put_back(value: T) {
if !self.is_empty() { if !self.is_empty() {
fail ~"attempt to put a value back into a full cell"; die!(~"attempt to put a value back into a full cell");
} }
self.value = Some(move value); self.value = Some(move value);
} }

View file

@ -58,7 +58,7 @@ pub fn create<T: Copy>() -> Deque<T> {
move rv move rv
} }
fn get<T: Copy>(elts: &DVec<Cell<T>>, i: uint) -> T { fn get<T: Copy>(elts: &DVec<Cell<T>>, i: uint) -> T {
match (*elts).get_elt(i) { Some(move t) => t, _ => fail } match (*elts).get_elt(i) { Some(move t) => t, _ => die!() }
} }
struct Repr<T> { struct Repr<T> {

View file

@ -104,7 +104,7 @@ pub mod reader {
(data[start + 2u] as uint) << 8u | (data[start + 2u] as uint) << 8u |
(data[start + 3u] as uint), (data[start + 3u] as uint),
next: start + 4u}; next: start + 4u};
} else { error!("vint too big"); fail; } } else { error!("vint too big"); die!(); }
} }
pub fn Doc(data: @~[u8]) -> Doc { pub fn Doc(data: @~[u8]) -> Doc {
@ -140,7 +140,7 @@ pub mod reader {
Some(d) => d, Some(d) => d,
None => { None => {
error!("failed to find block with tag %u", tg); error!("failed to find block with tag %u", tg);
fail; die!();
} }
} }
} }
@ -227,7 +227,8 @@ pub mod reader {
self.pos = r_doc.end; self.pos = r_doc.end;
let str = doc_as_str(r_doc); let str = doc_as_str(r_doc);
if lbl != str { if lbl != str {
fail fmt!("Expected label %s but found %s", lbl, str); die!(fmt!("Expected label %s but found %s", lbl,
str));
} }
} }
} }
@ -236,7 +237,7 @@ pub mod reader {
fn next_doc(exp_tag: EbmlEncoderTag) -> Doc { fn next_doc(exp_tag: EbmlEncoderTag) -> Doc {
debug!(". next_doc(exp_tag=%?)", exp_tag); debug!(". next_doc(exp_tag=%?)", exp_tag);
if self.pos >= self.parent.end { if self.pos >= self.parent.end {
fail ~"no more documents in current node!"; die!(~"no more documents in current node!");
} }
let TaggedDoc { tag: r_tag, doc: r_doc } = let TaggedDoc { tag: r_tag, doc: r_doc } =
doc_at(self.parent.data, self.pos); doc_at(self.parent.data, self.pos);
@ -244,12 +245,12 @@ pub mod reader {
copy self.parent.start, copy self.parent.end, copy self.parent.start, copy self.parent.end,
copy self.pos, r_tag, r_doc.start, r_doc.end); copy self.pos, r_tag, r_doc.start, r_doc.end);
if r_tag != (exp_tag as uint) { if r_tag != (exp_tag as uint) {
fail fmt!("expected EBML doc with tag %? but found tag %?", die!(fmt!("expected EBML doc with tag %? but found tag %?",
exp_tag, r_tag); exp_tag, r_tag));
} }
if r_doc.end > self.parent.end { if r_doc.end > self.parent.end {
fail fmt!("invalid EBML, child extends to 0x%x, \ die!(fmt!("invalid EBML, child extends to 0x%x, \
parent to 0x%x", r_doc.end, self.parent.end); parent to 0x%x", r_doc.end, self.parent.end));
} }
self.pos = r_doc.end; self.pos = r_doc.end;
r_doc r_doc
@ -291,7 +292,7 @@ pub mod reader {
fn read_uint(&self) -> uint { fn read_uint(&self) -> uint {
let v = doc_as_u64(self.next_doc(EsUint)); let v = doc_as_u64(self.next_doc(EsUint));
if v > (::core::uint::max_value as u64) { if v > (::core::uint::max_value as u64) {
fail fmt!("uint %? too large for this architecture", v); die!(fmt!("uint %? too large for this architecture", v));
} }
v as uint v as uint
} }
@ -303,7 +304,7 @@ pub mod reader {
fn read_int(&self) -> int { fn read_int(&self) -> int {
let v = doc_as_u64(self.next_doc(EsInt)) as i64; let v = doc_as_u64(self.next_doc(EsInt)) as i64;
if v > (int::max_value as i64) || v < (int::min_value as i64) { if v > (int::max_value as i64) || v < (int::min_value as i64) {
fail fmt!("int %? out of range for this architecture", v); die!(fmt!("int %? out of range for this architecture", v));
} }
v as int v as int
} }
@ -311,14 +312,14 @@ pub mod reader {
fn read_bool(&self) -> bool { doc_as_u8(self.next_doc(EsBool)) fn read_bool(&self) -> bool { doc_as_u8(self.next_doc(EsBool))
as bool } as bool }
fn read_f64(&self) -> f64 { fail ~"read_f64()"; } fn read_f64(&self) -> f64 { die!(~"read_f64()"); }
fn read_f32(&self) -> f32 { fail ~"read_f32()"; } fn read_f32(&self) -> f32 { die!(~"read_f32()"); }
fn read_float(&self) -> float { fail ~"read_float()"; } fn read_float(&self) -> float { die!(~"read_float()"); }
fn read_char(&self) -> char { fail ~"read_char()"; } fn read_char(&self) -> char { die!(~"read_char()"); }
fn read_owned_str(&self) -> ~str { doc_as_str(self.next_doc(EsStr)) } fn read_owned_str(&self) -> ~str { doc_as_str(self.next_doc(EsStr)) }
fn read_managed_str(&self) -> @str { fail ~"read_managed_str()"; } fn read_managed_str(&self) -> @str { die!(~"read_managed_str()"); }
// Compound types: // Compound types:
fn read_owned<T>(&self, f: fn() -> T) -> T { fn read_owned<T>(&self, f: fn() -> T) -> T {
@ -427,7 +428,7 @@ pub mod writer {
n as u8]), n as u8]),
4u => w.write(&[0x10u8 | ((n >> 24_u) as u8), (n >> 16_u) as u8, 4u => w.write(&[0x10u8 | ((n >> 24_u) as u8), (n >> 16_u) as u8,
(n >> 8_u) as u8, n as u8]), (n >> 8_u) as u8, n as u8]),
_ => fail fmt!("vint to write too big: %?", n) _ => die!(fmt!("vint to write too big: %?", n))
}; };
} }
@ -436,7 +437,7 @@ pub mod writer {
if n < 0x4000_u { write_sized_vuint(w, n, 2u); return; } if n < 0x4000_u { write_sized_vuint(w, n, 2u); return; }
if n < 0x200000_u { write_sized_vuint(w, n, 3u); return; } if n < 0x200000_u { write_sized_vuint(w, n, 3u); return; }
if n < 0x10000000_u { write_sized_vuint(w, n, 4u); return; } if n < 0x10000000_u { write_sized_vuint(w, n, 4u); return; }
fail fmt!("vint to write too big: %?", n); die!(fmt!("vint to write too big: %?", n));
} }
pub fn Encoder(w: io::Writer) -> Encoder { pub fn Encoder(w: io::Writer) -> Encoder {
@ -598,17 +599,17 @@ pub mod writer {
// FIXME (#2742): implement these // FIXME (#2742): implement these
fn emit_f64(&self, _v: f64) { fn emit_f64(&self, _v: f64) {
fail ~"Unimplemented: serializing an f64"; die!(~"Unimplemented: serializing an f64");
} }
fn emit_f32(&self, _v: f32) { fn emit_f32(&self, _v: f32) {
fail ~"Unimplemented: serializing an f32"; die!(~"Unimplemented: serializing an f32");
} }
fn emit_float(&self, _v: float) { fn emit_float(&self, _v: float) {
fail ~"Unimplemented: serializing a float"; die!(~"Unimplemented: serializing a float");
} }
fn emit_char(&self, _v: char) { fn emit_char(&self, _v: char) {
fail ~"Unimplemented: serializing a char"; die!(~"Unimplemented: serializing a char");
} }
fn emit_borrowed_str(&self, v: &str) { fn emit_borrowed_str(&self, v: &str) {

View file

@ -262,7 +262,7 @@ pub impl<T,U:Unflattener<T>,P:BytePort> FlatPort<T, U, P>: GenericPort<T> {
fn recv() -> T { fn recv() -> T {
match self.try_recv() { match self.try_recv() {
Some(move val) => move val, Some(move val) => move val,
None => fail ~"port is closed" None => die!(~"port is closed")
} }
} }
fn try_recv() -> Option<T> { fn try_recv() -> Option<T> {
@ -298,7 +298,7 @@ pub impl<T,U:Unflattener<T>,P:BytePort> FlatPort<T, U, P>: GenericPort<T> {
} }
} }
else { else {
fail ~"flatpipe: unrecognized command"; die!(~"flatpipe: unrecognized command");
} }
} }
} }
@ -480,7 +480,7 @@ pub mod flatteners {
Ok(move json) => { Ok(move json) => {
json::Decoder(move json) json::Decoder(move json)
} }
Err(e) => fail fmt!("flatpipe: can't parse json: %?", e) Err(e) => die!(fmt!("flatpipe: can't parse json: %?", e))
} }
} }
} }

View file

@ -65,14 +65,14 @@ impl<A> Future<A> {
unsafe { unsafe {
match self.state { match self.state {
Forced(ref mut v) => { return cast::transmute(v); } Forced(ref mut v) => { return cast::transmute(v); }
Evaluating => fail ~"Recursive forcing of future!", Evaluating => die!(~"Recursive forcing of future!"),
Pending(_) => {} Pending(_) => {}
} }
let mut state = Evaluating; let mut state = Evaluating;
self.state <-> state; self.state <-> state;
match move state { match move state {
Forced(_) | Evaluating => fail ~"Logic error.", Forced(_) | Evaluating => die!(~"Logic error."),
Pending(move f) => { Pending(move f) => {
self.state = Forced(move f()); self.state = Forced(move f());
self.get_ref() self.get_ref()
@ -195,7 +195,7 @@ pub mod test {
#[should_fail] #[should_fail]
#[ignore(cfg(target_os = "win32"))] #[ignore(cfg(target_os = "win32"))]
pub fn test_futurefail() { pub fn test_futurefail() {
let f = spawn(|| fail); let f = spawn(|| die!());
let _x: ~str = f.get(); let _x: ~str = f.get();
} }

View file

@ -56,7 +56,7 @@
* ]; * ];
* let matches = match getopts(vec::tail(args), opts) { * let matches = match getopts(vec::tail(args), opts) {
* result::ok(m) { m } * result::ok(m) { m }
* result::err(f) { fail fail_str(f) } * result::err(f) { die!(fail_str(f)) }
* }; * };
* if opt_present(matches, "h") || opt_present(matches, "help") { * if opt_present(matches, "h") || opt_present(matches, "help") {
* print_usage(program); * print_usage(program);
@ -348,7 +348,7 @@ fn opt_vals(mm: &Matches, nm: &str) -> ~[Optval] {
Some(id) => mm.vals[id], Some(id) => mm.vals[id],
None => { None => {
error!("No option '%s' defined", nm); error!("No option '%s' defined", nm);
fail die!()
} }
}; };
} }
@ -384,7 +384,7 @@ pub fn opts_present(mm: &Matches, names: &[~str]) -> bool {
* argument * argument
*/ */
pub fn opt_str(mm: &Matches, nm: &str) -> ~str { pub fn opt_str(mm: &Matches, nm: &str) -> ~str {
return match opt_val(mm, nm) { Val(copy s) => s, _ => fail }; return match opt_val(mm, nm) { Val(copy s) => s, _ => die!() };
} }
/** /**
@ -400,7 +400,7 @@ pub fn opts_str(mm: &Matches, names: &[~str]) -> ~str {
_ => () _ => ()
} }
} }
fail; die!();
} }
@ -550,7 +550,7 @@ pub mod groups {
match ((*lopt).short_name.len(), match ((*lopt).short_name.len(),
(*lopt).long_name.len()) { (*lopt).long_name.len()) {
(0,0) => fail ~"this long-format option was given no name", (0,0) => die!(~"this long-format option was given no name"),
(0,_) => ~[Opt {name: Long(((*lopt).long_name)), (0,_) => ~[Opt {name: Long(((*lopt).long_name)),
hasarg: (*lopt).hasarg, hasarg: (*lopt).hasarg,
@ -567,7 +567,7 @@ pub mod groups {
hasarg: (*lopt).hasarg, hasarg: (*lopt).hasarg,
occur: (*lopt).occur}], occur: (*lopt).occur}],
(_,_) => fail ~"something is wrong with the long-form opt" (_,_) => die!(~"something is wrong with the long-form opt")
} }
} }
@ -598,7 +598,7 @@ pub mod groups {
row += match short_name.len() { row += match short_name.len() {
0 => ~"", 0 => ~"",
1 => ~"-" + short_name + " ", 1 => ~"-" + short_name + " ",
_ => fail ~"the short name should only be 1 char long", _ => die!(~"the short name should only be 1 char long"),
}; };
// long option // long option
@ -668,7 +668,7 @@ mod tests {
assert (opt_present(m, ~"test")); assert (opt_present(m, ~"test"));
assert (opt_str(m, ~"test") == ~"20"); assert (opt_str(m, ~"test") == ~"20");
} }
_ => { fail ~"test_reqopt_long failed"; } _ => { die!(~"test_reqopt_long failed"); }
} }
} }
@ -679,7 +679,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Err(copy f) => check_fail_type(f, OptionMissing_), Err(copy f) => check_fail_type(f, OptionMissing_),
_ => fail _ => die!()
} }
} }
@ -690,7 +690,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Err(copy f) => check_fail_type(f, ArgumentMissing_), Err(copy f) => check_fail_type(f, ArgumentMissing_),
_ => fail _ => die!()
} }
} }
@ -701,7 +701,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Err(copy f) => check_fail_type(f, OptionDuplicated_), Err(copy f) => check_fail_type(f, OptionDuplicated_),
_ => fail _ => die!()
} }
} }
@ -715,7 +715,7 @@ mod tests {
assert (opt_present(m, ~"t")); assert (opt_present(m, ~"t"));
assert (opt_str(m, ~"t") == ~"20"); assert (opt_str(m, ~"t") == ~"20");
} }
_ => fail _ => die!()
} }
} }
@ -726,7 +726,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Err(copy f) => check_fail_type(f, OptionMissing_), Err(copy f) => check_fail_type(f, OptionMissing_),
_ => fail _ => die!()
} }
} }
@ -737,7 +737,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Err(copy f) => check_fail_type(f, ArgumentMissing_), Err(copy f) => check_fail_type(f, ArgumentMissing_),
_ => fail _ => die!()
} }
} }
@ -748,7 +748,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Err(copy f) => check_fail_type(f, OptionDuplicated_), Err(copy f) => check_fail_type(f, OptionDuplicated_),
_ => fail _ => die!()
} }
} }
@ -764,7 +764,7 @@ mod tests {
assert (opt_present(m, ~"test")); assert (opt_present(m, ~"test"));
assert (opt_str(m, ~"test") == ~"20"); assert (opt_str(m, ~"test") == ~"20");
} }
_ => fail _ => die!()
} }
} }
@ -775,7 +775,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Ok(ref m) => assert (!opt_present(m, ~"test")), Ok(ref m) => assert (!opt_present(m, ~"test")),
_ => fail _ => die!()
} }
} }
@ -786,7 +786,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Err(copy f) => check_fail_type(f, ArgumentMissing_), Err(copy f) => check_fail_type(f, ArgumentMissing_),
_ => fail _ => die!()
} }
} }
@ -797,7 +797,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Err(copy f) => check_fail_type(f, OptionDuplicated_), Err(copy f) => check_fail_type(f, OptionDuplicated_),
_ => fail _ => die!()
} }
} }
@ -811,7 +811,7 @@ mod tests {
assert (opt_present(m, ~"t")); assert (opt_present(m, ~"t"));
assert (opt_str(m, ~"t") == ~"20"); assert (opt_str(m, ~"t") == ~"20");
} }
_ => fail _ => die!()
} }
} }
@ -822,7 +822,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Ok(ref m) => assert (!opt_present(m, ~"t")), Ok(ref m) => assert (!opt_present(m, ~"t")),
_ => fail _ => die!()
} }
} }
@ -833,7 +833,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Err(copy f) => check_fail_type(f, ArgumentMissing_), Err(copy f) => check_fail_type(f, ArgumentMissing_),
_ => fail _ => die!()
} }
} }
@ -844,7 +844,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Err(copy f) => check_fail_type(f, OptionDuplicated_), Err(copy f) => check_fail_type(f, OptionDuplicated_),
_ => fail _ => die!()
} }
} }
@ -857,7 +857,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Ok(ref m) => assert (opt_present(m, ~"test")), Ok(ref m) => assert (opt_present(m, ~"test")),
_ => fail _ => die!()
} }
} }
@ -868,7 +868,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Ok(ref m) => assert (!opt_present(m, ~"test")), Ok(ref m) => assert (!opt_present(m, ~"test")),
_ => fail _ => die!()
} }
} }
@ -882,7 +882,7 @@ mod tests {
log(error, fail_str(f)); log(error, fail_str(f));
check_fail_type(f, UnexpectedArgument_); check_fail_type(f, UnexpectedArgument_);
} }
_ => fail _ => die!()
} }
} }
@ -893,7 +893,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Err(copy f) => check_fail_type(f, OptionDuplicated_), Err(copy f) => check_fail_type(f, OptionDuplicated_),
_ => fail _ => die!()
} }
} }
@ -904,7 +904,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Ok(ref m) => assert (opt_present(m, ~"t")), Ok(ref m) => assert (opt_present(m, ~"t")),
_ => fail _ => die!()
} }
} }
@ -915,7 +915,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Ok(ref m) => assert (!opt_present(m, ~"t")), Ok(ref m) => assert (!opt_present(m, ~"t")),
_ => fail _ => die!()
} }
} }
@ -930,7 +930,7 @@ mod tests {
assert (m.free[0] == ~"20"); assert (m.free[0] == ~"20");
} }
_ => fail _ => die!()
} }
} }
@ -941,7 +941,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Err(copy f) => check_fail_type(f, OptionDuplicated_), Err(copy f) => check_fail_type(f, OptionDuplicated_),
_ => fail _ => die!()
} }
} }
@ -955,7 +955,7 @@ mod tests {
Ok(ref m) => { Ok(ref m) => {
assert (opt_count(m, ~"v") == 1); assert (opt_count(m, ~"v") == 1);
} }
_ => fail _ => die!()
} }
} }
@ -968,7 +968,7 @@ mod tests {
Ok(ref m) => { Ok(ref m) => {
assert (opt_count(m, ~"v") == 2); assert (opt_count(m, ~"v") == 2);
} }
_ => fail _ => die!()
} }
} }
@ -981,7 +981,7 @@ mod tests {
Ok(ref m) => { Ok(ref m) => {
assert (opt_count(m, ~"v") == 2); assert (opt_count(m, ~"v") == 2);
} }
_ => fail _ => die!()
} }
} }
@ -994,7 +994,7 @@ mod tests {
Ok(ref m) => { Ok(ref m) => {
assert (opt_count(m, ~"verbose") == 1); assert (opt_count(m, ~"verbose") == 1);
} }
_ => fail _ => die!()
} }
} }
@ -1007,7 +1007,7 @@ mod tests {
Ok(ref m) => { Ok(ref m) => {
assert (opt_count(m, ~"verbose") == 2); assert (opt_count(m, ~"verbose") == 2);
} }
_ => fail _ => die!()
} }
} }
@ -1022,7 +1022,7 @@ mod tests {
assert (opt_present(m, ~"test")); assert (opt_present(m, ~"test"));
assert (opt_str(m, ~"test") == ~"20"); assert (opt_str(m, ~"test") == ~"20");
} }
_ => fail _ => die!()
} }
} }
@ -1033,7 +1033,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Ok(ref m) => assert (!opt_present(m, ~"test")), Ok(ref m) => assert (!opt_present(m, ~"test")),
_ => fail _ => die!()
} }
} }
@ -1044,7 +1044,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Err(copy f) => check_fail_type(f, ArgumentMissing_), Err(copy f) => check_fail_type(f, ArgumentMissing_),
_ => fail _ => die!()
} }
} }
@ -1061,7 +1061,7 @@ mod tests {
assert (pair[0] == ~"20"); assert (pair[0] == ~"20");
assert (pair[1] == ~"30"); assert (pair[1] == ~"30");
} }
_ => fail _ => die!()
} }
} }
@ -1075,7 +1075,7 @@ mod tests {
assert (opt_present(m, ~"t")); assert (opt_present(m, ~"t"));
assert (opt_str(m, ~"t") == ~"20"); assert (opt_str(m, ~"t") == ~"20");
} }
_ => fail _ => die!()
} }
} }
@ -1086,7 +1086,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Ok(ref m) => assert (!opt_present(m, ~"t")), Ok(ref m) => assert (!opt_present(m, ~"t")),
_ => fail _ => die!()
} }
} }
@ -1097,7 +1097,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Err(copy f) => check_fail_type(f, ArgumentMissing_), Err(copy f) => check_fail_type(f, ArgumentMissing_),
_ => fail _ => die!()
} }
} }
@ -1114,7 +1114,7 @@ mod tests {
assert (pair[0] == ~"20"); assert (pair[0] == ~"20");
assert (pair[1] == ~"30"); assert (pair[1] == ~"30");
} }
_ => fail _ => die!()
} }
} }
@ -1125,7 +1125,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Err(copy f) => check_fail_type(f, UnrecognizedOption_), Err(copy f) => check_fail_type(f, UnrecognizedOption_),
_ => fail _ => die!()
} }
} }
@ -1136,7 +1136,7 @@ mod tests {
let rs = getopts(args, opts); let rs = getopts(args, opts);
match rs { match rs {
Err(copy f) => check_fail_type(f, UnrecognizedOption_), Err(copy f) => check_fail_type(f, UnrecognizedOption_),
_ => fail _ => die!()
} }
} }
@ -1168,7 +1168,7 @@ mod tests {
assert (pair[1] == ~"-60 70"); assert (pair[1] == ~"-60 70");
assert (!opt_present(m, ~"notpresent")); assert (!opt_present(m, ~"notpresent"));
} }
_ => fail _ => die!()
} }
} }
@ -1178,7 +1178,7 @@ mod tests {
let opts = ~[optopt(~"e"), optopt(~"encrypt")]; let opts = ~[optopt(~"e"), optopt(~"encrypt")];
let matches = &match getopts(args, opts) { let matches = &match getopts(args, opts) {
result::Ok(move m) => m, result::Ok(move m) => m,
result::Err(_) => fail result::Err(_) => die!()
}; };
assert opts_present(matches, ~[~"e"]); assert opts_present(matches, ~[~"e"]);
assert opts_present(matches, ~[~"encrypt"]); assert opts_present(matches, ~[~"encrypt"]);
@ -1199,7 +1199,7 @@ mod tests {
let opts = ~[optmulti(~"L"), optmulti(~"M")]; let opts = ~[optmulti(~"L"), optmulti(~"M")];
let matches = &match getopts(args, opts) { let matches = &match getopts(args, opts) {
result::Ok(move m) => m, result::Ok(move m) => m,
result::Err(_) => fail result::Err(_) => die!()
}; };
assert opts_present(matches, ~[~"L"]); assert opts_present(matches, ~[~"L"]);
assert opts_str(matches, ~[~"L"]) == ~"foo"; assert opts_str(matches, ~[~"L"]) == ~"foo";

View file

@ -123,7 +123,7 @@ pub impl Encoder: serialize::Encoder {
fn emit_managed(&self, f: fn()) { f() } fn emit_managed(&self, f: fn()) { f() }
fn emit_enum(&self, name: &str, f: fn()) { fn emit_enum(&self, name: &str, f: fn()) {
if name != "option" { fail ~"only supports option enum" } if name != "option" { die!(~"only supports option enum") }
f() f()
} }
fn emit_enum_variant(&self, _name: &str, id: uint, _cnt: uint, f: fn()) { fn emit_enum_variant(&self, _name: &str, id: uint, _cnt: uint, f: fn()) {
@ -227,7 +227,7 @@ pub impl PrettyEncoder: serialize::Encoder {
fn emit_managed(&self, f: fn()) { f() } fn emit_managed(&self, f: fn()) { f() }
fn emit_enum(&self, name: &str, f: fn()) { fn emit_enum(&self, name: &str, f: fn()) {
if name != "option" { fail ~"only supports option enum" } if name != "option" { die!(~"only supports option enum") }
f() f()
} }
fn emit_enum_variant(&self, _name: &str, id: uint, _cnt: uint, f: fn()) { fn emit_enum_variant(&self, _name: &str, id: uint, _cnt: uint, f: fn()) {
@ -743,7 +743,7 @@ pub impl Decoder: serialize::Decoder {
debug!("read_nil"); debug!("read_nil");
match *self.pop() { match *self.pop() {
Null => (), Null => (),
_ => fail ~"not a null" _ => die!(~"not a null")
} }
} }
@ -763,7 +763,7 @@ pub impl Decoder: serialize::Decoder {
debug!("read_bool"); debug!("read_bool");
match *self.pop() { match *self.pop() {
Boolean(b) => b, Boolean(b) => b,
_ => fail ~"not a boolean" _ => die!(~"not a boolean")
} }
} }
@ -773,13 +773,13 @@ pub impl Decoder: serialize::Decoder {
debug!("read_float"); debug!("read_float");
match *self.pop() { match *self.pop() {
Number(f) => f, Number(f) => f,
_ => fail ~"not a number" _ => die!(~"not a number")
} }
} }
fn read_char(&self) -> char { fn read_char(&self) -> char {
let v = str::chars(self.read_owned_str()); let v = str::chars(self.read_owned_str());
if v.len() != 1 { fail ~"string must have one character" } if v.len() != 1 { die!(~"string must have one character") }
v[0] v[0]
} }
@ -787,7 +787,7 @@ pub impl Decoder: serialize::Decoder {
debug!("read_owned_str"); debug!("read_owned_str");
match *self.pop() { match *self.pop() {
String(ref s) => copy *s, String(ref s) => copy *s,
_ => fail ~"not a string" _ => die!(~"not a string")
} }
} }
@ -795,7 +795,7 @@ pub impl Decoder: serialize::Decoder {
debug!("read_managed_str"); debug!("read_managed_str");
match *self.pop() { match *self.pop() {
String(ref s) => s.to_managed(), String(ref s) => s.to_managed(),
_ => fail ~"not a string" _ => die!(~"not a string")
} }
} }
@ -811,7 +811,7 @@ pub impl Decoder: serialize::Decoder {
fn read_enum<T>(&self, name: &str, f: fn() -> T) -> T { fn read_enum<T>(&self, name: &str, f: fn() -> T) -> T {
debug!("read_enum(%s)", name); debug!("read_enum(%s)", name);
if name != ~"option" { fail ~"only supports the option enum" } if name != ~"option" { die!(~"only supports the option enum") }
f() f()
} }
@ -826,7 +826,7 @@ pub impl Decoder: serialize::Decoder {
fn read_enum_variant_arg<T>(&self, idx: uint, f: fn() -> T) -> T { fn read_enum_variant_arg<T>(&self, idx: uint, f: fn() -> T) -> T {
debug!("read_enum_variant_arg(idx=%u)", idx); debug!("read_enum_variant_arg(idx=%u)", idx);
if idx != 0 { fail ~"unknown index" } if idx != 0 { die!(~"unknown index") }
f() f()
} }
@ -834,7 +834,7 @@ pub impl Decoder: serialize::Decoder {
debug!("read_owned_vec()"); debug!("read_owned_vec()");
let len = match *self.peek() { let len = match *self.peek() {
List(list) => list.len(), List(list) => list.len(),
_ => fail ~"not a list", _ => die!(~"not a list"),
}; };
let res = f(len); let res = f(len);
self.pop(); self.pop();
@ -845,7 +845,7 @@ pub impl Decoder: serialize::Decoder {
debug!("read_owned_vec()"); debug!("read_owned_vec()");
let len = match *self.peek() { let len = match *self.peek() {
List(ref list) => list.len(), List(ref list) => list.len(),
_ => fail ~"not a list", _ => die!(~"not a list"),
}; };
let res = f(len); let res = f(len);
self.pop(); self.pop();
@ -862,7 +862,7 @@ pub impl Decoder: serialize::Decoder {
self.stack.push(&list[idx]); self.stack.push(&list[idx]);
f() f()
} }
_ => fail ~"not a list", _ => die!(~"not a list"),
} }
} }
@ -889,20 +889,20 @@ pub impl Decoder: serialize::Decoder {
let obj: &self/~Object = obj; let obj: &self/~Object = obj;
match obj.find(&name.to_owned()) { match obj.find(&name.to_owned()) {
None => fail fmt!("no such field: %s", name), None => die!(fmt!("no such field: %s", name)),
Some(json) => { Some(json) => {
self.stack.push(json); self.stack.push(json);
f() f()
} }
} }
} }
Number(_) => fail ~"num", Number(_) => die!(~"num"),
String(_) => fail ~"str", String(_) => die!(~"str"),
Boolean(_) => fail ~"bool", Boolean(_) => die!(~"bool"),
List(_) => fail fmt!("list: %?", top), List(_) => die!(fmt!("list: %?", top)),
Null => fail ~"null", Null => die!(~"null"),
//_ => fail fmt!("not an object: %?", *top) //_ => die!(fmt!("not an object: %?", *top))
} }
} }
@ -922,7 +922,7 @@ pub impl Decoder: serialize::Decoder {
self.stack.push(&list[idx]); self.stack.push(&list[idx]);
f() f()
} }
_ => fail ~"not a list" _ => die!(~"not a list")
} }
} }
} }

View file

@ -94,7 +94,7 @@ pub pure fn len<T>(ls: @List<T>) -> uint {
pub pure fn tail<T: Copy>(ls: @List<T>) -> @List<T> { pub pure fn tail<T: Copy>(ls: @List<T>) -> @List<T> {
match *ls { match *ls {
Cons(_, tl) => return tl, Cons(_, tl) => return tl,
Nil => fail ~"list empty" Nil => die!(~"list empty")
} }
} }
@ -103,7 +103,7 @@ pub pure fn head<T: Copy>(ls: @List<T>) -> T {
match *ls { match *ls {
Cons(copy hd, _) => hd, Cons(copy hd, _) => hd,
// makes me sad // makes me sad
_ => fail ~"head invoked on empty list" _ => die!(~"head invoked on empty list")
} }
} }

View file

@ -366,7 +366,7 @@ pub mod chained {
pure fn get(k: K) -> V { pure fn get(k: K) -> V {
let opt_v = self.find(k); let opt_v = self.find(k);
if opt_v.is_none() { if opt_v.is_none() {
fail fmt!("Key not found in table: %?", k); die!(fmt!("Key not found in table: %?", k));
} }
option::unwrap(move opt_v) option::unwrap(move opt_v)
} }

View file

@ -64,14 +64,14 @@ pub fn format_addr(ip: &IpAddr) -> ~str {
Ipv4(ref addr) => unsafe { Ipv4(ref addr) => unsafe {
let result = uv_ip4_name(addr); let result = uv_ip4_name(addr);
if result == ~"" { if result == ~"" {
fail ~"failed to convert inner sockaddr_in address to str" die!(~"failed to convert inner sockaddr_in address to str")
} }
result result
}, },
Ipv6(ref addr) => unsafe { Ipv6(ref addr) => unsafe {
let result = uv_ip6_name(addr); let result = uv_ip6_name(addr);
if result == ~"" { if result == ~"" {
fail ~"failed to convert inner sockaddr_in address to str" die!(~"failed to convert inner sockaddr_in address to str")
} }
result result
} }
@ -183,7 +183,7 @@ pub mod v4 {
pub fn parse_addr(ip: &str) -> IpAddr { pub fn parse_addr(ip: &str) -> IpAddr {
match try_parse_addr(ip) { match try_parse_addr(ip) {
result::Ok(move addr) => move addr, result::Ok(move addr) => move addr,
result::Err(ref err_data) => fail err_data.err_msg result::Err(ref err_data) => die!(err_data.err_msg)
} }
} }
// the simple, old style numberic representation of // the simple, old style numberic representation of
@ -278,7 +278,7 @@ pub mod v6 {
pub fn parse_addr(ip: &str) -> IpAddr { pub fn parse_addr(ip: &str) -> IpAddr {
match try_parse_addr(ip) { match try_parse_addr(ip) {
result::Ok(move addr) => move addr, result::Ok(move addr) => move addr,
result::Err(copy err_data) => fail err_data.err_msg result::Err(copy err_data) => die!(err_data.err_msg)
} }
} }
pub fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> { pub fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> {
@ -400,7 +400,7 @@ mod test {
assert true; assert true;
} }
result::Ok(ref addr) => { result::Ok(ref addr) => {
fail fmt!("Expected failure, but got addr %?", addr); die!(fmt!("Expected failure, but got addr %?", addr));
} }
} }
} }
@ -413,7 +413,7 @@ mod test {
assert true; assert true;
} }
result::Ok(ref addr) => { result::Ok(ref addr) => {
fail fmt!("Expected failure, but got addr %?", addr); die!(fmt!("Expected failure, but got addr %?", addr));
} }
} }
} }
@ -424,7 +424,7 @@ mod test {
let iotask = &uv::global_loop::get(); let iotask = &uv::global_loop::get();
let ga_result = get_addr(localhost_name, iotask); let ga_result = get_addr(localhost_name, iotask);
if result::is_err(&ga_result) { if result::is_err(&ga_result) {
fail ~"got err result from net::ip::get_addr();" die!(~"got err result from net::ip::get_addr();")
} }
// note really sure how to realiably test/assert // note really sure how to realiably test/assert
// this.. mostly just wanting to see it work, atm. // this.. mostly just wanting to see it work, atm.

View file

@ -1644,7 +1644,7 @@ pub mod test {
hl_loop); hl_loop);
match actual_resp_result.get_err() { match actual_resp_result.get_err() {
ConnectionRefused => (), ConnectionRefused => (),
_ => fail ~"unknown error.. expected connection_refused" _ => die!(~"unknown error.. expected connection_refused")
} }
} }
pub fn impl_gl_tcp_ipv4_server_address_in_use() { pub fn impl_gl_tcp_ipv4_server_address_in_use() {
@ -1685,8 +1685,8 @@ pub mod test {
assert true; assert true;
} }
_ => { _ => {
fail ~"expected address_in_use listen error,"+ die!(~"expected address_in_use listen error,"+
~"but got a different error varient. check logs."; ~"but got a different error varient. check logs.");
} }
} }
} }
@ -1704,8 +1704,8 @@ pub mod test {
assert true; assert true;
} }
_ => { _ => {
fail ~"expected address_in_use listen error,"+ die!(~"expected address_in_use listen error,"+
~"but got a different error varient. check logs."; ~"but got a different error varient. check logs.");
} }
} }
} }
@ -1884,14 +1884,14 @@ pub mod test {
if result::is_err(&listen_result) { if result::is_err(&listen_result) {
match result::get_err(&listen_result) { match result::get_err(&listen_result) {
GenericListenErr(ref name, ref msg) => { GenericListenErr(ref name, ref msg) => {
fail fmt!("SERVER: exited abnormally name %s msg %s", die!(fmt!("SERVER: exited abnormally name %s msg %s",
*name, *msg); *name, *msg));
} }
AccessDenied => { AccessDenied => {
fail ~"SERVER: exited abnormally, got access denied.."; die!(~"SERVER: exited abnormally, got access denied..");
} }
AddressInUse => { AddressInUse => {
fail ~"SERVER: exited abnormally, got address in use..."; die!(~"SERVER: exited abnormally, got address in use...");
} }
} }
} }
@ -1910,15 +1910,15 @@ pub mod test {
debug!("establish_cb %?", kill_ch); debug!("establish_cb %?", kill_ch);
}, },
|new_conn, kill_ch| { |new_conn, kill_ch| {
fail fmt!("SERVER: shouldn't be called.. %? %?", die!(fmt!("SERVER: shouldn't be called.. %? %?",
new_conn, kill_ch); new_conn, kill_ch));
}); });
// err check on listen_result // err check on listen_result
if result::is_err(&listen_result) { if result::is_err(&listen_result) {
result::get_err(&listen_result) result::get_err(&listen_result)
} }
else { else {
fail ~"SERVER: did not fail as expected" die!(~"SERVER: did not fail as expected")
} }
} }
@ -1962,7 +1962,7 @@ pub mod test {
debug!("tcp_write_single err name: %s msg: %s", debug!("tcp_write_single err name: %s msg: %s",
err_data.err_name, err_data.err_msg); err_data.err_name, err_data.err_msg);
// meh. torn on what to do here. // meh. torn on what to do here.
fail ~"tcp_write_single failed"; die!(~"tcp_write_single failed");
} }
} }
} }

View file

@ -100,7 +100,7 @@ pub fn of_str(str: @~str) -> Rope {
*/ */
pub fn of_substr(str: @~str, byte_offset: uint, byte_len: uint) -> Rope { pub fn of_substr(str: @~str, byte_offset: uint, byte_len: uint) -> Rope {
if byte_len == 0u { return node::Empty; } if byte_len == 0u { return node::Empty; }
if byte_offset + byte_len > str::len(*str) { fail; } if byte_offset + byte_len > str::len(*str) { die!(); }
return node::Content(node::of_substr(str, byte_offset, byte_len)); return node::Content(node::of_substr(str, byte_offset, byte_len));
} }
@ -246,9 +246,9 @@ Section: Transforming ropes
pub fn sub_chars(rope: Rope, char_offset: uint, char_len: uint) -> Rope { pub fn sub_chars(rope: Rope, char_offset: uint, char_len: uint) -> Rope {
if char_len == 0u { return node::Empty; } if char_len == 0u { return node::Empty; }
match (rope) { match (rope) {
node::Empty => fail, node::Empty => die!(),
node::Content(node) => if char_len > node::char_len(node) { node::Content(node) => if char_len > node::char_len(node) {
fail die!()
} else { } else {
return node::Content(node::sub_chars(node, char_offset, char_len)) return node::Content(node::sub_chars(node, char_offset, char_len))
} }
@ -271,9 +271,9 @@ pub fn sub_chars(rope: Rope, char_offset: uint, char_len: uint) -> Rope {
pub fn sub_bytes(rope: Rope, byte_offset: uint, byte_len: uint) -> Rope { pub fn sub_bytes(rope: Rope, byte_offset: uint, byte_len: uint) -> Rope {
if byte_len == 0u { return node::Empty; } if byte_len == 0u { return node::Empty; }
match (rope) { match (rope) {
node::Empty => fail, node::Empty => die!(),
node::Content(node) =>if byte_len > node::byte_len(node) { node::Content(node) =>if byte_len > node::byte_len(node) {
fail die!()
} else { } else {
return node::Content(node::sub_bytes(node, byte_offset, byte_len)) return node::Content(node::sub_bytes(node, byte_offset, byte_len))
} }
@ -550,7 +550,7 @@ pub pure fn byte_len(rope: Rope) -> uint {
*/ */
pub fn char_at(rope: Rope, pos: uint) -> char { pub fn char_at(rope: Rope, pos: uint) -> char {
match (rope) { match (rope) {
node::Empty => fail, node::Empty => die!(),
node::Content(x) => return node::char_at(x, pos) node::Content(x) => return node::char_at(x, pos)
} }
} }

View file

@ -390,7 +390,7 @@ pub impl<D: Decoder, T: Decodable<D>> Option<T>: Decodable<D> {
0 => None, 0 => None,
1 => Some(d.read_enum_variant_arg( 1 => Some(d.read_enum_variant_arg(
0u, || Decodable::decode(d))), 0u, || Decodable::decode(d))),
_ => fail(fmt!("Bad variant for option: %u", i)) _ => die!(fmt!("Bad variant for option: %u", i))
} }
} }
} }

View file

@ -85,7 +85,7 @@ pub fn sha1() -> Sha1 {
st.len_high += 1u32; st.len_high += 1u32;
if st.len_high == 0u32 { if st.len_high == 0u32 {
// FIXME: Need better failure mode (#2346) // FIXME: Need better failure mode (#2346)
fail; die!();
} }
} }
if st.msg_block_idx == msg_block_len { process_msg_block(st); } if st.msg_block_idx == msg_block_len { process_msg_block(st); }

View file

@ -69,7 +69,7 @@ pub pure fn get<T: Copy>(self: SmallIntMap<T>, key: uint) -> T {
match find(self, key) { match find(self, key) {
None => { None => {
error!("smallintmap::get(): key not present"); error!("smallintmap::get(): key not present");
fail; die!();
} }
Some(move v) => return v Some(move v) => return v
} }

Some files were not shown because too many files have changed in this diff Show more