Remove die!, raplace invocations with fail! Issue #4524 pt 3

This commit is contained in:
Nick Desaulniers 2013-02-11 19:26:38 -08:00 committed by Brian Anderson
parent c51ecc3223
commit 4445b38df2
363 changed files with 910 additions and 906 deletions

View File

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

View File

@ -145,7 +145,7 @@ fn parse_exec_env(line: ~str) -> Option<(~str, ~str)> {
match strs.len() {
1u => (strs[0], ~""),
2u => (strs[0], strs[1]),
n => die!(fmt!("Expected 1 or 2 strings, not %u", n))
n => fail!(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_out.in);
os::close(pipe_err.in);
die!();
fail!();
}
@ -99,7 +99,7 @@ pub fn run(lib_path: ~str,
(2, s) => {
errs = s;
}
_ => { die!() }
_ => { fail!() }
};
count -= 1;
};

View File

@ -202,7 +202,7 @@ actual:\n\
\n",
expected, actual);
io::stdout().write_str(msg);
die!();
fail!();
}
}
@ -518,7 +518,7 @@ fn compose_and_run_compiler(
fn ensure_dir(path: &Path) {
if os::path_is_dir(path) { return; }
if !os::make_dir(path, 0x1c0i32) {
die!(fmt!("can't make dir %s", path.to_str()));
fail!(fmt!("can't make dir %s", path.to_str()));
}
}
@ -668,7 +668,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 fatal(err: ~str) -> ! { error(err); die!(); }
fn fatal(err: ~str) -> ! { error(err); fail!(); }
fn fatal_ProcRes(err: ~str, ProcRes: ProcRes) -> ! {
let msg =
@ -686,5 +686,5 @@ stderr:\n\
\n",
err, ProcRes.cmdline, ProcRes.stdout, ProcRes.stderr);
io::stdout().write_str(msg);
die!();
fail!();
}

View File

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

View File

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

View File

@ -150,7 +150,7 @@ pub pure fn is_digit_radix(c: char, radix: uint) -> bool {
#[inline]
pub pure fn to_digit(c: char, radix: uint) -> Option<uint> {
if radix > 36 {
die!(fmt!("to_digit: radix %? is to high (maximum 36)", radix));
fail!(fmt!("to_digit: radix %? is to high (maximum 36)", radix));
}
let val = match c {
'0' .. '9' => c as uint - ('0' as uint),
@ -173,7 +173,7 @@ pub pure fn to_digit(c: char, radix: uint) -> Option<uint> {
#[inline]
pub pure fn from_digit(num: uint, radix: uint) -> Option<char> {
if radix > 36 {
die!(fmt!("from_digit: radix %? is to high (maximum 36)", num));
fail!(fmt!("from_digit: radix %? is to high (maximum 36)", num));
}
if num < radix {
if num < 10 {

View File

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

View File

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

View File

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

View File

@ -132,7 +132,8 @@ 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.
match move eith {
Left(move x) => move x, Right(_) => die!(~"either::unwrap_left Right")
Left(move x) => move x,
Right(_) => fail!(~"either::unwrap_left Right")
}
}
@ -141,7 +142,8 @@ 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.
match move eith {
Right(move x) => move x, Left(_) => die!(~"either::unwrap_right Left")
Right(move x) => move x,
Left(_) => fail!(~"either::unwrap_right Left")
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -402,7 +402,7 @@ pub pure fn to_str_hex(num: f32) -> ~str {
pub pure fn to_str_radix(num: f32, rdx: uint) -> ~str {
let (r, special) = num::to_str_common(
&num, rdx, true, true, num::SignNeg, num::DigAll);
if special { die!(~"number has a special value, \
if special { fail!(~"number has a special value, \
try to_str_radix_special() if those are expected") }
r
}

View File

@ -427,7 +427,7 @@ pub pure fn to_str_hex(num: f64) -> ~str {
pub pure fn to_str_radix(num: f64, rdx: uint) -> ~str {
let (r, special) = num::to_str_common(
&num, rdx, true, true, num::SignNeg, num::DigAll);
if special { die!(~"number has a special value, \
if special { fail!(~"number has a special value, \
try to_str_radix_special() if those are expected") }
r
}

View File

@ -143,7 +143,7 @@ pub pure fn to_str_hex(num: float) -> ~str {
pub pure fn to_str_radix(num: float, radix: uint) -> ~str {
let (r, special) = num::to_str_common(
&num, radix, true, true, num::SignNeg, num::DigAll);
if special { die!(~"number has a special value, \
if special { fail!(~"number has a special value, \
try to_str_radix_special() if those are expected") }
r
}
@ -509,16 +509,16 @@ pub fn test_from_str() {
// note: NaN != NaN, hence this slightly complex test
match from_str(~"NaN") {
Some(f) => assert is_NaN(f),
None => die!()
None => fail!()
}
// note: -0 == 0, hence these slightly more complex tests
match from_str(~"-0") {
Some(v) if is_zero(v) => assert is_negative(v),
_ => die!()
_ => fail!()
}
match from_str(~"0") {
Some(v) if is_zero(v) => assert is_positive(v),
_ => die!()
_ => fail!()
}
assert from_str(~"").is_none();
@ -556,16 +556,16 @@ pub fn test_from_str_hex() {
// note: NaN != NaN, hence this slightly complex test
match from_str_hex(~"NaN") {
Some(f) => assert is_NaN(f),
None => die!()
None => fail!()
}
// note: -0 == 0, hence these slightly more complex tests
match from_str_hex(~"-0") {
Some(v) if is_zero(v) => assert is_negative(v),
_ => die!()
_ => fail!()
}
match from_str_hex(~"0") {
Some(v) if is_zero(v) => assert is_positive(v),
_ => die!()
_ => fail!()
}
assert from_str_hex(~"e") == Some(14.);
assert from_str_hex(~"E") == Some(14.);

View File

@ -108,7 +108,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) {
let mut i = start;
if step == 0 {
die!(~"range_step called with step == 0");
fail!(~"range_step called with step == 0");
} else if step > 0 { // ascending
while i < stop {
if !it(i) { break }
@ -435,16 +435,16 @@ pub fn test_ranges() {
// None of the `fail`s should execute.
for range(10,0) |_i| {
die!(~"unreachable");
fail!(~"unreachable");
}
for range_rev(0,10) |_i| {
die!(~"unreachable");
fail!(~"unreachable");
}
for range_step(10,0,1) |_i| {
die!(~"unreachable");
fail!(~"unreachable");
}
for range_step(0,10,-1) |_i| {
die!(~"unreachable");
fail!(~"unreachable");
}
}

View File

@ -260,10 +260,10 @@ pub pure fn to_str_bytes_common<T: Num NumCast Zero One Eq Ord Round Copy>(
num: &T, radix: uint, special: bool, negative_zero: bool,
sign: SignFormat, digits: SignificantDigits) -> (~[u8], bool) {
if radix as int < 2 {
die!(fmt!("to_str_bytes_common: radix %? to low, \
fail!(fmt!("to_str_bytes_common: radix %? to low, \
must lie in the range [2, 36]", radix));
} else if radix as int > 36 {
die!(fmt!("to_str_bytes_common: radix %? to high, \
fail!(fmt!("to_str_bytes_common: radix %? to high, \
must lie in the range [2, 36]", radix));
}
@ -539,19 +539,19 @@ pub pure fn from_str_bytes_common<T: Num NumCast Zero One Ord Copy>(
) -> Option<T> {
match exponent {
ExpDec if radix >= DIGIT_E_RADIX // decimal exponent 'e'
=> die!(fmt!("from_str_bytes_common: radix %? incompatible with \
=> fail!(fmt!("from_str_bytes_common: radix %? incompatible with \
use of 'e' as decimal exponent", radix)),
ExpBin if radix >= DIGIT_P_RADIX // binary exponent 'p'
=> die!(fmt!("from_str_bytes_common: radix %? incompatible with \
=> fail!(fmt!("from_str_bytes_common: radix %? incompatible with \
use of 'p' as binary exponent", radix)),
_ if special && radix >= DIGIT_I_RADIX // first digit of 'inf'
=> die!(fmt!("from_str_bytes_common: radix %? incompatible with \
=> fail!(fmt!("from_str_bytes_common: radix %? incompatible with \
special values 'inf' and 'NaN'", radix)),
_ if radix as int < 2
=> die!(fmt!("from_str_bytes_common: radix %? to low, \
=> fail!(fmt!("from_str_bytes_common: radix %? to low, \
must lie in the range [2, 36]", radix)),
_ if radix as int > 36
=> die!(fmt!("from_str_bytes_common: radix %? to high, \
=> fail!(fmt!("from_str_bytes_common: radix %? to high, \
must lie in the range [2, 36]", radix)),
_ => ()
}

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) {
let mut i = start;
if step == 0 {
die!(~"range_step called with step == 0");
fail!(~"range_step called with step == 0");
}
if step >= 0 {
while i < stop {
@ -388,16 +388,16 @@ pub fn test_ranges() {
// None of the `fail`s should execute.
for range(0,0) |_i| {
die!(~"unreachable");
fail!(~"unreachable");
}
for range_rev(0,0) |_i| {
die!(~"unreachable");
fail!(~"unreachable");
}
for range_step(10,0,1) |_i| {
die!(~"unreachable");
fail!(~"unreachable");
}
for range_step(0,1,-10) |_i| {
die!(~"unreachable");
fail!(~"unreachable");
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -93,7 +93,7 @@ fn test_fail() {
let mut i = 0;
do (|| {
i = 10;
die!();
fail!();
}).finally {
assert failing();
assert i == 10;

View File

@ -269,7 +269,7 @@ fn test_modify() {
Some(~shared_mutable_state(10))
}
}
_ => die!()
_ => fail!()
}
}
@ -280,7 +280,7 @@ fn test_modify() {
assert *v == 10;
None
},
_ => die!()
_ => fail!()
}
}
@ -291,7 +291,7 @@ fn test_modify() {
Some(~shared_mutable_state(10))
}
}
_ => die!()
_ => fail!()
}
}
}

View File

@ -113,7 +113,7 @@ fn run_weak_task_service(port: Port<ServiceMsg>) {
// nobody will receive this
shutdown_chan.send(());
}
None => die!()
None => fail!()
}
}
Shutdown => break
@ -196,7 +196,7 @@ fn test_select_stream_and_oneshot() {
do weaken_task |signal| {
match select2i(&port, &signal) {
Left(*) => (),
Right(*) => die!()
Right(*) => fail!()
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -133,15 +133,15 @@ fn test_tls_modify() {
fn my_key(_x: @~str) { }
local_data_modify(my_key, |data| {
match data {
Some(@ref val) => die!(~"unwelcome value: " + *val),
Some(@ref val) => fail!(~"unwelcome value: " + *val),
None => Some(@~"first data")
}
});
local_data_modify(my_key, |data| {
match data {
Some(@~"first data") => Some(@~"next data"),
Some(@ref val) => die!(~"wrong value: " + *val),
None => die!(~"missing value")
Some(@ref val) => fail!(~"wrong value: " + *val),
None => fail!(~"missing value")
}
});
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(box_key, @@());
local_data_set(int_key, @42);
die!();
fail!();
}
}
// Not quite nondeterministic.
local_data_set(int_key, @31337);
die!();
fail!();
}
}

View File

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

View File

@ -644,7 +644,7 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) {
fn new_task_in_sched(opts: SchedOpts) -> *rust_task {
if opts.foreign_stack_size != None {
die!(~"foreign_stack_size scheduler option unimplemented");
fail!(~"foreign_stack_size scheduler option unimplemented");
}
let num_threads = match opts.mode {
@ -655,11 +655,11 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) {
SingleThreaded => 1u,
ThreadPerCore => unsafe { rt::rust_num_threads() },
ThreadPerTask => {
die!(~"ThreadPerTask scheduling mode unimplemented")
fail!(~"ThreadPerTask scheduling mode unimplemented")
}
ManualThreads(threads) => {
if threads == 0u {
die!(~"can not create a scheduler with no threads");
fail!(~"can not create a scheduler with no threads");
}
threads
}
@ -695,7 +695,7 @@ fn test_spawn_raw_unsupervise() {
.. default_task_opts()
};
do spawn_raw(move opts) {
die!();
fail!();
}
}
@ -725,7 +725,7 @@ fn test_spawn_raw_notify_failure() {
.. default_task_opts()
};
do spawn_raw(move opts) {
die!();
fail!();
}
assert notify_po.recv() == Failure;
}

View File

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

View File

@ -239,7 +239,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.
pub pure fn last<T: Copy>(v: &[const T]) -> T {
if len(v) == 0u { die!(~"last_unsafe: empty vector") }
if len(v) == 0u { fail!(~"last_unsafe: empty vector") }
v[len(v) - 1u]
}
@ -562,7 +562,7 @@ pub fn consume<T>(mut v: ~[T], f: fn(uint, v: T)) {
pub fn pop<T>(v: &mut ~[T]) -> T {
let ln = v.len();
if ln == 0 {
die!(~"sorry, cannot vec::pop an empty vector")
fail!(~"sorry, cannot vec::pop an empty vector")
}
let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]);
unsafe {
@ -583,7 +583,7 @@ pub fn pop<T>(v: &mut ~[T]) -> T {
pub fn swap_remove<T>(v: &mut ~[T], index: uint) -> T {
let ln = v.len();
if index >= ln {
die!(fmt!("vec::swap_remove - index %u >= length %u", index, ln));
fail!(fmt!("vec::swap_remove - index %u >= length %u", index, ln));
}
if index < ln - 1 {
v[index] <-> v[ln - 1];
@ -825,7 +825,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],
f: fn(t: &T, v: &U) -> V) -> ~[V] {
let v0_len = len(v0);
if v0_len != len(v1) { die!(); }
if v0_len != len(v1) { fail!(); }
let mut u: ~[V] = ~[];
let mut i = 0u;
while i < v0_len {
@ -2912,7 +2912,7 @@ mod tests {
#[test]
fn test_each_empty() {
for each::<int>(~[]) |_v| {
die!(); // should never be executed
fail!(); // should never be executed
}
}
@ -2939,7 +2939,7 @@ mod tests {
#[test]
fn test_reach_empty() {
for rev_each::<int>(~[]) |_v| {
die!(); // should never execute
fail!(); // should never execute
}
}
@ -3441,7 +3441,7 @@ mod tests {
#[should_fail]
fn test_from_fn_fail() {
do from_fn(100) |v| {
if v == 50 { die!() }
if v == 50 { fail!() }
(~0, @0)
};
}
@ -3455,7 +3455,7 @@ mod tests {
push((~0, @0));
push((~0, @0));
push((~0, @0));
die!();
fail!();
};
}
@ -3468,7 +3468,7 @@ mod tests {
let mut i = 0;
do split(v) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 1;
@ -3485,7 +3485,7 @@ mod tests {
let mut i = 0;
do split(v) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 1;
@ -3502,7 +3502,7 @@ mod tests {
let mut i = 0;
do splitn(v, 100) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 1;
@ -3519,7 +3519,7 @@ mod tests {
let mut i = 0;
do split(v) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 1;
@ -3536,7 +3536,7 @@ mod tests {
let mut i = 0;
do rsplit(v) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 1;
@ -3553,7 +3553,7 @@ mod tests {
let mut i = 0;
do rsplit(v) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 1;
@ -3570,7 +3570,7 @@ mod tests {
let mut i = 0;
do rsplitn(v, 100) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 1;
@ -3587,7 +3587,7 @@ mod tests {
let mut i = 0;
do rsplitn(v, 100) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 1;
@ -3603,7 +3603,7 @@ mod tests {
let mut i = 0;
do consume(v) |_i, _elt| {
if i == 2 {
die!()
fail!()
}
i += 1;
};
@ -3617,7 +3617,7 @@ mod tests {
let mut v = ~[];
do v.grow_fn(100) |i| {
if i == 50 {
die!()
fail!()
}
(~0, @0)
}
@ -3631,7 +3631,7 @@ mod tests {
let mut i = 0;
do map(v) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 0;
~[(~0, @0)]
@ -3646,7 +3646,7 @@ mod tests {
let mut i = 0;
do map_consume(v) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 0;
~[(~0, @0)]
@ -3661,7 +3661,7 @@ mod tests {
let mut i = 0;
do mapi(v) |_i, _elt| {
if i == 2 {
die!()
fail!()
}
i += 0;
~[(~0, @0)]
@ -3676,7 +3676,7 @@ mod tests {
let mut i = 0;
do map(v) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 0;
~[(~0, @0)]
@ -3692,7 +3692,7 @@ mod tests {
let mut i = 0;
do map2(v, v) |_elt1, _elt2| {
if i == 2 {
die!()
fail!()
}
i += 0;
~[(~0, @0)]
@ -3708,7 +3708,7 @@ mod tests {
let mut i = 0;
do filter_mapped(v) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 0;
Some((~0, @0))
@ -3724,7 +3724,7 @@ mod tests {
let mut i = 0;
do v.filtered |_elt| {
if i == 2 {
die!()
fail!()
}
i += 0;
true
@ -3740,7 +3740,7 @@ mod tests {
let mut i = 0;
do foldl((~0, @0), v) |_a, _b| {
if i == 2 {
die!()
fail!()
}
i += 0;
(~0, @0)
@ -3756,7 +3756,7 @@ mod tests {
let mut i = 0;
do foldr(v, (~0, @0)) |_a, _b| {
if i == 2 {
die!()
fail!()
}
i += 0;
(~0, @0)
@ -3771,7 +3771,7 @@ mod tests {
let mut i = 0;
do any(v) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 0;
false
@ -3786,7 +3786,7 @@ mod tests {
let mut i = 0;
do any(v) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 0;
false
@ -3801,7 +3801,7 @@ mod tests {
let mut i = 0;
do all(v) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 0;
true
@ -3816,7 +3816,7 @@ mod tests {
let mut i = 0;
do alli(v) |_i, _elt| {
if i == 2 {
die!()
fail!()
}
i += 0;
true
@ -3831,7 +3831,7 @@ mod tests {
let mut i = 0;
do all2(v, v) |_elt1, _elt2| {
if i == 2 {
die!()
fail!()
}
i += 0;
true
@ -3847,7 +3847,7 @@ mod tests {
let mut i = 0;
do find(v) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 0;
false
@ -3862,7 +3862,7 @@ mod tests {
let mut i = 0;
do position(v) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 0;
false
@ -3877,7 +3877,7 @@ mod tests {
let mut i = 0;
do rposition(v) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 0;
false
@ -3892,7 +3892,7 @@ mod tests {
let mut i = 0;
do each(v) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 0;
false
@ -3907,7 +3907,7 @@ mod tests {
let mut i = 0;
do eachi(v) |_i, _elt| {
if i == 2 {
die!()
fail!()
}
i += 0;
false
@ -3923,7 +3923,7 @@ mod tests {
let mut i = 0;
for each_permutation(v) |_elt| {
if i == 2 {
die!()
fail!()
}
i += 0;
}
@ -3935,7 +3935,7 @@ mod tests {
fn test_as_imm_buf_fail() {
let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
do as_imm_buf(v) |_buf, _i| {
die!()
fail!()
}
}
@ -3945,7 +3945,7 @@ mod tests {
fn test_as_const_buf_fail() {
let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
do as_const_buf(v) |_buf, _i| {
die!()
fail!()
}
}
@ -3955,7 +3955,7 @@ mod tests {
fn test_as_mut_buf_fail() {
let mut v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
do as_mut_buf(v) |_buf, _i| {
die!()
fail!()
}
}

View File

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

View File

@ -42,7 +42,7 @@ fn shuffled<T: copy>(r : rand::rng, v : ~[T]) -> ~[T] {
}
// sample from a population without replacement
//fn sample<T>(r : rand::rng, pop : ~[T], k : uint) -> ~[T] { die!() }
//fn sample<T>(r : rand::rng, pop : ~[T], k : uint) -> ~[T] { fail!() }
// Two ways to make a weighted choice.
// * 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(_, _) => {
// FIXME (#607): Implement this
die!(~"unimplemented meta_item variant");
fail!(~"unimplemented meta_item variant");
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -553,7 +553,7 @@ fn purity_static_method_family(p: purity) -> char {
unsafe_fn => 'U',
pure_fn => 'P',
impure_fn => 'F',
_ => die!(~"extern fn can't be static")
_ => fail!(~"extern fn can't be static")
}
}
@ -879,7 +879,7 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: writer::Encoder,
true, item.id, *m, /*bad*/copy m.tps);
}
}
item_mac(*) => die!(~"item macros unimplemented")
item_mac(*) => fail!(~"item macros unimplemented")
}
}
@ -936,7 +936,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: writer::Encoder,
encode_info_for_item(ecx, ebml_w, i,
index, *pt);
}
_ => die!(~"bad item")
_ => fail!(~"bad item")
}
}
},
@ -951,7 +951,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: writer::Encoder,
abi);
}
// case for separate item and foreign-item tables
_ => die!(~"bad foreign item")
_ => fail!(~"bad foreign item")
}
}
},

View File

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

View File

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

View File

@ -190,7 +190,7 @@ fn parse_bound_region(st: @mut PState) -> ty::bound_region {
assert next(st) == '|';
ty::br_cap_avoid(id, @parse_bound_region(st))
},
_ => die!(~"parse_bound_region: bad input")
_ => fail!(~"parse_bound_region: bad input")
}
}
@ -215,7 +215,7 @@ fn parse_region(st: @mut PState) -> ty::Region {
't' => {
ty::re_static
}
_ => die!(~"parse_region: bad input")
_ => fail!(~"parse_region: bad input")
}
}
@ -223,7 +223,7 @@ fn parse_opt<T>(st: @mut PState, f: fn() -> T) -> Option<T> {
match next(st) {
'n' => None,
's' => Some(f()),
_ => die!(~"parse_opt: bad input")
_ => fail!(~"parse_opt: bad input")
}
}
@ -256,7 +256,7 @@ fn parse_ty(st: @mut PState, conv: conv_did) -> ty::t {
'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_f64),
_ => die!(~"parse_ty: bad numeric type")
_ => fail!(~"parse_ty: bad numeric type")
}
}
'c' => return ty::mk_char(st.tcx),
@ -360,7 +360,7 @@ fn parse_ty(st: @mut PState, conv: conv_did) -> ty::t {
assert (next(st) == ']');
return ty::mk_struct(st.tcx, did, substs);
}
c => { error!("unexpected char in type string: %c", c); die!();}
c => { error!("unexpected char in type string: %c", c); fail!();}
}
}
@ -412,14 +412,14 @@ fn parse_purity(c: char) -> purity {
'p' => pure_fn,
'i' => impure_fn,
'c' => extern_fn,
_ => die!(~"parse_purity: bad purity")
_ => fail!(~"parse_purity: bad purity")
}
}
fn parse_abi(c: char) -> Abi {
match c {
'r' => ast::RustAbi,
_ => die!(fmt!("parse_abi: bad ABI '%c'", c))
_ => fail!(fmt!("parse_abi: bad ABI '%c'", c))
}
}
@ -427,7 +427,7 @@ fn parse_onceness(c: char) -> ast::Onceness {
match c {
'o' => ast::Once,
'm' => ast::Many,
_ => die!(~"parse_onceness: bad onceness")
_ => fail!(~"parse_onceness: bad onceness")
}
}
@ -440,7 +440,7 @@ fn parse_mode(st: @mut PState) -> ast::mode {
'+' => ast::by_copy,
'=' => ast::by_ref,
'#' => ast::by_val,
_ => die!(~"bad mode")
_ => fail!(~"bad mode")
});
return m;
}
@ -490,7 +490,7 @@ pub fn parse_def_id(buf: &[u8]) -> ast::def_id {
while colon_idx < len && buf[colon_idx] != ':' as u8 { colon_idx += 1u; }
if colon_idx == len {
error!("didn't find ':' when parsing def id");
die!();
fail!();
}
let crate_part = vec::view(buf, 0u, colon_idx);
@ -498,12 +498,12 @@ pub fn parse_def_id(buf: &[u8]) -> ast::def_id {
let crate_num = match uint::parse_bytes(crate_part, 10u) {
Some(cn) => cn as int,
None => die!(fmt!("internal error: parse_def_id: crate number \
None => fail!(fmt!("internal error: parse_def_id: crate number \
expected, but found %?", crate_part))
};
let def_num = match uint::parse_bytes(def_part, 10u) {
Some(dn) => dn as int,
None => die!(fmt!("internal error: parse_def_id: id expected, but \
None => fail!(fmt!("internal error: parse_def_id: id expected, but \
found %?", def_part))
};
ast::def_id { crate: crate_num, node: def_num }
@ -526,7 +526,7 @@ fn parse_bounds(st: @mut PState, conv: conv_did) -> @~[ty::param_bound] {
'O' => ty::bound_durable,
'I' => ty::bound_trait(parse_ty(st, conv)),
'.' => break,
_ => die!(~"parse_bounds: bad bounds")
_ => fail!(~"parse_bounds: bad bounds")
});
}
@bounds

View File

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

View File

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

View File

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

View File

@ -147,11 +147,11 @@ pub fn check_exhaustive(cx: @MatchCheckCtxt, sp: span, pats: ~[@pat]) {
}
ty::ty_enum(id, _) => {
let vid = match (*ctor) { variant(id) => id,
_ => die!(~"check_exhaustive: non-variant ctor") };
_ => fail!(~"check_exhaustive: non-variant ctor") };
match vec::find(*ty::enum_variants(cx.tcx, id),
|v| v.id == vid) {
Some(v) => Some(cx.tcx.sess.str_of(v.name)),
None => die!(~"check_exhaustive: bad variant in ctor")
None => fail!(~"check_exhaustive: bad variant in ctor")
}
}
ty::ty_unboxed_vec(*) | ty::ty_evec(*) => {
@ -366,7 +366,7 @@ pub fn missing_ctor(cx: @MatchCheckCtxt,
return Some(variant(v.id));
}
}
die!();
fail!();
} else { None }
}
ty::ty_nil => None,
@ -377,7 +377,7 @@ pub fn missing_ctor(cx: @MatchCheckCtxt,
None => (),
Some(val(const_bool(true))) => true_found = true,
Some(val(const_bool(false))) => false_found = true,
_ => die!(~"impossible case")
_ => fail!(~"impossible case")
}
}
if true_found && false_found { None }
@ -445,10 +445,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_enum(eid, _) => {
let id = match ctor { variant(id) => id,
_ => die!(~"impossible case") };
_ => fail!(~"impossible case") };
match vec::find(*ty::enum_variants(cx.tcx, eid), |v| v.id == id ) {
Some(v) => v.args.len(),
None => die!(~"impossible case")
None => fail!(~"impossible case")
}
}
ty::ty_struct(cid, _) => ty::lookup_struct_fields(cx.tcx, cid).len(),
@ -496,7 +496,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
compare_const_vals((*c_hi), e_v) <= 0
}
single => true,
_ => die!(~"type error")
_ => fail!(~"type error")
};
if match_ { Some(vec::tail(r)) } else { None }
}
@ -529,7 +529,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
pat_rec(ref flds, _) => {
let ty_flds = match /*bad*/copy ty::get(left_ty).sty {
ty::ty_rec(flds) => flds,
_ => die!(~"bad type for pat_rec")
_ => fail!(~"bad type for pat_rec")
};
let args = vec::map(ty_flds, |ty_fld| {
match flds.find(|f| f.ident == ty_fld.ident) {
@ -595,7 +595,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
compare_const_vals((*c_hi), e_v) <= 0
}
single => true,
_ => die!(~"type error")
_ => fail!(~"type error")
};
if match_ { Some(vec::tail(r)) } else { None }
}
@ -605,7 +605,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
range(ref lo, ref hi) =>
((/*bad*/copy *lo), (/*bad*/copy *hi)),
single => return Some(vec::tail(r)),
_ => die!(~"type error")
_ => fail!(~"type error")
};
let v_lo = eval_const_expr(cx.tcx, lo),
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 {
match eval_const_expr_partial(tcx, e) {
Ok(ref r) => (/*bad*/copy *r),
Err(ref s) => die!(/*bad*/copy *s)
Err(ref s) => fail!(/*bad*/copy *s)
}
}
@ -459,7 +459,7 @@ pub fn compare_const_vals(a: const_val, b: const_val) -> int {
1
}
}
_ => die!(~"compare_const_vals: ill-typed comparison")
_ => fail!(~"compare_const_vals: ill-typed comparison")
}
}

View File

@ -57,7 +57,7 @@ fn collect_freevars(def_map: resolve::DefMap, blk: ast::blk)
ast::expr_path(*) => {
let mut i = 0;
match def_map.find(&expr.id) {
None => die!(~"path not found"),
None => fail!(~"path not found"),
Some(df) => {
let mut def = df;
while i < depth {
@ -117,7 +117,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 {
match tcx.freevars.find(&fid) {
None => die!(~"get_freevars: " + int::str(fid) + ~" has no freevars"),
None => fail!(~"get_freevars: " + int::str(fid) + ~" has no freevars"),
Some(d) => return d
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -96,7 +96,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
let elt = llvm::LLVMGetElementType(ty);
ty_align(elt)
}
_ => die!(~"ty_size: unhandled type")
_ => fail!(~"ty_size: unhandled type")
};
}
}
@ -122,7 +122,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
let eltsz = ty_size(elt);
len * eltsz
}
_ => die!(~"ty_size: unhandled type")
_ => fail!(~"ty_size: unhandled type")
};
}
}
@ -215,7 +215,7 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
i += 1u;
}
}
_ => die!(~"classify: unhandled type")
_ => fail!(~"classify: unhandled type")
}
}
}
@ -316,7 +316,7 @@ fn llreg_ty(cls: &[x86_64_reg_class]) -> TypeRef {
sse_ds_class => {
tys.push(T_f64());
}
_ => die!(~"llregtype: unhandled class")
_ => fail!(~"llregtype: unhandled class")
}
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));
new_llval = PointerCast(callee.bcx, fn_data.llfn, llfnty);
}
_ => die!()
_ => fail!()
}
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() {
match cx.parent {
Some(b) => cx = b,
None => die!()
None => fail!()
}
}
let sp = cx.node_info.get().span;
@ -553,7 +553,7 @@ fn create_ty(_cx: @crate_ctxt, _t: ty::t, _ty: @ast::Ty)
* elsewhere, not be self-contained.
*/
die!();
fail!();
/*
fn t_to_ty(cx: crate_ctxt, t: ty::t, span: span) -> @ast::ty {
let ty = match ty::get(t).struct {
@ -669,7 +669,7 @@ pub fn create_local_var(bcx: block, local: @ast::local)
let name = match local.node.pat.node {
ast::pat_ident(_, pth, _) => ast_util::path_to_ident(pth),
// FIXME this should be handled (#2533)
_ => die!(~"no single variable name for local")
_ => fail!(~"no single variable name for local")
};
let loc = cx.sess.codemap.lookup_char_pos(local.span.lo);
let ty = node_id_type(bcx, local.node.id);

View File

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

View File

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

View File

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

View File

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

View File

@ -1505,7 +1505,7 @@ pub fn get_element_type(ty: t, i: uint) -> t {
match /*bad*/copy get(ty).sty {
ty_rec(flds) => return flds[i].mt.ty,
ty_tup(ts) => return ts[i],
_ => die!(~"get_element_type called on invalid type")
_ => fail!(~"get_element_type called on invalid type")
}
}
@ -2788,7 +2788,7 @@ pub fn ty_fn_args(fty: t) -> ~[arg] {
ty_bare_fn(ref f) => copy f.sig.inputs,
ty_closure(ref f) => copy f.sig.inputs,
ref s => {
die!(fmt!("ty_fn_args() called on non-fn type: %?", s))
fail!(fmt!("ty_fn_args() called on non-fn type: %?", s))
}
}
}
@ -2797,7 +2797,8 @@ pub fn ty_closure_sigil(fty: t) -> Sigil {
match get(fty).sty {
ty_closure(ref f) => f.sigil,
ref s => {
die!(fmt!("ty_closure_sigil() called on non-closure type: %?", s))
fail!(fmt!("ty_closure_sigil() called on non-closure type: %?",
s))
}
}
}
@ -2807,7 +2808,7 @@ pub fn ty_fn_purity(fty: t) -> ast::purity {
ty_bare_fn(ref f) => f.purity,
ty_closure(ref f) => f.purity,
ref s => {
die!(fmt!("ty_fn_purity() called on non-fn type: %?", s))
fail!(fmt!("ty_fn_purity() called on non-fn type: %?", s))
}
}
}
@ -2817,7 +2818,7 @@ pub pure fn ty_fn_ret(fty: t) -> t {
ty_bare_fn(ref f) => f.sig.output,
ty_closure(ref f) => f.sig.output,
ref s => {
die!(fmt!("ty_fn_ret() called on non-fn type: %?", s))
fail!(fmt!("ty_fn_ret() called on non-fn type: %?", s))
}
}
}
@ -2834,7 +2835,7 @@ pub pure fn ty_vstore(ty: t) -> vstore {
match get(ty).sty {
ty_evec(_, vstore) => vstore,
ty_estr(vstore) => vstore,
ref s => die!(fmt!("ty_vstore() called on invalid sty: %?", s))
ref s => fail!(fmt!("ty_vstore() called on invalid sty: %?", s))
}
}
@ -2843,7 +2844,7 @@ pub fn ty_region(ty: t) -> Region {
ty_rptr(r, _) => r,
ty_evec(_, vstore_slice(r)) => r,
ty_estr(vstore_slice(r)) => r,
ref s => die!(fmt!("ty_region() invoked on in appropriate ty: %?",
ref s => fail!(fmt!("ty_region() invoked on in appropriate ty: %?",
(*s)))
}
}
@ -3209,7 +3210,7 @@ pub fn stmt_node_id(s: @ast::stmt) -> ast::node_id {
ast::stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) => {
return id;
}
ast::stmt_mac(*) => die!(~"unexpanded macro in trans")
ast::stmt_mac(*) => fail!(~"unexpanded macro in trans")
}
}
@ -3233,7 +3234,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) {
Some(f) => f,
// Do we only call this when we know the field is legit?
None => die!(fmt!("get_field: ty doesn't have a field %s",
None => fail!(fmt!("get_field: ty doesn't have a field %s",
tcx.sess.str_of(id)))
}
}
@ -3242,7 +3243,7 @@ pub fn get_fields(rec_ty:t) -> ~[field] {
match /*bad*/copy get(rec_ty).sty {
ty_rec(fields) => fields,
// Can we check at the caller?
_ => die!(~"get_fields: not a record type")
_ => fail!(~"get_fields: not a record type")
}
}
@ -3904,10 +3905,10 @@ pub fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[VariantInfo] {
}
}
ast::struct_variant_kind(_) => {
die!(~"struct variant kinds unimpl in enum_variants")
fail!(~"struct variant kinds unimpl in enum_variants")
}
ast::enum_variant_kind(_) => {
die!(~"enum variant kinds unimpl in enum_variants")
fail!(~"enum variant kinds unimpl in enum_variants")
}
}
})

View File

@ -1234,7 +1234,7 @@ pub impl LookupContext {
let span = if did.crate == ast::local_crate {
match self.tcx().items.find(&did.node) {
Some(ast_map::node_method(m, _, _)) => m.span,
_ => die!(fmt!("report_static_candidate: bad item %?", did))
_ => fail!(fmt!("report_static_candidate: bad item %?", did))
}
} else {
self.expr.span

View File

@ -2097,7 +2097,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
inner_ty, fcx.expr_ty(loop_body));
}
ref n => {
die!(fmt!(
fail!(fmt!(
"check_loop_body expected expr_fn_block, not %?", n))
}
}
@ -2394,7 +2394,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b));
}
// argh
_ => die!(~"expected fn ty")
_ => fail!(~"expected fn ty")
}
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| {
match ty::get(*t_f).sty {
ty::ty_trait(_, ref substs_f, _) => (/*bad*/copy *substs_f),
_ => die!(~"t_f should be a trait")
_ => fail!(~"t_f should be a trait")
}
}
}

View File

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

View File

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

View File

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

View File

@ -119,7 +119,7 @@ fn parse_item_attrs<T:Owned>(
let attrs = match ctxt.ast_map.get(&id) {
ast_map::node_item(item, _) => copy item.attrs,
ast_map::node_foreign_item(item, _, _) => copy item.attrs,
_ => die!(~"parse_item_attrs: not an item")
_ => fail!(~"parse_item_attrs: not an item")
};
parse_attrs(attrs)
}
@ -183,7 +183,7 @@ fn fold_enum(
copy ast_variant.node.attrs)
}
_ => {
die!(fmt!("Enum variant %s has id that's \
fail!(fmt!("Enum variant %s has id that's \
not bound to an enum item",
variant.name))
}
@ -258,7 +258,7 @@ fn merge_method_attrs(
attr_parser::parse_desc(copy method.attrs))
})
}
_ => die!(~"unexpected item")
_ => fail!(~"unexpected item")
}
};

View File

@ -71,7 +71,7 @@ fn take_my_order_please(
* This function is full of fail
*/
die!();
fail!();
}
mod fortress_of_solitude {
@ -192,6 +192,6 @@ impl OmNomNomy: TheShunnedHouse {
}
fn construct(&self) -> bool {
die!();
fail!();
}
}

View File

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

View File

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

View File

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

View File

@ -80,7 +80,7 @@ fn get_fn_sig(srv: astsrv::Srv, fn_id: doc::AstId) -> Option<~str> {
Some(pprust::fun_to_str(*decl, ident, copy *tys,
extract::interner()))
}
_ => die!(~"get_fn_sig: fn_id not bound to a fn item")
_ => fail!(~"get_fn_sig: fn_id not bound to a fn item")
}
}
}
@ -113,7 +113,7 @@ fn fold_const(
}, _) => {
pprust::ty_to_str(ty, extract::interner())
}
_ => die!(~"fold_const: id not bound to a const item")
_ => fail!(~"fold_const: id not bound to a const item")
}
}}),
.. doc
@ -150,7 +150,7 @@ fn fold_enum(
pprust::variant_to_str(
ast_variant, extract::interner())
}
_ => die!(~"enum variant not bound to an enum item")
_ => fail!(~"enum variant not bound to an enum item")
}
}
};
@ -229,7 +229,7 @@ fn get_method_sig(
}
}
}
_ => die!(~"method not found")
_ => fail!(~"method not found")
}
}
ast_map::node_item(@ast::item {
@ -246,10 +246,10 @@ fn get_method_sig(
extract::interner()
))
}
None => die!(~"method not found")
None => fail!(~"method not found")
}
}
_ => die!(~"get_method_sig: item ID not bound to trait or impl")
_ => fail!(~"get_method_sig: item ID not bound to trait or impl")
}
}
}
@ -282,7 +282,7 @@ fn fold_impl(
Some(pprust::ty_to_str(
self_ty, extract::interner())))
}
_ => die!(~"expected impl")
_ => fail!(~"expected impl")
}
}
};
@ -315,7 +315,7 @@ fn should_add_impl_self_ty() {
#[test]
fn should_add_impl_method_sigs() {
let doc = test::mk_doc(~"impl int { fn a<T>() -> int { die!() } }");
let doc = test::mk_doc(~"impl int { fn a<T>() -> int { fail!() } }");
assert doc.cratemod().impls()[0].methods[0].sig
== Some(~"fn a<T>() -> int");
}
@ -345,7 +345,7 @@ fn fold_type(
extract::interner())
))
}
_ => die!(~"expected type")
_ => fail!(~"expected type")
}
}
},
@ -375,7 +375,7 @@ fn fold_struct(
Some(pprust::item_to_str(item,
extract::interner()))
}
_ => die!(~"not an item")
_ => fail!(~"not an item")
}
}
},
@ -396,7 +396,7 @@ fn strip_struct_extra_stuff(item: @ast::item) -> @ast::item {
};
ast::item_struct(def, tys)
}
_ => die!(~"not a struct")
_ => fail!(~"not a struct")
};
@ast::item {

View File

@ -178,10 +178,10 @@ fn run(repl: Repl, input: ~str) -> Repl {
ast::expr_call(_, exprs, _) => {
match exprs[0].node {
ast::expr_block(blk) => @blk,
_ => die!()
_ => fail!()
}
}
_ => die!()
_ => fail!()
};
debug!("recording input into repl history");
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;
while (!end_multiline) {
match get_line(~"rusti| ") {
None => die!(~"unterminated multiline command :{ .. :}"),
None => fail!(~"unterminated multiline command :{ .. :}"),
Some(line) => {
if str::trim(line) == ~":}" {
end_multiline = true;

View File

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

View File

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

View File

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

View File

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

View File

@ -240,7 +240,7 @@ pub fn Bitv (nbits: uint, init: bool) -> Bitv {
priv impl Bitv {
fn die() -> ! {
die!(~"Tried to do operation on bit vectors with different sizes");
fail!(~"Tried to do operation on bit vectors with different sizes");
}
#[inline(always)]
@ -985,7 +985,7 @@ mod tests {
let b = Bitv(14, true);
b.clear();
for b.ones |i| {
die!(fmt!("found 1 at %?", i));
fail!(fmt!("found 1 at %?", i));
}
}
@ -994,7 +994,7 @@ mod tests {
let b = Bitv(140, true);
b.clear();
for b.ones |i| {
die!(fmt!("found 1 at %?", i));
fail!(fmt!("found 1 at %?", i));
}
}
}

View File

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

View File

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

View File

@ -107,7 +107,7 @@ pub mod reader {
(data[start + 2u] as uint) << 8u |
(data[start + 3u] as uint),
next: start + 4u};
} else { error!("vint too big"); die!(); }
} else { error!("vint too big"); fail!(); }
}
pub fn Doc(data: @~[u8]) -> Doc {
@ -143,7 +143,7 @@ pub mod reader {
Some(d) => d,
None => {
error!("failed to find block with tag %u", tg);
die!();
fail!();
}
}
}
@ -230,7 +230,7 @@ pub mod reader {
self.pos = r_doc.end;
let str = doc_as_str(r_doc);
if lbl != str {
die!(fmt!("Expected label %s but found %s", lbl,
fail!(fmt!("Expected label %s but found %s", lbl,
str));
}
}
@ -240,7 +240,7 @@ pub mod reader {
fn next_doc(exp_tag: EbmlEncoderTag) -> Doc {
debug!(". next_doc(exp_tag=%?)", exp_tag);
if self.pos >= self.parent.end {
die!(~"no more documents in current node!");
fail!(~"no more documents in current node!");
}
let TaggedDoc { tag: r_tag, doc: r_doc } =
doc_at(self.parent.data, self.pos);
@ -248,11 +248,11 @@ pub mod reader {
copy self.parent.start, copy self.parent.end,
copy self.pos, r_tag, r_doc.start, r_doc.end);
if r_tag != (exp_tag as uint) {
die!(fmt!("expected EBML doc with tag %? but found tag %?",
fail!(fmt!("expected EBML doc with tag %? but found tag %?",
exp_tag, r_tag));
}
if r_doc.end > self.parent.end {
die!(fmt!("invalid EBML, child extends to 0x%x, \
fail!(fmt!("invalid EBML, child extends to 0x%x, \
parent to 0x%x", r_doc.end, self.parent.end));
}
self.pos = r_doc.end;
@ -295,7 +295,7 @@ pub mod reader {
fn read_uint(&self) -> uint {
let v = doc_as_u64(self.next_doc(EsUint));
if v > (::core::uint::max_value as u64) {
die!(fmt!("uint %? too large for this architecture", v));
fail!(fmt!("uint %? too large for this architecture", v));
}
v as uint
}
@ -307,7 +307,7 @@ pub mod reader {
fn read_int(&self) -> int {
let v = doc_as_u64(self.next_doc(EsInt)) as i64;
if v > (int::max_value as i64) || v < (int::min_value as i64) {
die!(fmt!("int %? out of range for this architecture", v));
fail!(fmt!("int %? out of range for this architecture", v));
}
v as int
}
@ -315,14 +315,14 @@ pub mod reader {
fn read_bool(&self) -> bool { doc_as_u8(self.next_doc(EsBool))
as bool }
fn read_f64(&self) -> f64 { die!(~"read_f64()"); }
fn read_f32(&self) -> f32 { die!(~"read_f32()"); }
fn read_float(&self) -> float { die!(~"read_float()"); }
fn read_f64(&self) -> f64 { fail!(~"read_f64()"); }
fn read_f32(&self) -> f32 { fail!(~"read_f32()"); }
fn read_float(&self) -> float { fail!(~"read_float()"); }
fn read_char(&self) -> char { die!(~"read_char()"); }
fn read_char(&self) -> char { fail!(~"read_char()"); }
fn read_owned_str(&self) -> ~str { doc_as_str(self.next_doc(EsStr)) }
fn read_managed_str(&self) -> @str { die!(~"read_managed_str()"); }
fn read_managed_str(&self) -> @str { fail!(~"read_managed_str()"); }
// Compound types:
fn read_owned<T>(&self, f: fn() -> T) -> T {
@ -431,7 +431,7 @@ pub mod writer {
n as u8]),
4u => w.write(&[0x10u8 | ((n >> 24_u) as u8), (n >> 16_u) as u8,
(n >> 8_u) as u8, n as u8]),
_ => die!(fmt!("vint to write too big: %?", n))
_ => fail!(fmt!("vint to write too big: %?", n))
};
}
@ -440,7 +440,7 @@ pub mod writer {
if n < 0x4000_u { write_sized_vuint(w, n, 2u); return; }
if n < 0x200000_u { write_sized_vuint(w, n, 3u); return; }
if n < 0x10000000_u { write_sized_vuint(w, n, 4u); return; }
die!(fmt!("vint to write too big: %?", n));
fail!(fmt!("vint to write too big: %?", n));
}
pub fn Encoder(w: io::Writer) -> Encoder {
@ -602,17 +602,17 @@ pub mod writer {
// FIXME (#2742): implement these
fn emit_f64(&self, _v: f64) {
die!(~"Unimplemented: serializing an f64");
fail!(~"Unimplemented: serializing an f64");
}
fn emit_f32(&self, _v: f32) {
die!(~"Unimplemented: serializing an f32");
fail!(~"Unimplemented: serializing an f32");
}
fn emit_float(&self, _v: float) {
die!(~"Unimplemented: serializing a float");
fail!(~"Unimplemented: serializing a float");
}
fn emit_char(&self, _v: char) {
die!(~"Unimplemented: serializing a char");
fail!(~"Unimplemented: serializing a char");
}
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 {
match self.try_recv() {
Some(move val) => move val,
None => die!(~"port is closed")
None => fail!(~"port is closed")
}
}
fn try_recv() -> Option<T> {
@ -298,7 +298,7 @@ pub impl<T,U:Unflattener<T>,P:BytePort> FlatPort<T, U, P>: GenericPort<T> {
}
}
else {
die!(~"flatpipe: unrecognized command");
fail!(~"flatpipe: unrecognized command");
}
}
}
@ -480,7 +480,7 @@ pub mod flatteners {
Ok(move json) => {
json::Decoder(move json)
}
Err(e) => die!(fmt!("flatpipe: can't parse json: %?", e))
Err(e) => fail!(fmt!("flatpipe: can't parse json: %?", e))
}
}
}

View File

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

View File

@ -349,7 +349,7 @@ fn opt_vals(mm: &Matches, nm: &str) -> ~[Optval] {
Some(id) => mm.vals[id],
None => {
error!("No option '%s' defined", nm);
die!()
fail!()
}
};
}
@ -385,7 +385,7 @@ pub fn opts_present(mm: &Matches, names: &[~str]) -> bool {
* argument
*/
pub fn opt_str(mm: &Matches, nm: &str) -> ~str {
return match opt_val(mm, nm) { Val(copy s) => s, _ => die!() };
return match opt_val(mm, nm) { Val(copy s) => s, _ => fail!() };
}
/**
@ -401,7 +401,7 @@ pub fn opts_str(mm: &Matches, names: &[~str]) -> ~str {
_ => ()
}
}
die!();
fail!();
}
@ -551,7 +551,7 @@ pub mod groups {
match ((*lopt).short_name.len(),
(*lopt).long_name.len()) {
(0,0) => die!(~"this long-format option was given no name"),
(0,0) => fail!(~"this long-format option was given no name"),
(0,_) => ~[Opt {name: Long(((*lopt).long_name)),
hasarg: (*lopt).hasarg,
@ -568,7 +568,7 @@ pub mod groups {
hasarg: (*lopt).hasarg,
occur: (*lopt).occur}],
(_,_) => die!(~"something is wrong with the long-form opt")
(_,_) => fail!(~"something is wrong with the long-form opt")
}
}
@ -599,7 +599,7 @@ pub mod groups {
row += match short_name.len() {
0 => ~"",
1 => ~"-" + short_name + " ",
_ => die!(~"the short name should only be 1 char long"),
_ => fail!(~"the short name should only be 1 char long"),
};
// long option
@ -669,7 +669,7 @@ mod tests {
assert (opt_present(m, ~"test"));
assert (opt_str(m, ~"test") == ~"20");
}
_ => { die!(~"test_reqopt_long failed"); }
_ => { fail!(~"test_reqopt_long failed"); }
}
}
@ -680,7 +680,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Err(copy f) => check_fail_type(f, OptionMissing_),
_ => die!()
_ => fail!()
}
}
@ -691,7 +691,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Err(copy f) => check_fail_type(f, ArgumentMissing_),
_ => die!()
_ => fail!()
}
}
@ -702,7 +702,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Err(copy f) => check_fail_type(f, OptionDuplicated_),
_ => die!()
_ => fail!()
}
}
@ -716,7 +716,7 @@ mod tests {
assert (opt_present(m, ~"t"));
assert (opt_str(m, ~"t") == ~"20");
}
_ => die!()
_ => fail!()
}
}
@ -727,7 +727,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Err(copy f) => check_fail_type(f, OptionMissing_),
_ => die!()
_ => fail!()
}
}
@ -738,7 +738,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Err(copy f) => check_fail_type(f, ArgumentMissing_),
_ => die!()
_ => fail!()
}
}
@ -749,7 +749,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Err(copy f) => check_fail_type(f, OptionDuplicated_),
_ => die!()
_ => fail!()
}
}
@ -765,7 +765,7 @@ mod tests {
assert (opt_present(m, ~"test"));
assert (opt_str(m, ~"test") == ~"20");
}
_ => die!()
_ => fail!()
}
}
@ -776,7 +776,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Ok(ref m) => assert (!opt_present(m, ~"test")),
_ => die!()
_ => fail!()
}
}
@ -787,7 +787,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Err(copy f) => check_fail_type(f, ArgumentMissing_),
_ => die!()
_ => fail!()
}
}
@ -798,7 +798,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Err(copy f) => check_fail_type(f, OptionDuplicated_),
_ => die!()
_ => fail!()
}
}
@ -812,7 +812,7 @@ mod tests {
assert (opt_present(m, ~"t"));
assert (opt_str(m, ~"t") == ~"20");
}
_ => die!()
_ => fail!()
}
}
@ -823,7 +823,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Ok(ref m) => assert (!opt_present(m, ~"t")),
_ => die!()
_ => fail!()
}
}
@ -834,7 +834,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Err(copy f) => check_fail_type(f, ArgumentMissing_),
_ => die!()
_ => fail!()
}
}
@ -845,7 +845,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Err(copy f) => check_fail_type(f, OptionDuplicated_),
_ => die!()
_ => fail!()
}
}
@ -858,7 +858,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Ok(ref m) => assert (opt_present(m, ~"test")),
_ => die!()
_ => fail!()
}
}
@ -869,7 +869,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Ok(ref m) => assert (!opt_present(m, ~"test")),
_ => die!()
_ => fail!()
}
}
@ -883,7 +883,7 @@ mod tests {
log(error, fail_str(f));
check_fail_type(f, UnexpectedArgument_);
}
_ => die!()
_ => fail!()
}
}
@ -894,7 +894,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Err(copy f) => check_fail_type(f, OptionDuplicated_),
_ => die!()
_ => fail!()
}
}
@ -905,7 +905,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Ok(ref m) => assert (opt_present(m, ~"t")),
_ => die!()
_ => fail!()
}
}
@ -916,7 +916,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Ok(ref m) => assert (!opt_present(m, ~"t")),
_ => die!()
_ => fail!()
}
}
@ -931,7 +931,7 @@ mod tests {
assert (m.free[0] == ~"20");
}
_ => die!()
_ => fail!()
}
}
@ -942,7 +942,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Err(copy f) => check_fail_type(f, OptionDuplicated_),
_ => die!()
_ => fail!()
}
}
@ -956,7 +956,7 @@ mod tests {
Ok(ref m) => {
assert (opt_count(m, ~"v") == 1);
}
_ => die!()
_ => fail!()
}
}
@ -969,7 +969,7 @@ mod tests {
Ok(ref m) => {
assert (opt_count(m, ~"v") == 2);
}
_ => die!()
_ => fail!()
}
}
@ -982,7 +982,7 @@ mod tests {
Ok(ref m) => {
assert (opt_count(m, ~"v") == 2);
}
_ => die!()
_ => fail!()
}
}
@ -995,7 +995,7 @@ mod tests {
Ok(ref m) => {
assert (opt_count(m, ~"verbose") == 1);
}
_ => die!()
_ => fail!()
}
}
@ -1008,7 +1008,7 @@ mod tests {
Ok(ref m) => {
assert (opt_count(m, ~"verbose") == 2);
}
_ => die!()
_ => fail!()
}
}
@ -1023,7 +1023,7 @@ mod tests {
assert (opt_present(m, ~"test"));
assert (opt_str(m, ~"test") == ~"20");
}
_ => die!()
_ => fail!()
}
}
@ -1034,7 +1034,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Ok(ref m) => assert (!opt_present(m, ~"test")),
_ => die!()
_ => fail!()
}
}
@ -1045,7 +1045,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Err(copy f) => check_fail_type(f, ArgumentMissing_),
_ => die!()
_ => fail!()
}
}
@ -1062,7 +1062,7 @@ mod tests {
assert (pair[0] == ~"20");
assert (pair[1] == ~"30");
}
_ => die!()
_ => fail!()
}
}
@ -1076,7 +1076,7 @@ mod tests {
assert (opt_present(m, ~"t"));
assert (opt_str(m, ~"t") == ~"20");
}
_ => die!()
_ => fail!()
}
}
@ -1087,7 +1087,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Ok(ref m) => assert (!opt_present(m, ~"t")),
_ => die!()
_ => fail!()
}
}
@ -1098,7 +1098,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Err(copy f) => check_fail_type(f, ArgumentMissing_),
_ => die!()
_ => fail!()
}
}
@ -1115,7 +1115,7 @@ mod tests {
assert (pair[0] == ~"20");
assert (pair[1] == ~"30");
}
_ => die!()
_ => fail!()
}
}
@ -1126,7 +1126,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Err(copy f) => check_fail_type(f, UnrecognizedOption_),
_ => die!()
_ => fail!()
}
}
@ -1137,7 +1137,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Err(copy f) => check_fail_type(f, UnrecognizedOption_),
_ => die!()
_ => fail!()
}
}
@ -1169,7 +1169,7 @@ mod tests {
assert (pair[1] == ~"-60 70");
assert (!opt_present(m, ~"notpresent"));
}
_ => die!()
_ => fail!()
}
}
@ -1179,7 +1179,7 @@ mod tests {
let opts = ~[optopt(~"e"), optopt(~"encrypt")];
let matches = &match getopts(args, opts) {
result::Ok(move m) => m,
result::Err(_) => die!()
result::Err(_) => fail!()
};
assert opts_present(matches, ~[~"e"]);
assert opts_present(matches, ~[~"encrypt"]);
@ -1200,7 +1200,7 @@ mod tests {
let opts = ~[optmulti(~"L"), optmulti(~"M")];
let matches = &match getopts(args, opts) {
result::Ok(move m) => m,
result::Err(_) => die!()
result::Err(_) => fail!()
};
assert opts_present(matches, ~[~"L"]);
assert opts_str(matches, ~[~"L"]) == ~"foo";

View File

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

View File

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

View File

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

View File

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

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