1
Fork 0

Use static string with fail!() and remove fail!(fmt!())

fail!() used to require owned strings but can handle static strings
now. Also, it can pass its arguments to fmt!() on its own, no need for
the caller to call fmt!() itself.
This commit is contained in:
Björn Steinbrink 2013-05-06 00:18:51 +02:00
parent 84745b483f
commit bdc182cc41
177 changed files with 546 additions and 560 deletions

View file

@ -2386,9 +2386,9 @@ enum List<X> { Nil, Cons(X, @List<X>) }
let x: List<int> = Cons(10, @Cons(11, @Nil)); let x: List<int> = Cons(10, @Cons(11, @Nil));
match x { match x {
Cons(_, @Nil) => fail!(~"singleton list"), Cons(_, @Nil) => fail!("singleton list"),
Cons(*) => return, Cons(*) => return,
Nil => fail!(~"empty list") Nil => fail!("empty list")
} }
~~~~ ~~~~

View file

@ -223,7 +223,7 @@ match x {
// complicated stuff goes here // complicated stuff goes here
return result + val; return result + val;
}, },
_ => fail!(~"Didn't get good_2") _ => fail!("Didn't get good_2")
} }
} }
_ => return 0 // default value _ => return 0 // default value
@ -265,7 +265,7 @@ macro_rules! biased_match (
biased_match!((x) ~ (good_1(g1, val)) else { return 0 }; biased_match!((x) ~ (good_1(g1, val)) else { return 0 };
binds g1, val ) binds g1, val )
biased_match!((g1.body) ~ (good_2(result) ) biased_match!((g1.body) ~ (good_2(result) )
else { fail!(~"Didn't get good_2") }; else { fail!("Didn't get good_2") };
binds result ) binds result )
// complicated stuff goes here // complicated stuff goes here
return result + val; return result + val;
@ -366,7 +366,7 @@ macro_rules! biased_match (
# fn f(x: t1) -> uint { # fn f(x: t1) -> uint {
biased_match!( biased_match!(
(x) ~ (good_1(g1, val)) else { return 0 }; (x) ~ (good_1(g1, val)) else { return 0 };
(g1.body) ~ (good_2(result) ) else { fail!(~"Didn't get good_2") }; (g1.body) ~ (good_2(result) ) else { fail!("Didn't get good_2") };
binds val, result ) binds val, result )
// complicated stuff goes here // complicated stuff goes here
return result + val; return result + val;

View file

@ -325,7 +325,7 @@ let result: Result<int, ()> = do task::try {
if some_condition() { if some_condition() {
calculate_result() calculate_result()
} else { } else {
fail!(~"oops!"); fail!("oops!");
} }
}; };
assert!(result.is_err()); assert!(result.is_err());

View file

@ -151,7 +151,7 @@ pub fn str_mode(s: ~str) -> mode {
~"run-pass" => mode_run_pass, ~"run-pass" => mode_run_pass,
~"pretty" => mode_pretty, ~"pretty" => mode_pretty,
~"debug-info" => mode_debug_info, ~"debug-info" => mode_debug_info,
_ => fail!(~"invalid mode") _ => fail!("invalid mode")
} }
} }
@ -169,7 +169,7 @@ pub fn run_tests(config: config) {
let opts = test_opts(config); let opts = test_opts(config);
let tests = make_tests(config); let tests = make_tests(config);
let res = test::run_tests_console(&opts, tests); let res = test::run_tests_console(&opts, tests);
if !res { fail!(~"Some tests failed"); } if !res { fail!("Some tests failed"); }
} }
pub fn test_opts(config: config) -> test::TestOpts { pub fn test_opts(config: config) -> test::TestOpts {

View file

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

View file

@ -561,7 +561,7 @@ fn compose_and_run_compiler(
fn ensure_dir(path: &Path) { fn ensure_dir(path: &Path) {
if os::path_is_dir(path) { return; } if os::path_is_dir(path) { return; }
if !os::make_dir(path, 0x1c0i32) { if !os::make_dir(path, 0x1c0i32) {
fail!(fmt!("can't make dir %s", path.to_str())); fail!("can't make dir %s", path.to_str());
} }
} }

View file

@ -46,7 +46,7 @@ pub impl<T> Cell<T> {
fn take(&self) -> T { fn take(&self) -> T {
let this = unsafe { transmute_mut(self) }; let this = unsafe { transmute_mut(self) };
if this.is_empty() { if this.is_empty() {
fail!(~"attempt to take an empty cell"); fail!("attempt to take an empty cell");
} }
replace(&mut this.value, None).unwrap() replace(&mut this.value, None).unwrap()
@ -56,7 +56,7 @@ pub impl<T> Cell<T> {
fn put_back(&self, value: T) { fn put_back(&self, value: T) {
let this = unsafe { transmute_mut(self) }; let this = unsafe { transmute_mut(self) };
if !this.is_empty() { if !this.is_empty() {
fail!(~"attempt to put a value back into a full cell"); fail!("attempt to put a value back into a full cell");
} }
this.value = Some(value); this.value = Some(value);
} }

View file

@ -145,7 +145,7 @@ pub fn is_digit_radix(c: char, radix: uint) -> bool {
#[inline] #[inline]
pub fn to_digit(c: char, radix: uint) -> Option<uint> { pub fn to_digit(c: char, radix: uint) -> Option<uint> {
if radix > 36 { if radix > 36 {
fail!(fmt!("to_digit: radix %? is to high (maximum 36)", radix)); fail!("to_digit: radix %? is to high (maximum 36)", radix);
} }
let val = match c { let val = match c {
'0' .. '9' => c as uint - ('0' as uint), '0' .. '9' => c as uint - ('0' as uint),
@ -168,7 +168,7 @@ pub fn to_digit(c: char, radix: uint) -> Option<uint> {
#[inline] #[inline]
pub fn from_digit(num: uint, radix: uint) -> Option<char> { pub fn from_digit(num: uint, radix: uint) -> Option<char> {
if radix > 36 { if radix > 36 {
fail!(fmt!("from_digit: radix %? is to high (maximum 36)", num)); fail!("from_digit: radix %? is to high (maximum 36)", num);
} }
if num < radix { if num < radix {
if num < 10 { if num < 10 {
@ -241,7 +241,7 @@ pub fn len_utf8_bytes(c: char) -> uint {
else if code < max_two_b { 2u } else if code < max_two_b { 2u }
else if code < max_three_b { 3u } else if code < max_three_b { 3u }
else if code < max_four_b { 4u } else if code < max_four_b { 4u }
else { fail!(~"invalid character!") } else { fail!("invalid character!") }
} }
#[cfg(not(test))] #[cfg(not(test))]

View file

@ -210,7 +210,7 @@ impl<T: Owned> Peekable<T> for Port<T> {
let mut endp = replace(self_endp, None); let mut endp = replace(self_endp, None);
let peek = match endp { let peek = match endp {
Some(ref mut endp) => peek(endp), Some(ref mut endp) => peek(endp),
None => fail!(~"peeking empty stream") None => fail!("peeking empty stream")
}; };
*self_endp = endp; *self_endp = endp;
peek peek
@ -222,7 +222,7 @@ impl<T: Owned> Selectable for Port<T> {
fn header(&mut self) -> *mut PacketHeader { fn header(&mut self) -> *mut PacketHeader {
match self.endp { match self.endp {
Some(ref mut endp) => endp.header(), Some(ref mut endp) => endp.header(),
None => fail!(~"peeking empty stream") None => fail!("peeking empty stream")
} }
} }
} }
@ -522,7 +522,7 @@ pub fn select2i<A:Selectable, B:Selectable>(a: &mut A, b: &mut B)
match wait_many(endpoints) { match wait_many(endpoints) {
0 => Left(()), 0 => Left(()),
1 => Right(()), 1 => Right(()),
_ => fail!(~"wait returned unexpected index"), _ => fail!("wait returned unexpected index"),
} }
} }

View file

@ -135,7 +135,7 @@ pub fn unwrap_left<T,U>(eith: Either<T,U>) -> T {
match eith { match eith {
Left(x) => x, Left(x) => x,
Right(_) => fail!(~"either::unwrap_left Right") Right(_) => fail!("either::unwrap_left Right")
} }
} }
@ -145,7 +145,7 @@ pub fn unwrap_right<T,U>(eith: Either<T,U>) -> U {
match eith { match eith {
Right(x) => x, Right(x) => x,
Left(_) => fail!(~"either::unwrap_right Left") Left(_) => fail!("either::unwrap_right Left")
} }
} }

View file

@ -200,7 +200,7 @@ priv impl<K:Hash + Eq,V> HashMap<K, V> {
fn value_for_bucket<'a>(&'a self, idx: uint) -> &'a V { fn value_for_bucket<'a>(&'a self, idx: uint) -> &'a V {
match self.buckets[idx] { match self.buckets[idx] {
Some(ref bkt) => &bkt.value, Some(ref bkt) => &bkt.value,
None => fail!(~"HashMap::find: internal logic error"), None => fail!("HashMap::find: internal logic error"),
} }
} }
@ -217,7 +217,7 @@ priv impl<K:Hash + Eq,V> HashMap<K, V> {
/// True if there was no previous entry with that key /// True if there was no previous entry with that key
fn insert_internal(&mut self, hash: uint, k: K, v: V) -> Option<V> { fn insert_internal(&mut self, hash: uint, k: K, v: V) -> Option<V> {
match self.bucket_for_key_with_hash(hash, &k) { match self.bucket_for_key_with_hash(hash, &k) {
TableFull => { fail!(~"Internal logic error"); } TableFull => { fail!("Internal logic error"); }
FoundHole(idx) => { FoundHole(idx) => {
debug!("insert fresh (%?->%?) at idx %?, hash %?", debug!("insert fresh (%?->%?) at idx %?, hash %?",
k, v, idx, hash); k, v, idx, hash);
@ -230,7 +230,7 @@ priv impl<K:Hash + Eq,V> HashMap<K, V> {
debug!("insert overwrite (%?->%?) at idx %?, hash %?", debug!("insert overwrite (%?->%?) at idx %?, hash %?",
k, v, idx, hash); k, v, idx, hash);
match self.buckets[idx] { match self.buckets[idx] {
None => { fail!(~"insert_internal: Internal logic error") } None => { fail!("insert_internal: Internal logic error") }
Some(ref mut b) => { Some(ref mut b) => {
b.hash = hash; b.hash = hash;
b.key = k; b.key = k;
@ -500,7 +500,7 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> {
let hash = k.hash_keyed(self.k0, self.k1) as uint; let hash = k.hash_keyed(self.k0, self.k1) as uint;
let idx = match self.bucket_for_key_with_hash(hash, &k) { let idx = match self.bucket_for_key_with_hash(hash, &k) {
TableFull => fail!(~"Internal logic error"), TableFull => fail!("Internal logic error"),
FoundEntry(idx) => idx, FoundEntry(idx) => idx,
FoundHole(idx) => { FoundHole(idx) => {
self.buckets[idx] = Some(Bucket{hash: hash, key: k, self.buckets[idx] = Some(Bucket{hash: hash, key: k,
@ -531,7 +531,7 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> {
let hash = k.hash_keyed(self.k0, self.k1) as uint; let hash = k.hash_keyed(self.k0, self.k1) as uint;
let idx = match self.bucket_for_key_with_hash(hash, &k) { let idx = match self.bucket_for_key_with_hash(hash, &k) {
TableFull => fail!(~"Internal logic error"), TableFull => fail!("Internal logic error"),
FoundEntry(idx) => idx, FoundEntry(idx) => idx,
FoundHole(idx) => { FoundHole(idx) => {
self.buckets[idx] = Some(Bucket{hash: hash, key: k, self.buckets[idx] = Some(Bucket{hash: hash, key: k,
@ -560,7 +560,7 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> {
let hash = k.hash_keyed(self.k0, self.k1) as uint; let hash = k.hash_keyed(self.k0, self.k1) as uint;
let idx = match self.bucket_for_key_with_hash(hash, &k) { let idx = match self.bucket_for_key_with_hash(hash, &k) {
TableFull => fail!(~"Internal logic error"), TableFull => fail!("Internal logic error"),
FoundEntry(idx) => idx, FoundEntry(idx) => idx,
FoundHole(idx) => { FoundHole(idx) => {
let v = f(&k); let v = f(&k);
@ -592,7 +592,7 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> {
let hash = k.hash_keyed(self.k0, self.k1) as uint; let hash = k.hash_keyed(self.k0, self.k1) as uint;
let idx = match self.bucket_for_key_with_hash(hash, &k) { let idx = match self.bucket_for_key_with_hash(hash, &k) {
TableFull => fail!(~"Internal logic error"), TableFull => fail!("Internal logic error"),
FoundEntry(idx) => idx, FoundEntry(idx) => idx,
FoundHole(idx) => { FoundHole(idx) => {
let v = f(&k); let v = f(&k);
@ -623,7 +623,7 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> {
fn get<'a>(&'a self, k: &K) -> &'a V { fn get<'a>(&'a self, k: &K) -> &'a V {
match self.find(k) { match self.find(k) {
Some(v) => v, Some(v) => v,
None => fail!(fmt!("No entry found for key: %?", k)), None => fail!("No entry found for key: %?", k),
} }
} }

View file

@ -132,15 +132,15 @@ fn test_tls_modify() {
fn my_key(_x: @~str) { } fn my_key(_x: @~str) { }
local_data_modify(my_key, |data| { local_data_modify(my_key, |data| {
match data { match data {
Some(@ref val) => fail!(~"unwelcome value: " + *val), Some(@ref val) => fail!("unwelcome value: %s", *val),
None => Some(@~"first data") None => Some(@~"first data")
} }
}); });
local_data_modify(my_key, |data| { local_data_modify(my_key, |data| {
match data { match data {
Some(@~"first data") => Some(@~"next data"), Some(@~"first data") => Some(@~"next data"),
Some(@ref val) => fail!(~"wrong value: " + *val), Some(@ref val) => fail!("wrong value: %s", *val),
None => fail!(~"missing value") None => fail!("missing value")
} }
}); });
assert!(*(local_data_pop(my_key).get()) == ~"next data"); assert!(*(local_data_pop(my_key).get()) == ~"next data");
@ -223,4 +223,4 @@ fn test_static_pointer() {
static VALUE: int = 0; static VALUE: int = 0;
local_data_set(key, @&VALUE); local_data_set(key, @&VALUE);
} }
} }

View file

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

View file

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

View file

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

View file

@ -89,7 +89,7 @@ pub fn gt(x: T, y: T) -> bool { x > y }
pub fn _range_step(start: T, stop: T, step: T, it: &fn(T) -> bool) -> bool { pub fn _range_step(start: T, stop: T, step: T, it: &fn(T) -> bool) -> bool {
let mut i = start; let mut i = start;
if step == 0 { if step == 0 {
fail!(~"range_step called with step == 0"); fail!("range_step called with step == 0");
} else if step > 0 { // ascending } else if step > 0 { // ascending
while i < stop { while i < stop {
if !it(i) { return false; } if !it(i) { return false; }
@ -923,16 +923,16 @@ mod tests {
// None of the `fail`s should execute. // None of the `fail`s should execute.
for range(10,0) |_i| { for range(10,0) |_i| {
fail!(~"unreachable"); fail!("unreachable");
} }
for range_rev(0,10) |_i| { for range_rev(0,10) |_i| {
fail!(~"unreachable"); fail!("unreachable");
} }
for range_step(10,0,1) |_i| { for range_step(10,0,1) |_i| {
fail!(~"unreachable"); fail!("unreachable");
} }
for range_step(0,10,-1) |_i| { for range_step(0,10,-1) |_i| {
fail!(~"unreachable"); fail!("unreachable");
} }
} }

View file

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

View file

@ -57,7 +57,7 @@ pub fn _range_step(start: T,
it: &fn(T) -> bool) -> bool { it: &fn(T) -> bool) -> bool {
let mut i = start; let mut i = start;
if step == 0 { if step == 0 {
fail!(~"range_step called with step == 0"); fail!("range_step called with step == 0");
} }
if step >= 0 { if step >= 0 {
while i < stop { while i < stop {
@ -630,16 +630,16 @@ mod tests {
// None of the `fail`s should execute. // None of the `fail`s should execute.
for range(0,0) |_i| { for range(0,0) |_i| {
fail!(~"unreachable"); fail!("unreachable");
} }
for range_rev(0,0) |_i| { for range_rev(0,0) |_i| {
fail!(~"unreachable"); fail!("unreachable");
} }
for range_step(10,0,1) |_i| { for range_step(10,0,1) |_i| {
fail!(~"unreachable"); fail!("unreachable");
} }
for range_step(0,1,-10) |_i| { for range_step(0,1,-10) |_i| {
fail!(~"unreachable"); fail!("unreachable");
} }
} }

View file

@ -269,7 +269,7 @@ pub fn min<A:Copy + Ord,IA:BaseIter<A>>(this: &IA) -> A {
} }
} { } {
Some(val) => val, Some(val) => val,
None => fail!(~"min called on empty iterator") None => fail!("min called on empty iterator")
} }
} }
@ -284,7 +284,7 @@ pub fn max<A:Copy + Ord,IA:BaseIter<A>>(this: &IA) -> A {
} }
} { } {
Some(val) => val, Some(val) => val,
None => fail!(~"max called on empty iterator") None => fail!("max called on empty iterator")
} }
} }

View file

@ -265,7 +265,7 @@ pub impl<T> Option<T> {
fn get_ref<'a>(&'a self) -> &'a T { fn get_ref<'a>(&'a self) -> &'a T {
match *self { match *self {
Some(ref x) => x, Some(ref x) => x,
None => fail!(~"option::get_ref none") None => fail!("option::get_ref none")
} }
} }
@ -287,7 +287,7 @@ pub impl<T> Option<T> {
fn get_mut_ref<'a>(&'a mut self) -> &'a mut T { fn get_mut_ref<'a>(&'a mut self) -> &'a mut T {
match *self { match *self {
Some(ref mut x) => x, Some(ref mut x) => x,
None => fail!(~"option::get_mut_ref none") None => fail!("option::get_mut_ref none")
} }
} }
@ -311,7 +311,7 @@ pub impl<T> Option<T> {
*/ */
match self { match self {
Some(x) => x, Some(x) => x,
None => fail!(~"option::unwrap none") None => fail!("option::unwrap none")
} }
} }
@ -325,7 +325,7 @@ pub impl<T> Option<T> {
*/ */
#[inline(always)] #[inline(always)]
fn swap_unwrap(&mut self) -> T { fn swap_unwrap(&mut self) -> T {
if self.is_none() { fail!(~"option::swap_unwrap none") } if self.is_none() { fail!("option::swap_unwrap none") }
util::replace(self, None).unwrap() util::replace(self, None).unwrap()
} }
@ -365,7 +365,7 @@ pub impl<T:Copy> Option<T> {
fn get(self) -> T { fn get(self) -> T {
match self { match self {
Some(copy x) => return x, Some(copy x) => return x,
None => fail!(~"option::get none") None => fail!("option::get none")
} }
} }

View file

@ -178,8 +178,8 @@ pub fn env() -> ~[(~str,~str)] {
}; };
let ch = GetEnvironmentStringsA(); let ch = GetEnvironmentStringsA();
if (ch as uint == 0) { if (ch as uint == 0) {
fail!(fmt!("os::env() failure getting env string from OS: %s", fail!("os::env() failure getting env string from OS: %s",
os::last_os_error())); os::last_os_error());
} }
let mut curr_ptr: uint = ch as uint; let mut curr_ptr: uint = ch as uint;
let mut result = ~[]; let mut result = ~[];
@ -201,8 +201,8 @@ pub fn env() -> ~[(~str,~str)] {
} }
let environ = rust_env_pairs(); let environ = rust_env_pairs();
if (environ as uint == 0) { if (environ as uint == 0) {
fail!(fmt!("os::env() failure getting env string from OS: %s", fail!("os::env() failure getting env string from OS: %s",
os::last_os_error())); os::last_os_error());
} }
let mut result = ~[]; let mut result = ~[];
ptr::array_each(environ, |e| { ptr::array_each(environ, |e| {
@ -744,8 +744,7 @@ pub fn list_dir(p: &Path) -> ~[~str] {
while more_files != 0 { while more_files != 0 {
let fp_buf = rust_list_dir_wfd_fp_buf(wfd_ptr); let fp_buf = rust_list_dir_wfd_fp_buf(wfd_ptr);
if fp_buf as uint == 0 { if fp_buf as uint == 0 {
fail!(~"os::list_dir() failure:"+ fail!("os::list_dir() failure: got null ptr from wfd");
~" got null ptr from wfd");
} }
else { else {
let fp_vec = vec::from_buf( let fp_vec = vec::from_buf(
@ -1062,7 +1061,7 @@ pub fn last_os_error() -> ~str {
let err = strerror_r(errno() as c_int, &mut buf[0], let err = strerror_r(errno() as c_int, &mut buf[0],
TMPBUF_SZ as size_t); TMPBUF_SZ as size_t);
if err < 0 { if err < 0 {
fail!(~"strerror_r failure"); fail!("strerror_r failure");
} }
str::raw::from_c_str(&buf[0]) str::raw::from_c_str(&buf[0])
@ -1100,7 +1099,7 @@ pub fn last_os_error() -> ~str {
&mut buf[0], TMPBUF_SZ as DWORD, &mut buf[0], TMPBUF_SZ as DWORD,
ptr::null()); ptr::null());
if res == 0 { if res == 0 {
fail!(fmt!("[%?] FormatMessage failure", errno())); fail!("[%?] FormatMessage failure", errno());
} }
str::raw::from_c_str(&buf[0]) str::raw::from_c_str(&buf[0])
@ -1304,7 +1303,7 @@ pub fn glob(pattern: &str) -> ~[Path] {
/// Returns a vector of Path objects that match the given glob pattern /// Returns a vector of Path objects that match the given glob pattern
#[cfg(target_os = "win32")] #[cfg(target_os = "win32")]
pub fn glob(pattern: &str) -> ~[Path] { pub fn glob(pattern: &str) -> ~[Path] {
fail!(~"glob() is unimplemented on Windows") fail!("glob() is unimplemented on Windows")
} }
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
@ -1638,7 +1637,7 @@ mod tests {
let in_mode = in.get_mode(); let in_mode = in.get_mode();
let rs = os::copy_file(&in, &out); let rs = os::copy_file(&in, &out);
if (!os::path_exists(&in)) { if (!os::path_exists(&in)) {
fail!(fmt!("%s doesn't exist", in.to_str())); fail!("%s doesn't exist", in.to_str());
} }
assert!((rs)); assert!((rs));
let rslt = run::run_program(~"diff", ~[in.to_str(), out.to_str()]); let rslt = run::run_program(~"diff", ~[in.to_str(), out.to_str()]);

View file

@ -281,7 +281,7 @@ fn wait_event(this: *rust_task) -> *libc::c_void {
let killed = rustrt::task_wait_event(this, &mut event); let killed = rustrt::task_wait_event(this, &mut event);
if killed && !task::failing() { if killed && !task::failing() {
fail!(~"killed") fail!("killed")
} }
event event
} }
@ -365,7 +365,7 @@ pub fn send<T,Tbuffer>(mut p: SendPacketBuffered<T,Tbuffer>,
//unsafe { forget(p); } //unsafe { forget(p); }
return true; return true;
} }
Full => fail!(~"duplicate send"), Full => fail!("duplicate send"),
Blocked => { Blocked => {
debug!("waking up task for %?", p_); debug!("waking up task for %?", p_);
let old_task = swap_task(&mut p.header.blocked_task, ptr::null()); let old_task = swap_task(&mut p.header.blocked_task, ptr::null());
@ -478,7 +478,7 @@ fn try_recv_<T:Owned>(p: &mut Packet<T>) -> Option<T> {
debug!("woke up, p.state = %?", copy p.header.state); debug!("woke up, p.state = %?", copy p.header.state);
} }
Blocked => if first { Blocked => if first {
fail!(~"blocking on already blocked packet") fail!("blocking on already blocked packet")
}, },
Full => { Full => {
let payload = replace(&mut p.payload, None); let payload = replace(&mut p.payload, None);
@ -514,7 +514,7 @@ pub fn peek<T:Owned,Tb:Owned>(p: &mut RecvPacketBuffered<T, Tb>) -> bool {
unsafe { unsafe {
match (*p.header()).state { match (*p.header()).state {
Empty | Terminated => false, Empty | Terminated => false,
Blocked => fail!(~"peeking on blocked packet"), Blocked => fail!("peeking on blocked packet"),
Full => true Full => true
} }
} }
@ -543,7 +543,7 @@ fn sender_terminate<T:Owned>(p: *mut Packet<T>) {
} }
Full => { Full => {
// This is impossible // This is impossible
fail!(~"you dun goofed") fail!("you dun goofed")
} }
Terminated => { Terminated => {
assert!(p.header.blocked_task.is_null()); assert!(p.header.blocked_task.is_null());
@ -609,7 +609,7 @@ pub fn wait_many<T: Selectable>(pkts: &mut [T]) -> uint {
(*p).state = old; (*p).state = old;
break; break;
} }
Blocked => fail!(~"blocking on blocked packet"), Blocked => fail!("blocking on blocked packet"),
Empty => () Empty => ()
} }
} }
@ -704,7 +704,7 @@ pub impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> {
let header = ptr::to_mut_unsafe_ptr(&mut packet.header); let header = ptr::to_mut_unsafe_ptr(&mut packet.header);
header header
}, },
None => fail!(~"packet already consumed") None => fail!("packet already consumed")
} }
} }
@ -758,7 +758,7 @@ impl<T:Owned,Tbuffer:Owned> Selectable for RecvPacketBuffered<T, Tbuffer> {
let header = ptr::to_mut_unsafe_ptr(&mut packet.header); let header = ptr::to_mut_unsafe_ptr(&mut packet.header);
header header
}, },
None => fail!(~"packet already consumed") None => fail!("packet already consumed")
} }
} }
} }
@ -816,7 +816,7 @@ pub fn select2<A:Owned,Ab:Owned,B:Owned,Bb:Owned>(
match i { match i {
0 => Left((try_recv(a), b)), 0 => Left((try_recv(a), b)),
1 => Right((a, try_recv(b))), 1 => Right((a, try_recv(b))),
_ => fail!(~"select2 return an invalid packet") _ => fail!("select2 return an invalid packet")
} }
} }
@ -840,7 +840,7 @@ pub fn select2i<A:Selectable,B:Selectable>(a: &mut A, b: &mut B)
match wait_many(endpoints) { match wait_many(endpoints) {
0 => Left(()), 0 => Left(()),
1 => Right(()), 1 => Right(()),
_ => fail!(~"wait returned unexpected index") _ => fail!("wait returned unexpected index")
} }
} }

View file

@ -176,7 +176,7 @@ pub fn ref_eq<'a,'b,T>(thing: &'a T, other: &'b T) -> bool {
pub unsafe fn array_each_with_len<T>(arr: **T, len: uint, cb: &fn(*T)) { pub unsafe fn array_each_with_len<T>(arr: **T, len: uint, cb: &fn(*T)) {
debug!("array_each_with_len: before iterate"); debug!("array_each_with_len: before iterate");
if (arr as uint == 0) { if (arr as uint == 0) {
fail!(~"ptr::array_each_with_len failure: arr input is null pointer"); fail!("ptr::array_each_with_len failure: arr input is null pointer");
} }
//let start_ptr = *arr; //let start_ptr = *arr;
uint::iterate(0, len, |e| { uint::iterate(0, len, |e| {
@ -198,7 +198,7 @@ pub unsafe fn array_each_with_len<T>(arr: **T, len: uint, cb: &fn(*T)) {
*/ */
pub unsafe fn array_each<T>(arr: **T, cb: &fn(*T)) { pub unsafe fn array_each<T>(arr: **T, cb: &fn(*T)) {
if (arr as uint == 0) { if (arr as uint == 0) {
fail!(~"ptr::array_each_with_len failure: arr input is null pointer"); fail!("ptr::array_each_with_len failure: arr input is null pointer");
} }
let len = buf_len(arr); let len = buf_len(arr);
debug!("array_each inferred len: %u", debug!("array_each inferred len: %u",

View file

@ -532,7 +532,7 @@ impl TyVisitor for ReprVisitor {
-> bool { -> bool {
let var_stk: &mut ~[VariantState] = self.var_stk; let var_stk: &mut ~[VariantState] = self.var_stk;
match var_stk.pop() { match var_stk.pop() {
SearchingFor(*) => fail!(~"enum value matched no variant"), SearchingFor(*) => fail!("enum value matched no variant"),
_ => true _ => true
} }
} }

View file

@ -42,7 +42,7 @@ pub fn get<T:Copy,U>(res: &Result<T, U>) -> T {
match *res { match *res {
Ok(copy t) => t, Ok(copy t) => t,
Err(ref the_err) => Err(ref the_err) =>
fail!(fmt!("get called on error result: %?", *the_err)) fail!("get called on error result: %?", *the_err)
} }
} }
@ -58,7 +58,7 @@ pub fn get_ref<'a, T, U>(res: &'a Result<T, U>) -> &'a T {
match *res { match *res {
Ok(ref t) => t, Ok(ref t) => t,
Err(ref the_err) => Err(ref the_err) =>
fail!(fmt!("get_ref called on error result: %?", *the_err)) fail!("get_ref called on error result: %?", *the_err)
} }
} }
@ -73,7 +73,7 @@ pub fn get_ref<'a, T, U>(res: &'a Result<T, U>) -> &'a T {
pub fn get_err<T, U: Copy>(res: &Result<T, U>) -> U { pub fn get_err<T, U: Copy>(res: &Result<T, U>) -> U {
match *res { match *res {
Err(copy u) => u, Err(copy u) => u,
Ok(_) => fail!(~"get_err called on ok result") Ok(_) => fail!("get_err called on ok result")
} }
} }
@ -378,7 +378,7 @@ pub fn iter_vec2<S,T,U:Copy>(ss: &[S], ts: &[T],
pub fn unwrap<T, U>(res: Result<T, U>) -> T { pub fn unwrap<T, U>(res: Result<T, U>) -> T {
match res { match res {
Ok(t) => t, Ok(t) => t,
Err(_) => fail!(~"unwrap called on an err result") Err(_) => fail!("unwrap called on an err result")
} }
} }
@ -387,7 +387,7 @@ pub fn unwrap<T, U>(res: Result<T, U>) -> T {
pub fn unwrap_err<T, U>(res: Result<T, U>) -> U { pub fn unwrap_err<T, U>(res: Result<T, U>) -> U {
match res { match res {
Err(u) => u, Err(u) => u,
Ok(_) => fail!(~"unwrap called on an ok result") Ok(_) => fail!("unwrap called on an ok result")
} }
} }

View file

@ -163,7 +163,7 @@ pub fn borrow_local_services(f: &fn(&mut LocalServices)) {
f(&mut task.local_services) f(&mut task.local_services)
} }
None => { None => {
fail!(~"no local services for schedulers yet") fail!("no local services for schedulers yet")
} }
} }
} }
@ -177,7 +177,7 @@ pub unsafe fn unsafe_borrow_local_services() -> &mut LocalServices {
transmute_mut_region(&mut task.local_services) transmute_mut_region(&mut task.local_services)
} }
None => { None => {
fail!(~"no local services for schedulers yet") fail!("no local services for schedulers yet")
} }
} }
} }

View file

@ -295,7 +295,7 @@ pub impl Scheduler {
Some(DoNothing) => { Some(DoNothing) => {
None None
} }
None => fail!(fmt!("all context switches should have a cleanup job")) None => fail!("all context switches should have a cleanup job")
}; };
// XXX: Pattern matching mutable pointers above doesn't work // XXX: Pattern matching mutable pointers above doesn't work
// because borrowck thinks the three patterns are conflicting // because borrowck thinks the three patterns are conflicting

View file

@ -205,29 +205,29 @@ fn spawn_process_internal(prog: &str, args: &[~str],
let orig_std_in = get_osfhandle(if in_fd > 0 { in_fd } else { 0 }) as HANDLE; let orig_std_in = get_osfhandle(if in_fd > 0 { in_fd } else { 0 }) as HANDLE;
if orig_std_in == INVALID_HANDLE_VALUE as HANDLE { if orig_std_in == INVALID_HANDLE_VALUE as HANDLE {
fail!(fmt!("failure in get_osfhandle: %s", os::last_os_error())); fail!("failure in get_osfhandle: %s", os::last_os_error());
} }
if DuplicateHandle(cur_proc, orig_std_in, cur_proc, &mut si.hStdInput, if DuplicateHandle(cur_proc, orig_std_in, cur_proc, &mut si.hStdInput,
0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE { 0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE {
fail!(fmt!("failure in DuplicateHandle: %s", os::last_os_error())); fail!("failure in DuplicateHandle: %s", os::last_os_error());
} }
let orig_std_out = get_osfhandle(if out_fd > 0 { out_fd } else { 1 }) as HANDLE; let orig_std_out = get_osfhandle(if out_fd > 0 { out_fd } else { 1 }) as HANDLE;
if orig_std_out == INVALID_HANDLE_VALUE as HANDLE { if orig_std_out == INVALID_HANDLE_VALUE as HANDLE {
fail!(fmt!("failure in get_osfhandle: %s", os::last_os_error())); fail!("failure in get_osfhandle: %s", os::last_os_error());
} }
if DuplicateHandle(cur_proc, orig_std_out, cur_proc, &mut si.hStdOutput, if DuplicateHandle(cur_proc, orig_std_out, cur_proc, &mut si.hStdOutput,
0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE { 0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE {
fail!(fmt!("failure in DuplicateHandle: %s", os::last_os_error())); fail!("failure in DuplicateHandle: %s", os::last_os_error());
} }
let orig_std_err = get_osfhandle(if err_fd > 0 { err_fd } else { 2 }) as HANDLE; let orig_std_err = get_osfhandle(if err_fd > 0 { err_fd } else { 2 }) as HANDLE;
if orig_std_err as HANDLE == INVALID_HANDLE_VALUE as HANDLE { if orig_std_err as HANDLE == INVALID_HANDLE_VALUE as HANDLE {
fail!(fmt!("failure in get_osfhandle: %s", os::last_os_error())); fail!("failure in get_osfhandle: %s", os::last_os_error());
} }
if DuplicateHandle(cur_proc, orig_std_err, cur_proc, &mut si.hStdError, if DuplicateHandle(cur_proc, orig_std_err, cur_proc, &mut si.hStdError,
0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE { 0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE {
fail!(fmt!("failure in DuplicateHandle: %s", os::last_os_error())); fail!("failure in DuplicateHandle: %s", os::last_os_error());
} }
let cmd = make_command_line(prog, args); let cmd = make_command_line(prog, args);
@ -252,7 +252,7 @@ fn spawn_process_internal(prog: &str, args: &[~str],
CloseHandle(si.hStdError); CloseHandle(si.hStdError);
for create_err.each |msg| { for create_err.each |msg| {
fail!(fmt!("failure in CreateProcess: %s", *msg)); fail!("failure in CreateProcess: %s", *msg);
} }
// We close the thread handle because we don't care about keeping the thread id valid, // We close the thread handle because we don't care about keeping the thread id valid,
@ -379,7 +379,7 @@ fn spawn_process_internal(prog: &str, args: &[~str],
let pid = fork(); let pid = fork();
if pid < 0 { if pid < 0 {
fail!(fmt!("failure in fork: %s", os::last_os_error())); fail!("failure in fork: %s", os::last_os_error());
} else if pid > 0 { } else if pid > 0 {
return RunProgramResult {pid: pid, handle: ptr::null()}; return RunProgramResult {pid: pid, handle: ptr::null()};
} }
@ -387,13 +387,13 @@ fn spawn_process_internal(prog: &str, args: &[~str],
rustrt::rust_unset_sigprocmask(); rustrt::rust_unset_sigprocmask();
if in_fd > 0 && dup2(in_fd, 0) == -1 { if in_fd > 0 && dup2(in_fd, 0) == -1 {
fail!(fmt!("failure in dup2(in_fd, 0): %s", os::last_os_error())); fail!("failure in dup2(in_fd, 0): %s", os::last_os_error());
} }
if out_fd > 0 && dup2(out_fd, 1) == -1 { if out_fd > 0 && dup2(out_fd, 1) == -1 {
fail!(fmt!("failure in dup2(out_fd, 1): %s", os::last_os_error())); fail!("failure in dup2(out_fd, 1): %s", os::last_os_error());
} }
if err_fd > 0 && dup2(err_fd, 2) == -1 { if err_fd > 0 && dup2(err_fd, 2) == -1 {
fail!(fmt!("failure in dup3(err_fd, 2): %s", os::last_os_error())); fail!("failure in dup3(err_fd, 2): %s", os::last_os_error());
} }
// close all other fds // close all other fds
for int::range_rev(getdtablesize() as int - 1, 2) |fd| { for int::range_rev(getdtablesize() as int - 1, 2) |fd| {
@ -403,7 +403,7 @@ fn spawn_process_internal(prog: &str, args: &[~str],
for dir.each |dir| { for dir.each |dir| {
do str::as_c_str(*dir) |dirp| { do str::as_c_str(*dir) |dirp| {
if chdir(dirp) == -1 { if chdir(dirp) == -1 {
fail!(fmt!("failure in chdir: %s", os::last_os_error())); fail!("failure in chdir: %s", os::last_os_error());
} }
} }
} }
@ -415,7 +415,7 @@ fn spawn_process_internal(prog: &str, args: &[~str],
do with_argv(prog, args) |argv| { do with_argv(prog, args) |argv| {
execvp(*argv, argv); execvp(*argv, argv);
// execvp only returns if an error occurred // execvp only returns if an error occurred
fail!(fmt!("failure in execvp: %s", os::last_os_error())); fail!("failure in execvp: %s", os::last_os_error());
} }
} }
} }
@ -646,8 +646,8 @@ pub fn program_output(prog: &str, args: &[~str]) -> ProgramOutput {
errs = s; errs = s;
} }
(n, _) => { (n, _) => {
fail!(fmt!("program_output received an unexpected file \ fail!("program_output received an unexpected file \
number: %u", n)); number: %u", n);
} }
}; };
count -= 1; count -= 1;
@ -713,14 +713,14 @@ pub fn waitpid(pid: pid_t) -> int {
let proc = OpenProcess(SYNCHRONIZE | PROCESS_QUERY_INFORMATION, FALSE, pid as DWORD); let proc = OpenProcess(SYNCHRONIZE | PROCESS_QUERY_INFORMATION, FALSE, pid as DWORD);
if proc.is_null() { if proc.is_null() {
fail!(fmt!("failure in OpenProcess: %s", os::last_os_error())); fail!("failure in OpenProcess: %s", os::last_os_error());
} }
loop { loop {
let mut status = 0; let mut status = 0;
if GetExitCodeProcess(proc, &mut status) == FALSE { if GetExitCodeProcess(proc, &mut status) == FALSE {
CloseHandle(proc); CloseHandle(proc);
fail!(fmt!("failure in GetExitCodeProcess: %s", os::last_os_error())); fail!("failure in GetExitCodeProcess: %s", os::last_os_error());
} }
if status != STILL_ACTIVE { if status != STILL_ACTIVE {
CloseHandle(proc); CloseHandle(proc);
@ -728,7 +728,7 @@ pub fn waitpid(pid: pid_t) -> int {
} }
if WaitForSingleObject(proc, INFINITE) == WAIT_FAILED { if WaitForSingleObject(proc, INFINITE) == WAIT_FAILED {
CloseHandle(proc); CloseHandle(proc);
fail!(fmt!("failure in WaitForSingleObject: %s", os::last_os_error())); fail!("failure in WaitForSingleObject: %s", os::last_os_error());
} }
} }
} }
@ -765,7 +765,7 @@ pub fn waitpid(pid: pid_t) -> int {
let mut status = 0 as c_int; let mut status = 0 as c_int;
if unsafe { waitpid(pid, &mut status, 0) } == -1 { if unsafe { waitpid(pid, &mut status, 0) } == -1 {
fail!(fmt!("failure in waitpid: %s", os::last_os_error())); fail!("failure in waitpid: %s", os::last_os_error());
} }
return if WIFEXITED(status) { return if WIFEXITED(status) {

View file

@ -1051,8 +1051,8 @@ pub fn _each_split_within<'a>(ss: &'a str,
(B, Cr, UnderLim) => { B } (B, Cr, UnderLim) => { B }
(B, Cr, OverLim) if (i - last_start + 1) > lim (B, Cr, OverLim) if (i - last_start + 1) > lim
=> fail!(fmt!("word starting with %? longer than limit!", => fail!("word starting with %? longer than limit!",
self::slice(ss, last_start, i + 1))), self::slice(ss, last_start, i + 1)),
(B, Cr, OverLim) => { slice(); slice_start = last_start; B } (B, Cr, OverLim) => { slice(); slice_start = last_start; B }
(B, Ws, UnderLim) => { last_end = i; C } (B, Ws, UnderLim) => { last_end = i; C }
(B, Ws, OverLim) => { last_end = i; slice(); A } (B, Ws, OverLim) => { last_end = i; slice(); A }

View file

@ -198,7 +198,7 @@ pub fn task() -> TaskBuilder {
priv impl TaskBuilder { priv impl TaskBuilder {
fn consume(&mut self) -> TaskBuilder { fn consume(&mut self) -> TaskBuilder {
if self.consumed { if self.consumed {
fail!(~"Cannot copy a task_builder"); // Fake move mode on self fail!("Cannot copy a task_builder"); // Fake move mode on self
} }
self.consumed = true; self.consumed = true;
let gen_body = replace(&mut self.gen_body, None); let gen_body = replace(&mut self.gen_body, None);
@ -263,7 +263,7 @@ pub impl TaskBuilder {
// sending out messages. // sending out messages.
if self.opts.notify_chan.is_some() { if self.opts.notify_chan.is_some() {
fail!(~"Can't set multiple future_results for one task!"); fail!("Can't set multiple future_results for one task!");
} }
// Construct the future and give it to the caller. // Construct the future and give it to the caller.
@ -494,7 +494,7 @@ pub fn yield() {
let task_ = rt::rust_get_task(); let task_ = rt::rust_get_task();
let killed = rt::rust_task_yield(task_); let killed = rt::rust_task_yield(task_);
if killed && !failing() { if killed && !failing() {
fail!(~"killed"); fail!("killed");
} }
} }
} }

View file

@ -569,10 +569,10 @@ pub fn spawn_raw(opts: TaskOpts, f: ~fn()) {
spawn_raw_newsched(opts, f) spawn_raw_newsched(opts, f)
} }
SchedulerContext => { SchedulerContext => {
fail!(~"can't spawn from scheduler context") fail!("can't spawn from scheduler context")
} }
GlobalContext => { GlobalContext => {
fail!(~"can't spawn from global context") fail!("can't spawn from global context")
} }
} }
} }
@ -708,7 +708,7 @@ fn spawn_raw_oldsched(mut opts: TaskOpts, f: ~fn()) {
fn new_task_in_sched(opts: SchedOpts) -> *rust_task { fn new_task_in_sched(opts: SchedOpts) -> *rust_task {
if opts.foreign_stack_size != None { if opts.foreign_stack_size != None {
fail!(~"foreign_stack_size scheduler option unimplemented"); fail!("foreign_stack_size scheduler option unimplemented");
} }
let num_threads = match opts.mode { let num_threads = match opts.mode {
@ -719,11 +719,11 @@ fn spawn_raw_oldsched(mut opts: TaskOpts, f: ~fn()) {
SingleThreaded => 1u, SingleThreaded => 1u,
ThreadPerCore => unsafe { rt::rust_num_threads() }, ThreadPerCore => unsafe { rt::rust_num_threads() },
ThreadPerTask => { ThreadPerTask => {
fail!(~"ThreadPerTask scheduling mode unimplemented") fail!("ThreadPerTask scheduling mode unimplemented")
} }
ManualThreads(threads) => { ManualThreads(threads) => {
if threads == 0u { if threads == 0u {
fail!(~"can not create a scheduler with no threads"); fail!("can not create a scheduler with no threads");
} }
threads threads
} }

View file

@ -46,7 +46,7 @@ stuff in exchange_alloc::malloc
pub unsafe fn malloc_raw(size: uint) -> *c_void { pub unsafe fn malloc_raw(size: uint) -> *c_void {
let p = c_malloc(size as size_t); let p = c_malloc(size as size_t);
if p.is_null() { if p.is_null() {
fail!(~"Failure in malloc_raw: result ptr is null"); fail!("Failure in malloc_raw: result ptr is null");
} }
p p
} }

View file

@ -198,8 +198,7 @@ pub impl<T:Owned> Exclusive<T> {
let rec = self.x.get(); let rec = self.x.get();
do (*rec).lock.lock { do (*rec).lock.lock {
if (*rec).failed { if (*rec).failed {
fail!( fail!("Poisoned exclusive - another task failed inside!");
~"Poisoned exclusive - another task failed inside!");
} }
(*rec).failed = true; (*rec).failed = true;
let result = f(&mut (*rec).data); let result = f(&mut (*rec).data);

View file

@ -171,7 +171,7 @@ fn choose_weighted_item(v: &[Item]) -> Item {
*/ */
pub fn unreachable() -> ! { pub fn unreachable() -> ! {
fail!(~"internal error: entered unreachable code"); fail!("internal error: entered unreachable code");
} }
#[cfg(test)] #[cfg(test)]

View file

@ -237,7 +237,7 @@ pub fn build_sized_opt<A>(size: Option<uint>,
/// Returns the first element of a vector /// Returns the first element of a vector
pub fn head<'r,T>(v: &'r [T]) -> &'r T { pub fn head<'r,T>(v: &'r [T]) -> &'r T {
if v.len() == 0 { fail!(~"head: empty vector") } if v.len() == 0 { fail!("head: empty vector") }
&v[0] &v[0]
} }
@ -263,7 +263,7 @@ pub fn initn<'r,T>(v: &'r [T], n: uint) -> &'r [T] {
/// Returns the last element of the slice `v`, failing if the slice is empty. /// Returns the last element of the slice `v`, failing if the slice is empty.
pub fn last<'r,T>(v: &'r [T]) -> &'r T { pub fn last<'r,T>(v: &'r [T]) -> &'r T {
if v.len() == 0 { fail!(~"last: empty vector") } if v.len() == 0 { fail!("last: empty vector") }
&v[v.len() - 1] &v[v.len() - 1]
} }
@ -587,7 +587,7 @@ pub fn consume_reverse<T>(mut v: ~[T], f: &fn(uint, v: T)) {
pub fn pop<T>(v: &mut ~[T]) -> T { pub fn pop<T>(v: &mut ~[T]) -> T {
let ln = v.len(); let ln = v.len();
if ln == 0 { if ln == 0 {
fail!(~"sorry, cannot vec::pop an empty vector") fail!("sorry, cannot vec::pop an empty vector")
} }
let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]); let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]);
unsafe { unsafe {
@ -601,7 +601,7 @@ pub fn pop<T>(v: &mut ~[T]) -> T {
pub fn pop<T>(v: &mut ~[T]) -> T { pub fn pop<T>(v: &mut ~[T]) -> T {
let ln = v.len(); let ln = v.len();
if ln == 0 { if ln == 0 {
fail!(~"sorry, cannot vec::pop an empty vector") fail!("sorry, cannot vec::pop an empty vector")
} }
let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]); let valptr = ptr::to_mut_unsafe_ptr(&mut v[ln - 1u]);
unsafe { unsafe {
@ -620,7 +620,7 @@ pub fn pop<T>(v: &mut ~[T]) -> T {
pub fn swap_remove<T>(v: &mut ~[T], index: uint) -> T { pub fn swap_remove<T>(v: &mut ~[T], index: uint) -> T {
let ln = v.len(); let ln = v.len();
if index >= ln { if index >= ln {
fail!(fmt!("vec::swap_remove - index %u >= length %u", index, ln)); fail!("vec::swap_remove - index %u >= length %u", index, ln);
} }
if index < ln - 1 { if index < ln - 1 {
swap(*v, index, ln - 1); swap(*v, index, ln - 1);

View file

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

View file

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

View file

@ -523,7 +523,7 @@ pub fn host_triple() -> ~str {
return if ht != ~"" { return if ht != ~"" {
ht ht
} else { } else {
fail!(~"rustc built without CFG_BUILD_TRIPLE") fail!("rustc built without CFG_BUILD_TRIPLE")
}; };
} }
@ -917,7 +917,7 @@ mod test {
let matches = let matches =
&match getopts(~[~"--test"], optgroups()) { &match getopts(~[~"--test"], optgroups()) {
Ok(copy m) => m, Ok(copy m) => m,
Err(copy f) => fail!(~"test_switch_implies_cfg_test: " + Err(copy f) => fail!("test_switch_implies_cfg_test: %s",
getopts::fail_str(f)) getopts::fail_str(f))
}; };
let sessopts = build_session_options( let sessopts = build_session_options(
@ -935,7 +935,7 @@ mod test {
&match getopts(~[~"--test", ~"--cfg=test"], optgroups()) { &match getopts(~[~"--test", ~"--cfg=test"], optgroups()) {
Ok(copy m) => m, Ok(copy m) => m,
Err(copy f) => { Err(copy f) => {
fail!(~"test_switch_implies_cfg_test_unless_cfg_test: " + fail!("test_switch_implies_cfg_test_unless_cfg_test: %s",
getopts::fail_str(f)); getopts::fail_str(f));
} }
}; };

View file

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

View file

@ -87,7 +87,7 @@ fn find_item(item_id: int, items: ebml::Doc) -> ebml::Doc {
fn lookup_item(item_id: int, data: @~[u8]) -> ebml::Doc { fn lookup_item(item_id: int, data: @~[u8]) -> ebml::Doc {
let items = reader::get_doc(reader::Doc(data), tag_items); let items = reader::get_doc(reader::Doc(data), tag_items);
match maybe_find_item(item_id, items) { match maybe_find_item(item_id, items) {
None => fail!(fmt!("lookup_item: id not found: %d", item_id)), None => fail!("lookup_item: id not found: %d", item_id),
Some(d) => d Some(d) => d
} }
} }
@ -139,7 +139,7 @@ fn item_family(item: ebml::Doc) -> Family {
'g' => PublicField, 'g' => PublicField,
'j' => PrivateField, 'j' => PrivateField,
'N' => InheritedField, 'N' => InheritedField,
c => fail!(fmt!("unexpected family char: %c", c)) c => fail!("unexpected family char: %c", c)
} }
} }
@ -151,7 +151,7 @@ fn item_visibility(item: ebml::Doc) -> ast::visibility {
'y' => ast::public, 'y' => ast::public,
'n' => ast::private, 'n' => ast::private,
'i' => ast::inherited, 'i' => ast::inherited,
_ => fail!(~"unknown visibility character") _ => fail!("unknown visibility character")
} }
} }
} }
@ -458,8 +458,8 @@ pub enum def_like {
fn def_like_to_def(def_like: def_like) -> ast::def { fn def_like_to_def(def_like: def_like) -> ast::def {
match def_like { match def_like {
dl_def(def) => return def, dl_def(def) => return def,
dl_impl(*) => fail!(~"found impl in def_like_to_def"), dl_impl(*) => fail!("found impl in def_like_to_def"),
dl_field => fail!(~"found field in def_like_to_def") dl_field => fail!("found field in def_like_to_def")
} }
} }
@ -677,7 +677,7 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ {
'm' => { ast::m_mutbl } 'm' => { ast::m_mutbl }
'c' => { ast::m_const } 'c' => { ast::m_const }
_ => { _ => {
fail!(fmt!("unknown mutability character: `%c`", ch as char)) fail!("unknown mutability character: `%c`", ch as char)
} }
} }
} }
@ -696,7 +696,7 @@ fn get_self_ty(item: ebml::Doc) -> ast::self_ty_ {
return ast::sty_region(None, get_mutability(string[1])); return ast::sty_region(None, get_mutability(string[1]));
} }
_ => { _ => {
fail!(fmt!("unknown self type code: `%c`", self_ty_kind as char)); fail!("unknown self type code: `%c`", self_ty_kind as char);
} }
} }
} }
@ -998,7 +998,7 @@ fn describe_def(items: ebml::Doc, id: ast::def_id) -> ~str {
if id.crate != ast::local_crate { return ~"external"; } if id.crate != ast::local_crate { return ~"external"; }
let it = match maybe_find_item(id.node, items) { let it = match maybe_find_item(id.node, items) {
Some(it) => it, Some(it) => it,
None => fail!(fmt!("describe_def: item not found %?", id)) None => fail!("describe_def: item not found %?", id)
}; };
return item_family_to_str(item_family(it)); return item_family_to_str(item_family(it));
} }
@ -1189,7 +1189,7 @@ pub fn translate_def_id(cdata: cmd, did: ast::def_id) -> ast::def_id {
match cdata.cnum_map.find(&did.crate) { match cdata.cnum_map.find(&did.crate) {
option::Some(&n) => ast::def_id { crate: n, node: did.node }, option::Some(&n) => ast::def_id { crate: n, node: did.node },
option::None => fail!(~"didn't find a crate in the cnum_map") option::None => fail!("didn't find a crate in the cnum_map")
} }
} }

View file

@ -696,7 +696,7 @@ fn purity_static_method_family(p: purity) -> char {
unsafe_fn => 'U', unsafe_fn => 'U',
pure_fn => 'P', pure_fn => 'P',
impure_fn => 'F', impure_fn => 'F',
_ => fail!(~"extern fn can't be static") _ => fail!("extern fn can't be static")
} }
} }
@ -1009,7 +1009,7 @@ fn encode_info_for_item(ecx: @EncodeContext,
ebml_w.end_tag(); ebml_w.end_tag();
} }
} }
item_mac(*) => fail!(~"item macros unimplemented") item_mac(*) => fail!("item macros unimplemented")
} }
} }
@ -1068,7 +1068,7 @@ fn encode_info_for_items(ecx: @EncodeContext,
let mut ebml_w = copy ebml_w; let mut ebml_w = copy ebml_w;
encode_info_for_item(ecx, &mut ebml_w, i, index, *pt); encode_info_for_item(ecx, &mut ebml_w, i, index, *pt);
} }
_ => fail!(~"bad item") _ => fail!("bad item")
} }
} }
}, },
@ -1087,7 +1087,7 @@ fn encode_info_for_items(ecx: @EncodeContext,
abi); abi);
} }
// case for separate item and foreign-item tables // case for separate item and foreign-item tables
_ => fail!(~"bad foreign item") _ => fail!("bad foreign item")
} }
} }
}, },

View file

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

View file

@ -142,7 +142,7 @@ pub fn crate_name_from_metas(metas: &[@ast::meta_item]) -> @~str {
_ => fail!() _ => fail!()
} }
} }
None => fail!(~"expected to find the crate name") None => fail!("expected to find the crate name")
} }
} }

View file

@ -219,7 +219,7 @@ fn parse_bound_region(st: @mut PState) -> ty::bound_region {
assert!(next(st) == '|'); assert!(next(st) == '|');
ty::br_cap_avoid(id, @parse_bound_region(st)) ty::br_cap_avoid(id, @parse_bound_region(st))
}, },
_ => fail!(~"parse_bound_region: bad input") _ => fail!("parse_bound_region: bad input")
} }
} }
@ -248,7 +248,7 @@ fn parse_region(st: @mut PState) -> ty::Region {
'e' => { 'e' => {
ty::re_static ty::re_static
} }
_ => fail!(~"parse_region: bad input") _ => fail!("parse_region: bad input")
} }
} }
@ -256,7 +256,7 @@ fn parse_opt<T>(st: @mut PState, f: &fn() -> T) -> Option<T> {
match next(st) { match next(st) {
'n' => None, 'n' => None,
's' => Some(f()), 's' => Some(f()),
_ => fail!(~"parse_opt: bad input") _ => fail!("parse_opt: bad input")
} }
} }
@ -295,7 +295,7 @@ fn parse_ty(st: @mut PState, conv: conv_did) -> ty::t {
'D' => return ty::mk_mach_int(ast::ty_i64), 'D' => return ty::mk_mach_int(ast::ty_i64),
'f' => return ty::mk_mach_float(ast::ty_f32), 'f' => return ty::mk_mach_float(ast::ty_f32),
'F' => return ty::mk_mach_float(ast::ty_f64), 'F' => return ty::mk_mach_float(ast::ty_f64),
_ => fail!(~"parse_ty: bad numeric type") _ => fail!("parse_ty: bad numeric type")
} }
} }
'c' => return ty::mk_char(), 'c' => return ty::mk_char(),
@ -446,7 +446,7 @@ fn parse_purity(c: char) -> purity {
'p' => pure_fn, 'p' => pure_fn,
'i' => impure_fn, 'i' => impure_fn,
'c' => extern_fn, 'c' => extern_fn,
_ => fail!(~"parse_purity: bad purity") _ => fail!("parse_purity: bad purity")
} }
} }
@ -467,7 +467,7 @@ fn parse_onceness(c: char) -> ast::Onceness {
match c { match c {
'o' => ast::Once, 'o' => ast::Once,
'm' => ast::Many, 'm' => ast::Many,
_ => fail!(~"parse_onceness: bad onceness") _ => fail!("parse_onceness: bad onceness")
} }
} }
@ -531,13 +531,13 @@ pub fn parse_def_id(buf: &[u8]) -> ast::def_id {
let crate_num = match uint::parse_bytes(crate_part, 10u) { let crate_num = match uint::parse_bytes(crate_part, 10u) {
Some(cn) => cn as int, Some(cn) => cn as int,
None => fail!(fmt!("internal error: parse_def_id: crate number \ None => fail!("internal error: parse_def_id: crate number \
expected, but found %?", crate_part)) expected, but found %?", crate_part)
}; };
let def_num = match uint::parse_bytes(def_part, 10u) { let def_num = match uint::parse_bytes(def_part, 10u) {
Some(dn) => dn as int, Some(dn) => dn as int,
None => fail!(fmt!("internal error: parse_def_id: id expected, but \ None => fail!("internal error: parse_def_id: id expected, but \
found %?", def_part)) found %?", def_part)
}; };
ast::def_id { crate: crate_num, node: def_num } ast::def_id { crate: crate_num, node: def_num }
} }
@ -581,7 +581,7 @@ fn parse_bounds(st: @mut PState, conv: conv_did) -> @ty::ParamBounds {
return @param_bounds; return @param_bounds;
} }
_ => { _ => {
fail!(~"parse_bounds: bad bounds") fail!("parse_bounds: bad bounds")
} }
} }
} }

View file

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

View file

@ -293,7 +293,7 @@ fn simplify_ast(ii: &ast::inlined_item) -> ast::inlined_item {
span: _}, _) => true, span: _}, _) => true,
ast::stmt_decl(@codemap::spanned { node: ast::decl_item(_), ast::stmt_decl(@codemap::spanned { node: ast::decl_item(_),
span: _}, _) => false, span: _}, _) => false,
ast::stmt_mac(*) => fail!(~"unexpanded macro in astencode") ast::stmt_mac(*) => fail!("unexpanded macro in astencode")
} }
}; };
let blk_sans_items = ast::blk_ { let blk_sans_items = ast::blk_ {
@ -686,7 +686,7 @@ impl vtable_decoder_helpers for reader::Decoder {
) )
} }
// hard to avoid - user input // hard to avoid - user input
_ => fail!(~"bad enum variant") _ => fail!("bad enum variant")
} }
} }
} }

View file

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

View file

@ -147,14 +147,14 @@ pub fn check_exhaustive(cx: @MatchCheckCtxt, sp: span, pats: ~[@pat]) {
ty::ty_enum(id, _) => { ty::ty_enum(id, _) => {
let vid = match *ctor { let vid = match *ctor {
variant(id) => id, variant(id) => id,
_ => fail!(~"check_exhaustive: non-variant ctor"), _ => fail!("check_exhaustive: non-variant ctor"),
}; };
let variants = ty::enum_variants(cx.tcx, id); let variants = ty::enum_variants(cx.tcx, id);
match variants.find(|v| v.id == vid) { match variants.find(|v| v.id == vid) {
Some(v) => Some(cx.tcx.sess.str_of(v.name)), Some(v) => Some(cx.tcx.sess.str_of(v.name)),
None => { None => {
fail!(~"check_exhaustive: bad variant in ctor") fail!("check_exhaustive: bad variant in ctor")
} }
} }
} }
@ -382,7 +382,7 @@ pub fn missing_ctor(cx: @MatchCheckCtxt,
None => (), None => (),
Some(val(const_bool(true))) => true_found = true, Some(val(const_bool(true))) => true_found = true,
Some(val(const_bool(false))) => false_found = true, Some(val(const_bool(false))) => false_found = true,
_ => fail!(~"impossible case") _ => fail!("impossible case")
} }
} }
if true_found && false_found { None } if true_found && false_found { None }
@ -449,10 +449,10 @@ pub fn ctor_arity(cx: @MatchCheckCtxt, ctor: &ctor, ty: ty::t) -> uint {
ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_rptr(*) => 1u, ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_rptr(*) => 1u,
ty::ty_enum(eid, _) => { ty::ty_enum(eid, _) => {
let id = match *ctor { variant(id) => id, let id = match *ctor { variant(id) => id,
_ => fail!(~"impossible case") }; _ => fail!("impossible case") };
match vec::find(*ty::enum_variants(cx.tcx, eid), |v| v.id == id ) { match vec::find(*ty::enum_variants(cx.tcx, eid), |v| v.id == id ) {
Some(v) => v.args.len(), Some(v) => v.args.len(),
None => fail!(~"impossible case") None => fail!("impossible case")
} }
} }
ty::ty_struct(cid, _) => ty::lookup_struct_fields(cx.tcx, cid).len(), ty::ty_struct(cid, _) => ty::lookup_struct_fields(cx.tcx, cid).len(),
@ -504,7 +504,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
compare_const_vals(c_hi, &e_v) <= 0 compare_const_vals(c_hi, &e_v) <= 0
} }
single => true, single => true,
_ => fail!(~"type error") _ => fail!("type error")
}; };
if match_ { if match_ {
Some(vec::to_owned(r.tail())) Some(vec::to_owned(r.tail()))
@ -535,7 +535,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
compare_const_vals(c_hi, &e_v) <= 0 compare_const_vals(c_hi, &e_v) <= 0
} }
single => true, single => true,
_ => fail!(~"type error") _ => fail!("type error")
}; };
if match_ { if match_ {
Some(vec::to_owned(r.tail())) Some(vec::to_owned(r.tail()))
@ -625,7 +625,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
compare_const_vals(c_hi, &e_v) <= 0 compare_const_vals(c_hi, &e_v) <= 0
} }
single => true, single => true,
_ => fail!(~"type error") _ => fail!("type error")
}; };
if match_ { Some(vec::to_owned(r.tail())) } else { None } if match_ { Some(vec::to_owned(r.tail())) } else { None }
} }
@ -635,7 +635,7 @@ pub fn specialize(cx: @MatchCheckCtxt,
range(ref lo, ref hi) => range(ref lo, ref hi) =>
((/*bad*/copy *lo), (/*bad*/copy *hi)), ((/*bad*/copy *lo), (/*bad*/copy *hi)),
single => return Some(vec::to_owned(r.tail())), single => return Some(vec::to_owned(r.tail())),
_ => fail!(~"type error") _ => fail!("type error")
}; };
let v_lo = eval_const_expr(cx.tcx, lo), let v_lo = eval_const_expr(cx.tcx, lo),
v_hi = eval_const_expr(cx.tcx, hi); v_hi = eval_const_expr(cx.tcx, hi);

View file

@ -467,7 +467,7 @@ pub fn compare_const_vals(a: &const_val, b: &const_val) -> int {
1 1
} }
} }
_ => fail!(~"compare_const_vals: ill-typed comparison") _ => fail!("compare_const_vals: ill-typed comparison")
} }
} }

View file

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

View file

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

View file

@ -127,7 +127,7 @@ pub impl RegionMaps {
match self.scope_map.find(&id) { match self.scope_map.find(&id) {
Some(&r) => r, Some(&r) => r,
None => { fail!(fmt!("No enclosing scope for id %?", id)); } None => { fail!("No enclosing scope for id %?", id); }
} }
} }

View file

@ -319,7 +319,7 @@ pub fn namespace_for_duplicate_checking_mode(mode: DuplicateCheckingMode)
ForbidDuplicateModules | ForbidDuplicateTypes | ForbidDuplicateModules | ForbidDuplicateTypes |
ForbidDuplicateTypesAndValues => TypeNS, ForbidDuplicateTypesAndValues => TypeNS,
ForbidDuplicateValues => ValueNS, ForbidDuplicateValues => ValueNS,
OverwriteDuplicates => fail!(~"OverwriteDuplicates has no namespace") OverwriteDuplicates => fail!("OverwriteDuplicates has no namespace")
} }
} }
@ -605,7 +605,7 @@ pub impl NameBindings {
fn get_module(@mut self) -> @mut Module { fn get_module(@mut self) -> @mut Module {
match self.get_module_if_available() { match self.get_module_if_available() {
None => { None => {
fail!(~"get_module called on a node with no module \ fail!("get_module called on a node with no module \
definition!") definition!")
} }
Some(module_def) => module_def Some(module_def) => module_def
@ -1336,7 +1336,7 @@ pub impl Resolver {
} }
item_mac(*) => { item_mac(*) => {
fail!(~"item macros unimplemented") fail!("item macros unimplemented")
} }
} }
} }
@ -1577,7 +1577,7 @@ pub impl Resolver {
match existing_module.parent_link { match existing_module.parent_link {
NoParentLink | NoParentLink |
BlockParentLink(*) => { BlockParentLink(*) => {
fail!(~"can't happen"); fail!("can't happen");
} }
ModuleParentLink(parent_module, ident) => { ModuleParentLink(parent_module, ident) => {
let name_bindings = parent_module.children.get( let name_bindings = parent_module.children.get(
@ -1647,7 +1647,7 @@ pub impl Resolver {
def_prim_ty(*) | def_ty_param(*) | def_binding(*) | def_prim_ty(*) | def_ty_param(*) | def_binding(*) |
def_use(*) | def_upvar(*) | def_region(*) | def_use(*) | def_upvar(*) | def_region(*) |
def_typaram_binder(*) | def_label(*) | def_self_ty(*) => { def_typaram_binder(*) | def_label(*) | def_self_ty(*) => {
fail!(fmt!("didn't expect `%?`", def)); fail!("didn't expect `%?`", def);
} }
} }
} }
@ -2269,7 +2269,7 @@ pub impl Resolver {
} }
UnboundResult => { /* Continue. */ } UnboundResult => { /* Continue. */ }
UnknownResult => { UnknownResult => {
fail!(~"value result should be known at this point"); fail!("value result should be known at this point");
} }
} }
match type_result { match type_result {
@ -2279,7 +2279,7 @@ pub impl Resolver {
} }
UnboundResult => { /* Continue. */ } UnboundResult => { /* Continue. */ }
UnknownResult => { UnknownResult => {
fail!(~"type result should be known at this point"); fail!("type result should be known at this point");
} }
} }
@ -3573,7 +3573,7 @@ pub impl Resolver {
} }
item_mac(*) => { item_mac(*) => {
fail!(~"item macros unimplemented") fail!("item macros unimplemented")
} }
} }
@ -4310,7 +4310,7 @@ pub impl Resolver {
Success(target) => { Success(target) => {
match target.bindings.value_def { match target.bindings.value_def {
None => { None => {
fail!(~"resolved name in the value namespace to a \ fail!("resolved name in the value namespace to a \
set of name bindings with no def?!"); set of name bindings with no def?!");
} }
Some(def) => { Some(def) => {
@ -4330,7 +4330,7 @@ pub impl Resolver {
} }
Indeterminate => { Indeterminate => {
fail!(~"unexpected indeterminate result"); fail!("unexpected indeterminate result");
} }
Failed => { Failed => {
@ -4501,7 +4501,7 @@ pub impl Resolver {
} }
Indeterminate => { Indeterminate => {
fail!(~"indeterminate unexpected"); fail!("indeterminate unexpected");
} }
Success(resulting_module) => { Success(resulting_module) => {
@ -4550,7 +4550,7 @@ pub impl Resolver {
} }
Indeterminate => { Indeterminate => {
fail!(~"indeterminate unexpected"); fail!("indeterminate unexpected");
} }
Success(resulting_module) => { Success(resulting_module) => {
@ -4660,7 +4660,7 @@ pub impl Resolver {
} }
} }
Indeterminate => { Indeterminate => {
fail!(~"unexpected indeterminate result"); fail!("unexpected indeterminate result");
} }
Failed => { Failed => {
return None; return None;

View file

@ -320,7 +320,7 @@ pub fn namespace_for_duplicate_checking_mode(mode: DuplicateCheckingMode)
ForbidDuplicateModules | ForbidDuplicateTypes | ForbidDuplicateModules | ForbidDuplicateTypes |
ForbidDuplicateTypesAndValues => TypeNS, ForbidDuplicateTypesAndValues => TypeNS,
ForbidDuplicateValues => ValueNS, ForbidDuplicateValues => ValueNS,
OverwriteDuplicates => fail!(~"OverwriteDuplicates has no namespace") OverwriteDuplicates => fail!("OverwriteDuplicates has no namespace")
} }
} }
@ -606,7 +606,7 @@ pub impl NameBindings {
fn get_module(@mut self) -> @mut Module { fn get_module(@mut self) -> @mut Module {
match self.get_module_if_available() { match self.get_module_if_available() {
None => { None => {
fail!(~"get_module called on a node with no module \ fail!("get_module called on a node with no module \
definition!") definition!")
} }
Some(module_def) => module_def Some(module_def) => module_def
@ -1352,7 +1352,7 @@ pub impl Resolver {
} }
item_mac(*) => { item_mac(*) => {
fail!(~"item macros unimplemented") fail!("item macros unimplemented")
} }
} }
} }
@ -1593,7 +1593,7 @@ pub impl Resolver {
match existing_module.parent_link { match existing_module.parent_link {
NoParentLink | NoParentLink |
BlockParentLink(*) => { BlockParentLink(*) => {
fail!(~"can't happen"); fail!("can't happen");
} }
ModuleParentLink(parent_module, ident) => { ModuleParentLink(parent_module, ident) => {
let name_bindings = parent_module.children.get( let name_bindings = parent_module.children.get(
@ -1663,7 +1663,7 @@ pub impl Resolver {
def_prim_ty(*) | def_ty_param(*) | def_binding(*) | def_prim_ty(*) | def_ty_param(*) | def_binding(*) |
def_use(*) | def_upvar(*) | def_region(*) | def_use(*) | def_upvar(*) | def_region(*) |
def_typaram_binder(*) | def_label(*) | def_self_ty(*) => { def_typaram_binder(*) | def_label(*) | def_self_ty(*) => {
fail!(fmt!("didn't expect `%?`", def)); fail!("didn't expect `%?`", def);
} }
} }
} }
@ -2286,7 +2286,7 @@ pub impl Resolver {
} }
UnboundResult => { /* Continue. */ } UnboundResult => { /* Continue. */ }
UnknownResult => { UnknownResult => {
fail!(~"value result should be known at this point"); fail!("value result should be known at this point");
} }
} }
match type_result { match type_result {
@ -2296,7 +2296,7 @@ pub impl Resolver {
} }
UnboundResult => { /* Continue. */ } UnboundResult => { /* Continue. */ }
UnknownResult => { UnknownResult => {
fail!(~"type result should be known at this point"); fail!("type result should be known at this point");
} }
} }
@ -3599,7 +3599,7 @@ pub impl Resolver {
} }
item_mac(*) => { item_mac(*) => {
fail!(~"item macros unimplemented") fail!("item macros unimplemented")
} }
} }
@ -4337,7 +4337,7 @@ pub impl Resolver {
Success(target) => { Success(target) => {
match target.bindings.value_def { match target.bindings.value_def {
None => { None => {
fail!(~"resolved name in the value namespace to a \ fail!("resolved name in the value namespace to a \
set of name bindings with no def?!"); set of name bindings with no def?!");
} }
Some(def) => { Some(def) => {
@ -4357,7 +4357,7 @@ pub impl Resolver {
} }
Indeterminate => { Indeterminate => {
fail!(~"unexpected indeterminate result"); fail!("unexpected indeterminate result");
} }
Failed => { Failed => {
@ -4528,7 +4528,7 @@ pub impl Resolver {
} }
Indeterminate => { Indeterminate => {
fail!(~"indeterminate unexpected"); fail!("indeterminate unexpected");
} }
Success(resulting_module) => { Success(resulting_module) => {
@ -4577,7 +4577,7 @@ pub impl Resolver {
} }
Indeterminate => { Indeterminate => {
fail!(~"indeterminate unexpected"); fail!("indeterminate unexpected");
} }
Success(resulting_module) => { Success(resulting_module) => {
@ -4687,7 +4687,7 @@ pub impl Resolver {
} }
} }
Indeterminate => { Indeterminate => {
fail!(~"unexpected indeterminate result"); fail!("unexpected indeterminate result");
} }
Failed => { Failed => {
return None; return None;

View file

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

View file

@ -47,7 +47,7 @@ pub fn trans_inline_asm(bcx: block, ia: &ast::inline_asm) -> block {
let e = match out.node { let e = match out.node {
ast::expr_addr_of(_, e) => e, ast::expr_addr_of(_, e) => e,
_ => fail!(~"Expression must be addr of") _ => fail!("Expression must be addr of")
}; };
let outty = ty::arg { let outty = ty::arg {

View file

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

View file

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

View file

@ -52,7 +52,7 @@ fn ty_align(ty: TypeRef) -> uint {
let elt = llvm::LLVMGetElementType(ty); let elt = llvm::LLVMGetElementType(ty);
ty_align(elt) ty_align(elt)
} }
_ => fail!(~"ty_align: unhandled type") _ => fail!("ty_align: unhandled type")
}; };
} }
} }
@ -84,7 +84,7 @@ fn ty_size(ty: TypeRef) -> uint {
let eltsz = ty_size(elt); let eltsz = ty_size(elt);
len * eltsz len * eltsz
} }
_ => fail!(~"ty_size: unhandled type") _ => fail!("ty_size: unhandled type")
}; };
} }
} }

View file

@ -60,7 +60,7 @@ fn ty_align(ty: TypeRef) -> uint {
let elt = llvm::LLVMGetElementType(ty); let elt = llvm::LLVMGetElementType(ty);
ty_align(elt) ty_align(elt)
} }
_ => fail!(~"ty_size: unhandled type") _ => fail!("ty_size: unhandled type")
}; };
} }
} }
@ -92,7 +92,7 @@ fn ty_size(ty: TypeRef) -> uint {
let eltsz = ty_size(elt); let eltsz = ty_size(elt);
len * eltsz len * eltsz
} }
_ => fail!(~"ty_size: unhandled type") _ => fail!("ty_size: unhandled type")
}; };
} }
} }

View file

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

View file

@ -837,7 +837,7 @@ pub fn create_local_var(bcx: block, local: @ast::local)
let name = match local.node.pat.node { let name = match local.node.pat.node {
ast::pat_ident(_, pth, _) => ast_util::path_to_ident(pth), ast::pat_ident(_, pth, _) => ast_util::path_to_ident(pth),
// FIXME this should be handled (#2533) // FIXME this should be handled (#2533)
_ => fail!(~"no single variable name for local") _ => fail!("no single variable name for local")
}; };
let loc = cx.sess.codemap.lookup_char_pos(local.span.lo); let loc = cx.sess.codemap.lookup_char_pos(local.span.lo);
let ty = node_id_type(bcx, local.node.id); let ty = node_id_type(bcx, local.node.id);

View file

@ -753,7 +753,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
if in_type_size != out_type_size { if in_type_size != out_type_size {
let sp = match ccx.tcx.items.get_copy(&ref_id.get()) { let sp = match ccx.tcx.items.get_copy(&ref_id.get()) {
ast_map::node_expr(e) => e.span, ast_map::node_expr(e) => e.span,
_ => fail!(~"transmute has non-expr arg"), _ => fail!("transmute has non-expr arg"),
}; };
let pluralize = |n| if 1u == n { "" } else { "s" }; let pluralize = |n| if 1u == n { "" } else { "s" };
ccx.sess.span_fatal(sp, ccx.sess.span_fatal(sp,

View file

@ -257,7 +257,7 @@ pub fn trans_method_callee(bcx: block,
trait_id, off, vtbl) trait_id, off, vtbl)
} }
// how to get rid of this? // how to get rid of this?
None => fail!(~"trans_method_callee: missing param_substs") None => fail!("trans_method_callee: missing param_substs")
} }
} }
typeck::method_trait(_, off, store) => { typeck::method_trait(_, off, store) => {
@ -269,7 +269,7 @@ pub fn trans_method_callee(bcx: block,
mentry.explicit_self) mentry.explicit_self)
} }
typeck::method_self(*) | typeck::method_super(*) => { typeck::method_self(*) | typeck::method_super(*) => {
fail!(~"method_self or method_super should have been handled \ fail!("method_self or method_super should have been handled \
above") above")
} }
} }
@ -317,13 +317,13 @@ pub fn trans_static_method_callee(bcx: block,
ast_map::node_trait_method(trait_method, _, _) => { ast_map::node_trait_method(trait_method, _, _) => {
ast_util::trait_method_to_ty_method(trait_method).ident ast_util::trait_method_to_ty_method(trait_method).ident
} }
_ => fail!(~"callee is not a trait method") _ => fail!("callee is not a trait method")
} }
} else { } else {
let path = csearch::get_item_path(bcx.tcx(), method_id); let path = csearch::get_item_path(bcx.tcx(), method_id);
match path[path.len()-1] { match path[path.len()-1] {
path_name(s) => { s } path_name(s) => { s }
path_mod(_) => { fail!(~"path doesn't have a name?") } path_mod(_) => { fail!("path doesn't have a name?") }
} }
}; };
debug!("trans_static_method_callee: method_id=%?, callee_id=%?, \ debug!("trans_static_method_callee: method_id=%?, callee_id=%?, \
@ -354,7 +354,7 @@ pub fn trans_static_method_callee(bcx: block,
FnData {llfn: PointerCast(bcx, lval, llty)} FnData {llfn: PointerCast(bcx, lval, llty)}
} }
_ => { _ => {
fail!(~"vtable_param left in monomorphized \ fail!("vtable_param left in monomorphized \
function's vtable substs"); function's vtable substs");
} }
} }
@ -375,7 +375,7 @@ pub fn method_with_name(ccx: @CrateContext, impl_id: ast::def_id,
}, _) => { }, _) => {
method_from_methods(*ms, name).get() method_from_methods(*ms, name).get()
} }
_ => fail!(~"method_with_name") _ => fail!("method_with_name")
} }
} else { } else {
csearch::get_impl_method(ccx.sess.cstore, impl_id, name) csearch::get_impl_method(ccx.sess.cstore, impl_id, name)
@ -410,7 +410,7 @@ pub fn method_with_name_or_default(ccx: @CrateContext,
} }
} }
} }
_ => fail!(~"method_with_name") _ => fail!("method_with_name")
} }
} else { } else {
csearch::get_impl_method(ccx.sess.cstore, impl_id, name) csearch::get_impl_method(ccx.sess.cstore, impl_id, name)
@ -436,7 +436,7 @@ pub fn method_ty_param_count(ccx: @CrateContext, m_id: ast::def_id,
_, _)) => { _, _)) => {
m.generics.ty_params.len() m.generics.ty_params.len()
} }
copy e => fail!(fmt!("method_ty_param_count %?", e)) copy e => fail!("method_ty_param_count %?", e)
} }
} else { } else {
csearch::get_type_param_count(ccx.sess.cstore, m_id) - csearch::get_type_param_count(ccx.sess.cstore, m_id) -
@ -495,8 +495,7 @@ pub fn trans_monomorphized_callee(bcx: block,
} }
} }
typeck::vtable_param(*) => { typeck::vtable_param(*) => {
fail!(~"vtable_param left in monomorphized function's " + fail!("vtable_param left in monomorphized function's vtable substs");
"vtable substs");
} }
}; };
@ -752,7 +751,7 @@ pub fn vtable_id(ccx: @CrateContext,
} }
// can't this be checked at the callee? // can't this be checked at the callee?
_ => fail!(~"vtable_id") _ => fail!("vtable_id")
} }
} }
@ -767,7 +766,7 @@ pub fn get_vtable(ccx: @CrateContext,
typeck::vtable_static(id, substs, sub_vtables) => { typeck::vtable_static(id, substs, sub_vtables) => {
make_impl_vtable(ccx, id, substs, sub_vtables) make_impl_vtable(ccx, id, substs, sub_vtables)
} }
_ => fail!(~"get_vtable: expected a static origin") _ => fail!("get_vtable: expected a static origin")
} }
} }
} }

View file

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

View file

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

View file

@ -1687,7 +1687,7 @@ pub fn simd_type(cx: ctxt, ty: t) -> t {
let fields = lookup_struct_fields(cx, did); let fields = lookup_struct_fields(cx, did);
lookup_field_type(cx, did, fields[0].id, substs) lookup_field_type(cx, did, fields[0].id, substs)
} }
_ => fail!(~"simd_type called on invalid type") _ => fail!("simd_type called on invalid type")
} }
} }
@ -1697,14 +1697,14 @@ pub fn simd_size(cx: ctxt, ty: t) -> uint {
let fields = lookup_struct_fields(cx, did); let fields = lookup_struct_fields(cx, did);
fields.len() fields.len()
} }
_ => fail!(~"simd_size called on invalid type") _ => fail!("simd_size called on invalid type")
} }
} }
pub fn get_element_type(ty: t, i: uint) -> t { pub fn get_element_type(ty: t, i: uint) -> t {
match get(ty).sty { match get(ty).sty {
ty_tup(ref ts) => return ts[i], ty_tup(ref ts) => return ts[i],
_ => fail!(~"get_element_type called on invalid type") _ => fail!("get_element_type called on invalid type")
} }
} }
@ -3001,7 +3001,7 @@ pub fn ty_fn_sig(fty: t) -> FnSig {
ty_bare_fn(ref f) => copy f.sig, ty_bare_fn(ref f) => copy f.sig,
ty_closure(ref f) => copy f.sig, ty_closure(ref f) => copy f.sig,
ref s => { ref s => {
fail!(fmt!("ty_fn_sig() called on non-fn type: %?", s)) fail!("ty_fn_sig() called on non-fn type: %?", s)
} }
} }
} }
@ -3012,7 +3012,7 @@ pub fn ty_fn_args(fty: t) -> ~[arg] {
ty_bare_fn(ref f) => copy f.sig.inputs, ty_bare_fn(ref f) => copy f.sig.inputs,
ty_closure(ref f) => copy f.sig.inputs, ty_closure(ref f) => copy f.sig.inputs,
ref s => { ref s => {
fail!(fmt!("ty_fn_args() called on non-fn type: %?", s)) fail!("ty_fn_args() called on non-fn type: %?", s)
} }
} }
} }
@ -3021,8 +3021,7 @@ pub fn ty_closure_sigil(fty: t) -> Sigil {
match get(fty).sty { match get(fty).sty {
ty_closure(ref f) => f.sigil, ty_closure(ref f) => f.sigil,
ref s => { ref s => {
fail!(fmt!("ty_closure_sigil() called on non-closure type: %?", fail!("ty_closure_sigil() called on non-closure type: %?", s)
s))
} }
} }
} }
@ -3032,7 +3031,7 @@ pub fn ty_fn_purity(fty: t) -> ast::purity {
ty_bare_fn(ref f) => f.purity, ty_bare_fn(ref f) => f.purity,
ty_closure(ref f) => f.purity, ty_closure(ref f) => f.purity,
ref s => { ref s => {
fail!(fmt!("ty_fn_purity() called on non-fn type: %?", s)) fail!("ty_fn_purity() called on non-fn type: %?", s)
} }
} }
} }
@ -3042,7 +3041,7 @@ pub fn ty_fn_ret(fty: t) -> t {
ty_bare_fn(ref f) => f.sig.output, ty_bare_fn(ref f) => f.sig.output,
ty_closure(ref f) => f.sig.output, ty_closure(ref f) => f.sig.output,
ref s => { ref s => {
fail!(fmt!("ty_fn_ret() called on non-fn type: %?", s)) fail!("ty_fn_ret() called on non-fn type: %?", s)
} }
} }
} }
@ -3059,7 +3058,7 @@ pub fn ty_vstore(ty: t) -> vstore {
match get(ty).sty { match get(ty).sty {
ty_evec(_, vstore) => vstore, ty_evec(_, vstore) => vstore,
ty_estr(vstore) => vstore, ty_estr(vstore) => vstore,
ref s => fail!(fmt!("ty_vstore() called on invalid sty: %?", s)) ref s => fail!("ty_vstore() called on invalid sty: %?", s)
} }
} }
@ -3496,7 +3495,7 @@ pub fn stmt_node_id(s: @ast::stmt) -> ast::node_id {
ast::stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) => { ast::stmt_decl(_, id) | stmt_expr(_, id) | stmt_semi(_, id) => {
return id; return id;
} }
ast::stmt_mac(*) => fail!(~"unexpanded macro in trans") ast::stmt_mac(*) => fail!("unexpanded macro in trans")
} }
} }
@ -3833,8 +3832,7 @@ fn lookup_locally_or_in_crate_store<V:Copy>(
} }
if def_id.crate == ast::local_crate { if def_id.crate == ast::local_crate {
fail!(fmt!("No def'n found for %? in tcx.%s", fail!("No def'n found for %? in tcx.%s", def_id, descr);
def_id, descr));
} }
let v = load_external(); let v = load_external();
map.insert(def_id, v); map.insert(def_id, v);
@ -4095,7 +4093,7 @@ pub fn enum_variants(cx: ctxt, id: ast::def_id) -> @~[VariantInfo] {
} }
} }
ast::struct_variant_kind(_) => { ast::struct_variant_kind(_) => {
fail!(~"struct variant kinds unimpl in enum_variants") fail!("struct variant kinds unimpl in enum_variants")
} }
} }
}) })

View file

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

View file

@ -2147,8 +2147,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
inner_ty, fcx.expr_ty(loop_body)); inner_ty, fcx.expr_ty(loop_body));
} }
ref n => { ref n => {
fail!(fmt!( fail!("check_loop_body expected expr_fn_block, not %?", n)
"check_loop_body expected expr_fn_block, not %?", n))
} }
} }
@ -2573,7 +2572,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b)); demand::suptype(fcx, b.span, inner_ty, fcx.expr_ty(b));
} }
// argh // argh
_ => fail!(~"expected fn ty") _ => fail!("expected fn ty")
} }
fcx.write_ty(expr.id, fcx.node_ty(b.id)); fcx.write_ty(expr.id, fcx.node_ty(b.id));
} }

View file

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

View file

@ -142,7 +142,7 @@ pub fn get_base_type_def_id(inference_context: @mut InferCtxt,
return Some(def_id); return Some(def_id);
} }
_ => { _ => {
fail!(~"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"); enum, class, or trait");
} }
} }

View file

@ -1137,7 +1137,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: @ast::item)
} }
ast::item_impl(*) | ast::item_mod(_) | ast::item_impl(*) | ast::item_mod(_) |
ast::item_foreign_mod(_) => fail!(), ast::item_foreign_mod(_) => fail!(),
ast::item_mac(*) => fail!(~"item macros unimplemented") ast::item_mac(*) => fail!("item macros unimplemented")
} }
} }

View file

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

View file

@ -227,7 +227,7 @@ impl region_scope for type_rscope {
None => { None => {
// if the self region is used, region parameterization should // if the self region is used, region parameterization should
// have inferred that this type is RP // have inferred that this type is RP
fail!(~"region parameterization should have inferred that \ fail!("region parameterization should have inferred that \
this type is RP"); this type is RP");
} }
Some(ref region_parameterization) => { Some(ref region_parameterization) => {

View file

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

View file

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

View file

@ -135,7 +135,7 @@ fn pandoc_writer(
if status != 0 { if status != 0 {
error!("pandoc-out: %s", stdout); error!("pandoc-out: %s", stdout);
error!("pandoc-err: %s", stderr); error!("pandoc-err: %s", stderr);
fail!(~"pandoc failed"); fail!("pandoc failed");
} }
} }
} }

View file

@ -75,7 +75,7 @@ fn get_fn_sig(srv: astsrv::Srv, fn_id: doc::AstId) -> Option<~str> {
Some(pprust::fun_to_str(decl, purity, ident, None, tys, Some(pprust::fun_to_str(decl, purity, ident, None, tys,
extract::interner())) extract::interner()))
} }
_ => fail!(~"get_fn_sig: fn_id not bound to a fn item") _ => fail!("get_fn_sig: fn_id not bound to a fn item")
} }
} }
} }
@ -96,7 +96,7 @@ fn fold_const(
}, _) => { }, _) => {
pprust::ty_to_str(ty, extract::interner()) pprust::ty_to_str(ty, extract::interner())
} }
_ => fail!(~"fold_const: id not bound to a const item") _ => fail!("fold_const: id not bound to a const item")
} }
}}), }}),
.. doc .. doc
@ -127,7 +127,7 @@ fn fold_enum(
pprust::variant_to_str( pprust::variant_to_str(
ast_variant, extract::interner()) ast_variant, extract::interner())
} }
_ => fail!(~"enum variant not bound to an enum item") _ => fail!("enum variant not bound to an enum item")
} }
} }
}; };
@ -204,7 +204,7 @@ fn get_method_sig(
} }
} }
} }
_ => fail!(~"method not found") _ => fail!("method not found")
} }
} }
ast_map::node_item(@ast::item { ast_map::node_item(@ast::item {
@ -223,10 +223,10 @@ fn get_method_sig(
extract::interner() extract::interner()
)) ))
} }
None => fail!(~"method not found") None => fail!("method not found")
} }
} }
_ => fail!(~"get_method_sig: item ID not bound to trait or impl") _ => fail!("get_method_sig: item ID not bound to trait or impl")
} }
} }
} }
@ -255,7 +255,7 @@ fn fold_impl(
Some(pprust::ty_to_str( Some(pprust::ty_to_str(
self_ty, extract::interner()))) self_ty, extract::interner())))
} }
_ => fail!(~"expected impl") _ => fail!("expected impl")
} }
} }
}; };
@ -294,7 +294,7 @@ fn fold_type(
extract::interner()) extract::interner())
)) ))
} }
_ => fail!(~"expected type") _ => fail!("expected type")
} }
} }
}, },
@ -318,7 +318,7 @@ fn fold_struct(
Some(pprust::item_to_str(item, Some(pprust::item_to_str(item,
extract::interner())) extract::interner()))
} }
_ => fail!(~"not an item") _ => fail!("not an item")
} }
} }
}, },
@ -333,7 +333,7 @@ fn fold_struct(
fn strip_struct_extra_stuff(item: @ast::item) -> @ast::item { fn strip_struct_extra_stuff(item: @ast::item) -> @ast::item {
let node = match copy item.node { let node = match copy item.node {
ast::item_struct(def, tys) => ast::item_struct(def, tys), ast::item_struct(def, tys) => ast::item_struct(def, tys),
_ => fail!(~"not a struct") _ => fail!("not a struct")
}; };
@ast::item { @ast::item {

View file

@ -312,7 +312,7 @@ fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer,
let mut end_multiline = false; let mut end_multiline = false;
while (!end_multiline) { while (!end_multiline) {
match get_line(use_rl, ~"rusti| ") { match get_line(use_rl, ~"rusti| ") {
None => fail!(~"unterminated multiline command :{ .. :}"), None => fail!("unterminated multiline command :{ .. :}"),
Some(line) => { Some(line) => {
if str::trim(line) == ~":}" { if str::trim(line) == ~":}" {
end_multiline = true; end_multiline = true;

View file

@ -146,8 +146,8 @@ impl PkgScript {
} }
} }
Err(e) => { Err(e) => {
fail!(fmt!("Running package script, couldn't find rustpkg sysroot (%s)", fail!("Running package script, couldn't find rustpkg sysroot (%s)",
e)) e)
} }
} }
} }
@ -256,13 +256,13 @@ impl Ctx {
self.unprefer(name.get(), vers); self.unprefer(name.get(), vers);
} }
_ => fail!(~"reached an unhandled command") _ => fail!("reached an unhandled command")
} }
} }
fn do_cmd(&self, _cmd: ~str, _pkgname: ~str) { fn do_cmd(&self, _cmd: ~str, _pkgname: ~str) {
// stub // stub
fail!(~"`do` not yet implemented"); fail!("`do` not yet implemented");
} }
fn build(&self, workspace: &Path, pkgid: PkgId) { fn build(&self, workspace: &Path, pkgid: PkgId) {
@ -289,7 +289,7 @@ impl Ctx {
let (cfgs, hook_result) = pscript.run_custom(~"post_build"); let (cfgs, hook_result) = pscript.run_custom(~"post_build");
debug!("Command return code = %?", hook_result); debug!("Command return code = %?", hook_result);
if hook_result != 0 { if hook_result != 0 {
fail!(fmt!("Error running custom build command")) fail!("Error running custom build command")
} }
custom = true; custom = true;
// otherwise, the package script succeeded // otherwise, the package script succeeded
@ -330,7 +330,7 @@ impl Ctx {
fn info(&self) { fn info(&self) {
// stub // stub
fail!(~"info not yet implemented"); fail!("info not yet implemented");
} }
fn install(&self, workspace: &Path, id: PkgId) { fn install(&self, workspace: &Path, id: PkgId) {
@ -362,7 +362,7 @@ impl Ctx {
fn fetch(&self, _dir: &Path, _url: ~str, _target: Option<~str>) { fn fetch(&self, _dir: &Path, _url: ~str, _target: Option<~str>) {
// stub // stub
fail!(~"fetch not yet implemented"); fail!("fetch not yet implemented");
} }
fn fetch_curl(&self, dir: &Path, url: ~str) { fn fetch_curl(&self, dir: &Path, url: ~str) {
@ -448,15 +448,15 @@ impl Ctx {
fn test(&self) { fn test(&self) {
// stub // stub
fail!(~"test not yet implemented"); fail!("test not yet implemented");
} }
fn uninstall(&self, _id: ~str, _vers: Option<~str>) { fn uninstall(&self, _id: ~str, _vers: Option<~str>) {
fail!(~"uninstall not yet implemented"); fail!("uninstall not yet implemented");
} }
fn unprefer(&self, _id: ~str, _vers: Option<~str>) { fn unprefer(&self, _id: ~str, _vers: Option<~str>) {
fail!(~"unprefer not yet implemented"); fail!("unprefer not yet implemented");
} }
} }

View file

@ -324,7 +324,7 @@ pub fn parse_vers(vers: ~str) -> result::Result<semver::Version, ~str> {
pub fn need_dir(s: &Path) { pub fn need_dir(s: &Path) {
if !os::path_is_dir(s) && !os::make_dir(s, 493_i32) { if !os::path_is_dir(s) && !os::make_dir(s, 493_i32) {
fail!(fmt!("can't create dir: %s", s.to_str())); fail!("can't create dir: %s", s.to_str());
} }
} }
@ -421,12 +421,12 @@ pub fn wait_for_lock(path: &Path) {
} }
pub fn load_pkgs() -> result::Result<~[json::Json], ~str> { pub fn load_pkgs() -> result::Result<~[json::Json], ~str> {
fail!(~"load_pkg not implemented"); fail!("load_pkg not implemented");
} }
pub fn get_pkg(_id: ~str, pub fn get_pkg(_id: ~str,
_vers: Option<~str>) -> result::Result<Pkg, ~str> { _vers: Option<~str>) -> result::Result<Pkg, ~str> {
fail!(~"get_pkg not implemented"); fail!("get_pkg not implemented");
} }
pub fn add_pkg(pkg: &Pkg) -> bool { pub fn add_pkg(pkg: &Pkg) -> bool {

View file

@ -21,10 +21,10 @@ pub fn pkg_parent_workspaces(pkgid: PkgId, action: &fn(&Path) -> bool) -> bool {
workspace_contains_package_id(pkgid, ws)); workspace_contains_package_id(pkgid, ws));
if workspaces.is_empty() { if workspaces.is_empty() {
// tjc: make this a condition // tjc: make this a condition
fail!(fmt!("Package %s not found in any of \ fail!("Package %s not found in any of \
the following workspaces: %s", the following workspaces: %s",
pkgid.path.to_str(), pkgid.path.to_str(),
rust_path().to_str())); rust_path().to_str());
} }
for workspaces.each |ws| { for workspaces.each |ws| {
if action(ws) { if action(ws) {

View file

@ -208,9 +208,9 @@ pub impl<T:Owned> MutexARC<T> {
fn check_poison(is_mutex: bool, failed: bool) { fn check_poison(is_mutex: bool, failed: bool) {
if failed { if failed {
if is_mutex { if is_mutex {
fail!(~"Poisoned MutexARC - another task failed inside!"); fail!("Poisoned MutexARC - another task failed inside!");
} else { } else {
fail!(~"Poisoned rw_arc - another task failed inside!"); fail!("Poisoned rw_arc - another task failed inside!");
} }
} }
} }

View file

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

View file

@ -236,7 +236,7 @@ pub struct Bitv {
} }
fn die() -> ! { fn die() -> ! {
fail!(~"Tried to do operation on bit vectors with different sizes"); fail!("Tried to do operation on bit vectors with different sizes");
} }
priv impl Bitv { priv impl Bitv {
@ -1308,7 +1308,7 @@ mod tests {
let mut b = Bitv::new(14, true); let mut b = Bitv::new(14, true);
b.clear(); b.clear();
for b.ones |i| { for b.ones |i| {
fail!(fmt!("found 1 at %?", i)); fail!("found 1 at %?", i);
} }
} }
@ -1317,7 +1317,7 @@ mod tests {
let mut b = Bitv::new(140, true); let mut b = Bitv::new(140, true);
b.clear(); b.clear();
for b.ones |i| { for b.ones |i| {
fail!(fmt!("found 1 at %?", i)); fail!("found 1 at %?", i);
} }
} }

View file

@ -40,18 +40,18 @@ priv impl<T> DListNode<T> {
match self.next { match self.next {
Some(neighbour) => match neighbour.prev { Some(neighbour) => match neighbour.prev {
Some(me) => if !managed::mut_ptr_eq(self, me) { Some(me) => if !managed::mut_ptr_eq(self, me) {
fail!(~"Asymmetric next-link in dlist node.") fail!("Asymmetric next-link in dlist node.")
}, },
None => fail!(~"One-way next-link in dlist node.") None => fail!("One-way next-link in dlist node.")
}, },
None => () None => ()
} }
match self.prev { match self.prev {
Some(neighbour) => match neighbour.next { Some(neighbour) => match neighbour.next {
Some(me) => if !managed::mut_ptr_eq(me, self) { Some(me) => if !managed::mut_ptr_eq(me, self) {
fail!(~"Asymmetric prev-link in dlist node.") fail!("Asymmetric prev-link in dlist node.")
}, },
None => fail!(~"One-way prev-link in dlist node.") None => fail!("One-way prev-link in dlist node.")
}, },
None => () None => ()
} }
@ -68,7 +68,7 @@ pub impl<T> DListNode<T> {
fn next_node(@mut self) -> @mut DListNode<T> { fn next_node(@mut self) -> @mut DListNode<T> {
match self.next_link() { match self.next_link() {
Some(nobe) => nobe, Some(nobe) => nobe,
None => fail!(~"This dlist node has no next neighbour.") None => fail!("This dlist node has no next neighbour.")
} }
} }
/// Get the previous node in the list, if there is one. /// Get the previous node in the list, if there is one.
@ -80,7 +80,7 @@ pub impl<T> DListNode<T> {
fn prev_node(@mut self) -> @mut DListNode<T> { fn prev_node(@mut self) -> @mut DListNode<T> {
match self.prev_link() { match self.prev_link() {
Some(nobe) => nobe, Some(nobe) => nobe,
None => fail!(~"This dlist node has no previous neighbour.") None => fail!("This dlist node has no previous neighbour.")
} }
} }
} }
@ -132,21 +132,21 @@ priv impl<T> DList<T> {
// These asserts could be stronger if we had node-root back-pointers, // These asserts could be stronger if we had node-root back-pointers,
// but those wouldn't allow for O(1) append. // but those wouldn't allow for O(1) append.
if self.size == 0 { if self.size == 0 {
fail!(~"This dlist is empty; that node can't be on it.") fail!("This dlist is empty; that node can't be on it.")
} }
if !nobe.linked { fail!(~"That node isn't linked to any dlist.") } if !nobe.linked { fail!("That node isn't linked to any dlist.") }
if !((nobe.prev.is_some() if !((nobe.prev.is_some()
|| managed::mut_ptr_eq(self.hd.expect(~"headless dlist?"), || managed::mut_ptr_eq(self.hd.expect(~"headless dlist?"),
nobe)) && nobe)) &&
(nobe.next.is_some() (nobe.next.is_some()
|| managed::mut_ptr_eq(self.tl.expect(~"tailless dlist?"), || managed::mut_ptr_eq(self.tl.expect(~"tailless dlist?"),
nobe))) { nobe))) {
fail!(~"That node isn't on this dlist.") fail!("That node isn't on this dlist.")
} }
} }
fn make_mine(&self, nobe: @mut DListNode<T>) { fn make_mine(&self, nobe: @mut DListNode<T>) {
if nobe.prev.is_some() || nobe.next.is_some() || nobe.linked { if nobe.prev.is_some() || nobe.next.is_some() || nobe.linked {
fail!(~"Cannot insert node that's already on a dlist!") fail!("Cannot insert node that's already on a dlist!")
} }
nobe.linked = true; nobe.linked = true;
} }
@ -318,16 +318,14 @@ pub impl<T> DList<T> {
fn head_n(@mut self) -> @mut DListNode<T> { fn head_n(@mut self) -> @mut DListNode<T> {
match self.hd { match self.hd {
Some(nobe) => nobe, Some(nobe) => nobe,
None => fail!( None => fail!("Attempted to get the head of an empty dlist.")
~"Attempted to get the head of an empty dlist.")
} }
} }
/// Get the node at the list's tail, failing if empty. O(1). /// Get the node at the list's tail, failing if empty. O(1).
fn tail_n(@mut self) -> @mut DListNode<T> { fn tail_n(@mut self) -> @mut DListNode<T> {
match self.tl { match self.tl {
Some(nobe) => nobe, Some(nobe) => nobe,
None => fail!( None => fail!("Attempted to get the tail of an empty dlist.")
~"Attempted to get the tail of an empty dlist.")
} }
} }
@ -340,7 +338,7 @@ pub impl<T> DList<T> {
*/ */
fn append(@mut self, them: @mut DList<T>) { fn append(@mut self, them: @mut DList<T>) {
if managed::mut_ptr_eq(self, them) { if managed::mut_ptr_eq(self, them) {
fail!(~"Cannot append a dlist to itself!") fail!("Cannot append a dlist to itself!")
} }
if them.len() > 0 { if them.len() > 0 {
self.link(self.tl, them.hd); self.link(self.tl, them.hd);
@ -357,7 +355,7 @@ pub impl<T> DList<T> {
*/ */
fn prepend(@mut self, them: @mut DList<T>) { fn prepend(@mut self, them: @mut DList<T>) {
if managed::mut_ptr_eq(self, them) { if managed::mut_ptr_eq(self, them) {
fail!(~"Cannot prepend a dlist to itself!") fail!("Cannot prepend a dlist to itself!")
} }
if them.len() > 0 { if them.len() > 0 {
self.link(them.tl, self.hd); self.link(them.tl, self.hd);
@ -524,7 +522,7 @@ impl<T> BaseIter<T> for @mut DList<T> {
// Check (weakly) that the user didn't do a remove. // Check (weakly) that the user didn't do a remove.
if self.size == 0 { if self.size == 0 {
fail!(~"The dlist became empty during iteration??") fail!("The dlist became empty during iteration??")
} }
if !nobe.linked || if !nobe.linked ||
(!((nobe.prev.is_some() (!((nobe.prev.is_some()
@ -533,7 +531,7 @@ impl<T> BaseIter<T> for @mut DList<T> {
&& (nobe.next.is_some() && (nobe.next.is_some()
|| managed::mut_ptr_eq(self.tl.expect(~"tailless dlist?"), || managed::mut_ptr_eq(self.tl.expect(~"tailless dlist?"),
nobe)))) { nobe)))) {
fail!(~"Removing a dlist node during iteration is forbidden!") fail!("Removing a dlist node during iteration is forbidden!")
} }
link = nobe.next_link(); link = nobe.next_link();
} }

View file

@ -116,7 +116,7 @@ pub mod reader {
(data[start + 3u] as uint), (data[start + 3u] as uint),
next: start + 4u}; next: start + 4u};
} }
fail!(~"vint too big"); fail!("vint too big");
} }
#[cfg(target_arch = "x86")] #[cfg(target_arch = "x86")]
@ -319,9 +319,9 @@ pub mod reader {
self.pos = r_doc.end; self.pos = r_doc.end;
let str = doc_as_str(r_doc); let str = doc_as_str(r_doc);
if lbl != str { if lbl != str {
fail!(fmt!("Expected label %s but found %s", fail!("Expected label %s but found %s",
lbl, lbl,
str)); str);
} }
} }
} }
@ -330,7 +330,7 @@ pub mod reader {
fn next_doc(&mut self, exp_tag: EbmlEncoderTag) -> Doc { fn next_doc(&mut self, exp_tag: EbmlEncoderTag) -> Doc {
debug!(". next_doc(exp_tag=%?)", exp_tag); debug!(". next_doc(exp_tag=%?)", exp_tag);
if self.pos >= self.parent.end { if self.pos >= self.parent.end {
fail!(~"no more documents in current node!"); fail!("no more documents in current node!");
} }
let TaggedDoc { tag: r_tag, doc: r_doc } = let TaggedDoc { tag: r_tag, doc: r_doc } =
doc_at(self.parent.data, self.pos); doc_at(self.parent.data, self.pos);
@ -338,12 +338,12 @@ pub mod reader {
copy self.parent.start, copy self.parent.end, copy self.parent.start, copy self.parent.end,
copy self.pos, r_tag, r_doc.start, r_doc.end); copy self.pos, r_tag, r_doc.start, r_doc.end);
if r_tag != (exp_tag as uint) { if r_tag != (exp_tag as uint) {
fail!(fmt!("expected EBML doc with tag %? but found tag %?", fail!("expected EBML doc with tag %? but found tag %?",
exp_tag, r_tag)); exp_tag, r_tag);
} }
if r_doc.end > self.parent.end { if r_doc.end > self.parent.end {
fail!(fmt!("invalid EBML, child extends to 0x%x, \ fail!("invalid EBML, child extends to 0x%x, \
parent to 0x%x", r_doc.end, self.parent.end)); parent to 0x%x", r_doc.end, self.parent.end);
} }
self.pos = r_doc.end; self.pos = r_doc.end;
r_doc r_doc
@ -393,7 +393,7 @@ pub mod reader {
fn read_uint(&mut self) -> uint { fn read_uint(&mut self) -> uint {
let v = doc_as_u64(self.next_doc(EsUint)); let v = doc_as_u64(self.next_doc(EsUint));
if v > (::core::uint::max_value as u64) { if v > (::core::uint::max_value as u64) {
fail!(fmt!("uint %? too large for this architecture", v)); fail!("uint %? too large for this architecture", v);
} }
v as uint v as uint
} }
@ -414,7 +414,7 @@ pub mod reader {
let v = doc_as_u64(self.next_doc(EsInt)) as i64; let v = doc_as_u64(self.next_doc(EsInt)) as i64;
if v > (int::max_value as i64) || v < (int::min_value as i64) { if v > (int::max_value as i64) || v < (int::min_value as i64) {
debug!("FIXME #6122: Removing this makes this function miscompile"); debug!("FIXME #6122: Removing this makes this function miscompile");
fail!(fmt!("int %? out of range for this architecture", v)); fail!("int %? out of range for this architecture", v);
} }
v as int v as int
} }
@ -423,10 +423,10 @@ pub mod reader {
doc_as_u8(self.next_doc(EsBool)) as bool doc_as_u8(self.next_doc(EsBool)) as bool
} }
fn read_f64(&mut self) -> f64 { fail!(~"read_f64()"); } fn read_f64(&mut self) -> f64 { fail!("read_f64()"); }
fn read_f32(&mut self) -> f32 { fail!(~"read_f32()"); } fn read_f32(&mut self) -> f32 { fail!("read_f32()"); }
fn read_float(&mut self) -> float { fail!(~"read_float()"); } fn read_float(&mut self) -> float { fail!("read_float()"); }
fn read_char(&mut self) -> char { fail!(~"read_char()"); } fn read_char(&mut self) -> char { fail!("read_char()"); }
fn read_str(&mut self) -> ~str { doc_as_str(self.next_doc(EsStr)) } fn read_str(&mut self) -> ~str { doc_as_str(self.next_doc(EsStr)) }
// Compound types: // Compound types:
@ -602,7 +602,7 @@ pub mod reader {
fn read_map<T>(&mut self, _: &fn(&mut Decoder, uint) -> T) -> T { fn read_map<T>(&mut self, _: &fn(&mut Decoder, uint) -> T) -> T {
debug!("read_map()"); debug!("read_map()");
fail!(~"read_map is unimplemented"); fail!("read_map is unimplemented");
} }
fn read_map_elt_key<T>(&mut self, fn read_map_elt_key<T>(&mut self,
@ -610,7 +610,7 @@ pub mod reader {
_: &fn(&mut Decoder) -> T) _: &fn(&mut Decoder) -> T)
-> T { -> T {
debug!("read_map_elt_key(idx=%u)", idx); debug!("read_map_elt_key(idx=%u)", idx);
fail!(~"read_map_elt_val is unimplemented"); fail!("read_map_elt_val is unimplemented");
} }
fn read_map_elt_val<T>(&mut self, fn read_map_elt_val<T>(&mut self,
@ -618,7 +618,7 @@ pub mod reader {
_: &fn(&mut Decoder) -> T) _: &fn(&mut Decoder) -> T)
-> T { -> T {
debug!("read_map_elt_val(idx=%u)", idx); debug!("read_map_elt_val(idx=%u)", idx);
fail!(~"read_map_elt_val is unimplemented"); fail!("read_map_elt_val is unimplemented");
} }
} }
} }
@ -647,7 +647,7 @@ pub mod writer {
n as u8]), n as u8]),
4u => w.write(&[0x10u8 | ((n >> 24_u) as u8), (n >> 16_u) as u8, 4u => w.write(&[0x10u8 | ((n >> 24_u) as u8), (n >> 16_u) as u8,
(n >> 8_u) as u8, n as u8]), (n >> 8_u) as u8, n as u8]),
_ => fail!(fmt!("vint to write too big: %?", n)) _ => fail!("vint to write too big: %?", n)
}; };
} }
@ -656,7 +656,7 @@ pub mod writer {
if n < 0x4000_u { write_sized_vuint(w, n, 2u); return; } if n < 0x4000_u { write_sized_vuint(w, n, 2u); return; }
if n < 0x200000_u { write_sized_vuint(w, n, 3u); return; } if n < 0x200000_u { write_sized_vuint(w, n, 3u); return; }
if n < 0x10000000_u { write_sized_vuint(w, n, 4u); return; } if n < 0x10000000_u { write_sized_vuint(w, n, 4u); return; }
fail!(fmt!("vint to write too big: %?", n)); fail!("vint to write too big: %?", n);
} }
#[cfg(stage0)] #[cfg(stage0)]
@ -847,17 +847,17 @@ pub mod writer {
// FIXME (#2742): implement these // FIXME (#2742): implement these
fn emit_f64(&mut self, _v: f64) { fn emit_f64(&mut self, _v: f64) {
fail!(~"Unimplemented: serializing an f64"); fail!("Unimplemented: serializing an f64");
} }
fn emit_f32(&mut self, _v: f32) { fn emit_f32(&mut self, _v: f32) {
fail!(~"Unimplemented: serializing an f32"); fail!("Unimplemented: serializing an f32");
} }
fn emit_float(&mut self, _v: float) { fn emit_float(&mut self, _v: float) {
fail!(~"Unimplemented: serializing a float"); fail!("Unimplemented: serializing a float");
} }
fn emit_char(&mut self, _v: char) { fn emit_char(&mut self, _v: char) {
fail!(~"Unimplemented: serializing a char"); fail!("Unimplemented: serializing a char");
} }
fn emit_str(&mut self, v: &str) { fn emit_str(&mut self, v: &str) {
@ -954,15 +954,15 @@ pub mod writer {
} }
fn emit_map(&mut self, _len: uint, _f: &fn(&mut Encoder)) { fn emit_map(&mut self, _len: uint, _f: &fn(&mut Encoder)) {
fail!(~"emit_map is unimplemented"); fail!("emit_map is unimplemented");
} }
fn emit_map_elt_key(&mut self, _idx: uint, _f: &fn(&mut Encoder)) { fn emit_map_elt_key(&mut self, _idx: uint, _f: &fn(&mut Encoder)) {
fail!(~"emit_map_elt_key is unimplemented"); fail!("emit_map_elt_key is unimplemented");
} }
fn emit_map_elt_val(&mut self, _idx: uint, _f: &fn(&mut Encoder)) { fn emit_map_elt_val(&mut self, _idx: uint, _f: &fn(&mut Encoder)) {
fail!(~"emit_map_elt_val is unimplemented"); fail!("emit_map_elt_val is unimplemented");
} }
} }
} }

View file

@ -598,7 +598,7 @@ mod test {
let expected_path = match line { let expected_path = match line {
"1" | "2" => copy filenames[0], "1" | "2" => copy filenames[0],
"3" | "4" => copy filenames[2], "3" | "4" => copy filenames[2],
_ => fail!(~"unexpected line") _ => fail!("unexpected line")
}; };
assert_eq!(copy state.current_path, expected_path); assert_eq!(copy state.current_path, expected_path);
count += 1; count += 1;

View file

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

View file

@ -67,14 +67,14 @@ pub impl<A> Future<A> {
{ {
match self.state { match self.state {
Forced(ref mut v) => { return cast::transmute(v); } Forced(ref mut v) => { return cast::transmute(v); }
Evaluating => fail!(~"Recursive forcing of future!"), Evaluating => fail!("Recursive forcing of future!"),
Pending(_) => {} Pending(_) => {}
} }
} }
{ {
let state = replace(&mut self.state, Evaluating); let state = replace(&mut self.state, Evaluating);
match state { match state {
Forced(_) | Evaluating => fail!(~"Logic error."), Forced(_) | Evaluating => fail!("Logic error."),
Pending(f) => { Pending(f) => {
self.state = Forced(f()); self.state = Forced(f());
cast::transmute(self.get_ref()) cast::transmute(self.get_ref())

View file

@ -554,7 +554,7 @@ pub mod groups {
_} = copy *lopt; _} = copy *lopt;
match (short_name.len(), long_name.len()) { match (short_name.len(), long_name.len()) {
(0,0) => fail!(~"this long-format option was given no name"), (0,0) => fail!("this long-format option was given no name"),
(0,_) => ~[Opt {name: Long((long_name)), (0,_) => ~[Opt {name: Long((long_name)),
hasarg: hasarg, hasarg: hasarg,
@ -571,7 +571,7 @@ pub mod groups {
hasarg: hasarg, hasarg: hasarg,
occur: occur}], occur: occur}],
(_,_) => fail!(~"something is wrong with the long-form opt") (_,_) => fail!("something is wrong with the long-form opt")
} }
} }
@ -603,7 +603,7 @@ pub mod groups {
row += match short_name.len() { row += match short_name.len() {
0 => ~"", 0 => ~"",
1 => ~"-" + short_name + " ", 1 => ~"-" + short_name + " ",
_ => fail!(~"the short name should only be 1 ascii char long"), _ => fail!("the short name should only be 1 ascii char long"),
}; };
// long option // long option
@ -686,7 +686,7 @@ mod tests {
assert!((opt_present(m, ~"test"))); assert!((opt_present(m, ~"test")));
assert!((opt_str(m, ~"test") == ~"20")); assert!((opt_str(m, ~"test") == ~"20"));
} }
_ => { fail!(~"test_reqopt_long failed"); } _ => { fail!("test_reqopt_long failed"); }
} }
} }

View file

@ -853,7 +853,7 @@ impl serialize::Decoder for Decoder {
debug!("read_nil"); debug!("read_nil");
match self.stack.pop() { match self.stack.pop() {
Null => (), Null => (),
value => fail!(fmt!("not a null: %?", value)) value => fail!("not a null: %?", value)
} }
} }
@ -873,7 +873,7 @@ impl serialize::Decoder for Decoder {
debug!("read_bool"); debug!("read_bool");
match self.stack.pop() { match self.stack.pop() {
Boolean(b) => b, Boolean(b) => b,
value => fail!(fmt!("not a boolean: %?", value)) value => fail!("not a boolean: %?", value)
} }
} }
@ -883,14 +883,14 @@ impl serialize::Decoder for Decoder {
debug!("read_float"); debug!("read_float");
match self.stack.pop() { match self.stack.pop() {
Number(f) => f, Number(f) => f,
value => fail!(fmt!("not a number: %?", value)) value => fail!("not a number: %?", value)
} }
} }
fn read_char(&mut self) -> char { fn read_char(&mut self) -> char {
let mut v = ~[]; let mut v = ~[];
for str::each_char(self.read_str()) |c| { v.push(c) } for str::each_char(self.read_str()) |c| { v.push(c) }
if v.len() != 1 { fail!(~"string must have one character") } if v.len() != 1 { fail!("string must have one character") }
v[0] v[0]
} }
@ -898,7 +898,7 @@ impl serialize::Decoder for Decoder {
debug!("read_str"); debug!("read_str");
match self.stack.pop() { match self.stack.pop() {
String(s) => s, String(s) => s,
json => fail!(fmt!("not a string: %?", json)) json => fail!("not a string: %?", json)
} }
} }
@ -920,14 +920,14 @@ impl serialize::Decoder for Decoder {
} }
match self.stack.pop() { match self.stack.pop() {
String(s) => s, String(s) => s,
value => fail!(fmt!("invalid variant name: %?", value)), value => fail!("invalid variant name: %?", value),
} }
} }
ref json => fail!(fmt!("invalid variant: %?", *json)), ref json => fail!("invalid variant: %?", *json),
}; };
let idx = match vec::position(names, |n| str::eq_slice(*n, name)) { let idx = match vec::position(names, |n| str::eq_slice(*n, name)) {
Some(idx) => idx, Some(idx) => idx,
None => fail!(fmt!("Unknown variant name: %?", name)), None => fail!("Unknown variant name: %?", name),
}; };
f(self, idx) f(self, idx)
} }
@ -979,7 +979,7 @@ impl serialize::Decoder for Decoder {
Object(obj) => { Object(obj) => {
let mut obj = obj; let mut obj = obj;
let value = match obj.pop(&name.to_owned()) { let value = match obj.pop(&name.to_owned()) {
None => fail!(fmt!("no such field: %s", name)), None => fail!("no such field: %s", name),
Some(json) => { Some(json) => {
self.stack.push(json); self.stack.push(json);
f(self) f(self)
@ -988,7 +988,7 @@ impl serialize::Decoder for Decoder {
self.stack.push(Object(obj)); self.stack.push(Object(obj));
value value
} }
value => fail!(fmt!("not an object: %?", value)) value => fail!("not an object: %?", value)
} }
} }
@ -1038,7 +1038,7 @@ impl serialize::Decoder for Decoder {
} }
len len
} }
_ => fail!(~"not a list"), _ => fail!("not a list"),
}; };
f(self, len) f(self, len)
} }
@ -1060,7 +1060,7 @@ impl serialize::Decoder for Decoder {
} }
len len
} }
json => fail!(fmt!("not an object: %?", json)), json => fail!("not an object: %?", json),
}; };
f(self, len) f(self, len)
} }

View file

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

View file

@ -59,14 +59,14 @@ pub fn format_addr(ip: &IpAddr) -> ~str {
Ipv4(ref addr) => unsafe { Ipv4(ref addr) => unsafe {
let result = uv_ip4_name(addr); let result = uv_ip4_name(addr);
if result == ~"" { if result == ~"" {
fail!(~"failed to convert inner sockaddr_in address to str") fail!("failed to convert inner sockaddr_in address to str")
} }
result result
}, },
Ipv6(ref addr) => unsafe { Ipv6(ref addr) => unsafe {
let result = uv_ip6_name(addr); let result = uv_ip6_name(addr);
if result == ~"" { if result == ~"" {
fail!(~"failed to convert inner sockaddr_in address to str") fail!("failed to convert inner sockaddr_in address to str")
} }
result result
} }
@ -394,7 +394,7 @@ mod test {
assert!(true); assert!(true);
} }
result::Ok(ref addr) => { result::Ok(ref addr) => {
fail!(fmt!("Expected failure, but got addr %?", addr)); fail!("Expected failure, but got addr %?", addr);
} }
} }
} }
@ -407,7 +407,7 @@ mod test {
assert!(true); assert!(true);
} }
result::Ok(ref addr) => { result::Ok(ref addr) => {
fail!(fmt!("Expected failure, but got addr %?", addr)); fail!("Expected failure, but got addr %?", addr);
} }
} }
} }
@ -418,7 +418,7 @@ mod test {
let iotask = &uv::global_loop::get(); let iotask = &uv::global_loop::get();
let ga_result = get_addr(localhost_name, iotask); let ga_result = get_addr(localhost_name, iotask);
if result::is_err(&ga_result) { if result::is_err(&ga_result) {
fail!(~"got err result from net::ip::get_addr();") fail!("got err result from net::ip::get_addr();")
} }
// note really sure how to reliably test/assert // note really sure how to reliably test/assert
// this.. mostly just wanting to see it work, atm. // this.. mostly just wanting to see it work, atm.

View file

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

View file

@ -48,7 +48,7 @@ impl<T: Copy + Num + Ord>
#[inline(always)] #[inline(always)]
pub fn new(numer: T, denom: T) -> Ratio<T> { pub fn new(numer: T, denom: T) -> Ratio<T> {
if denom == Zero::zero() { if denom == Zero::zero() {
fail!(~"denominator == 0"); fail!("denominator == 0");
} }
let mut ret = Ratio::new_raw(numer, denom); let mut ret = Ratio::new_raw(numer, denom);
ret.reduce(); ret.reduce();

View file

@ -581,7 +581,7 @@ impl<T:Copy + Ord> MergeState<T> {
shift_vec(array, dest, c2, len2); shift_vec(array, dest, c2, len2);
swap(&mut array[dest+len2], &mut tmp[c1]); swap(&mut array[dest+len2], &mut tmp[c1]);
} else if len1 == 0 { } else if len1 == 0 {
fail!(~"Comparison violates its contract!"); fail!("Comparison violates its contract!");
} else { } else {
assert!(len2 == 0); assert!(len2 == 0);
assert!(len1 > 1); assert!(len1 > 1);
@ -703,7 +703,7 @@ impl<T:Copy + Ord> MergeState<T> {
shift_vec(array, dest+1, c1+1, len1); shift_vec(array, dest+1, c1+1, len1);
swap(&mut array[dest], &mut tmp[c2]); swap(&mut array[dest], &mut tmp[c2]);
} else if len2 == 0 { } else if len2 == 0 {
fail!(~"Comparison violates its contract!"); fail!("Comparison violates its contract!");
} else { } else {
assert!(len1 == 0); assert!(len1 == 0);
assert!(len2 != 0); assert!(len2 != 0);
@ -949,7 +949,7 @@ mod test_tim_sort {
fn lt(&self, other: &CVal) -> bool { fn lt(&self, other: &CVal) -> bool {
let mut rng = rand::rng(); let mut rng = rand::rng();
if rng.gen::<float>() > 0.995 { if rng.gen::<float>() > 0.995 {
fail!(~"It's happening!!!"); fail!("It's happening!!!");
} }
(*self).val < other.val (*self).val < other.val
} }
@ -1004,7 +1004,7 @@ mod test_tim_sort {
}; };
tim_sort(arr); tim_sort(arr);
fail!(~"Guarantee the fail"); fail!("Guarantee the fail");
} }
struct DVal { val: uint } struct DVal { val: uint }
@ -1065,7 +1065,7 @@ mod big_tests {
fn isSorted<T:Ord>(arr: &[T]) { fn isSorted<T:Ord>(arr: &[T]) {
for uint::range(0, arr.len()-1) |i| { for uint::range(0, arr.len()-1) |i| {
if arr[i] > arr[i+1] { if arr[i] > arr[i+1] {
fail!(~"Array not sorted"); fail!("Array not sorted");
} }
} }
} }
@ -1136,7 +1136,7 @@ mod big_tests {
fn isSorted<T:Ord>(arr: &[@T]) { fn isSorted<T:Ord>(arr: &[@T]) {
for uint::range(0, arr.len()-1) |i| { for uint::range(0, arr.len()-1) |i| {
if arr[i] > arr[i+1] { if arr[i] > arr[i+1] {
fail!(~"Array not sorted"); fail!("Array not sorted");
} }
} }
} }
@ -1219,7 +1219,7 @@ mod big_tests {
local_data::local_data_set(self.key, @(y+1)); local_data::local_data_set(self.key, @(y+1));
} }
} }
_ => fail!(~"Expected key to work"), _ => fail!("Expected key to work"),
} }
} }
} }

View file

@ -577,7 +577,7 @@ impl<T:Copy + Ord> MergeState<T> {
copy_vec(array, dest, array, c2, len2); copy_vec(array, dest, array, c2, len2);
util::swap(&mut array[dest+len2], &mut tmp[c1]); util::swap(&mut array[dest+len2], &mut tmp[c1]);
} else if len1 == 0 { } else if len1 == 0 {
fail!(~"Comparison violates its contract!"); fail!("Comparison violates its contract!");
} else { } else {
assert!(len2 == 0); assert!(len2 == 0);
assert!(len1 > 1); assert!(len1 > 1);
@ -699,7 +699,7 @@ impl<T:Copy + Ord> MergeState<T> {
copy_vec(array, dest+1, array, c1+1, len1); copy_vec(array, dest+1, array, c1+1, len1);
util::swap(&mut array[dest], &mut tmp[c2]); util::swap(&mut array[dest], &mut tmp[c2]);
} else if len2 == 0 { } else if len2 == 0 {
fail!(~"Comparison violates its contract!"); fail!("Comparison violates its contract!");
} else { } else {
assert!(len1 == 0); assert!(len1 == 0);
assert!(len2 != 0); assert!(len2 != 0);
@ -941,7 +941,7 @@ mod test_tim_sort {
impl Ord for CVal { impl Ord for CVal {
fn lt(&self, other: &CVal) -> bool { fn lt(&self, other: &CVal) -> bool {
let rng = rand::rng(); let rng = rand::rng();
if rng.gen::<float>() > 0.995 { fail!(~"It's happening!!!"); } if rng.gen::<float>() > 0.995 { fail!("It's happening!!!"); }
(*self).val < other.val (*self).val < other.val
} }
fn le(&self, other: &CVal) -> bool { (*self).val <= other.val } fn le(&self, other: &CVal) -> bool { (*self).val <= other.val }
@ -995,7 +995,7 @@ mod test_tim_sort {
}; };
tim_sort(arr); tim_sort(arr);
fail!(~"Guarantee the fail"); fail!("Guarantee the fail");
} }
struct DVal { val: uint } struct DVal { val: uint }
@ -1056,7 +1056,7 @@ mod big_tests {
fn isSorted<T:Ord>(arr: &const [T]) { fn isSorted<T:Ord>(arr: &const [T]) {
for uint::range(0, arr.len()-1) |i| { for uint::range(0, arr.len()-1) |i| {
if arr[i] > arr[i+1] { if arr[i] > arr[i+1] {
fail!(~"Array not sorted"); fail!("Array not sorted");
} }
} }
} }
@ -1127,7 +1127,7 @@ mod big_tests {
fn isSorted<T:Ord>(arr: &const [@T]) { fn isSorted<T:Ord>(arr: &const [@T]) {
for uint::range(0, arr.len()-1) |i| { for uint::range(0, arr.len()-1) |i| {
if arr[i] > arr[i+1] { if arr[i] > arr[i+1] {
fail!(~"Array not sorted"); fail!("Array not sorted");
} }
} }
} }
@ -1210,7 +1210,7 @@ mod big_tests {
local_data::local_data_set(self.key, @(y+1)); local_data::local_data_set(self.key, @(y+1));
} }
} }
_ => fail!(~"Expected key to work"), _ => fail!("Expected key to work"),
} }
} }
} }

View file

@ -329,11 +329,11 @@ fn check_cvar_bounds<U>(out_of_bounds: Option<uint>, id: uint, act: &str,
blk: &fn() -> U) -> U { blk: &fn() -> U) -> U {
match out_of_bounds { match out_of_bounds {
Some(0) => Some(0) =>
fail!(fmt!("%s with illegal ID %u - this lock has no condvars!", fail!("%s with illegal ID %u - this lock has no condvars!",
act, id)), act, id),
Some(length) => Some(length) =>
fail!(fmt!("%s with illegal ID %u - ID must be less than %u", fail!("%s with illegal ID %u - ID must be less than %u",
act, id, length)), act, id, length),
None => blk() None => blk()
} }
} }
@ -578,7 +578,7 @@ pub impl RWlock {
token: RWlockWriteMode<'a>) token: RWlockWriteMode<'a>)
-> RWlockReadMode<'a> { -> RWlockReadMode<'a> {
if !ptr::ref_eq(self, token.lock) { if !ptr::ref_eq(self, token.lock) {
fail!(~"Can't downgrade() with a different rwlock's write_mode!"); fail!("Can't downgrade() with a different rwlock's write_mode!");
} }
unsafe { unsafe {
do task::unkillable { do task::unkillable {

View file

@ -89,7 +89,7 @@ pub fn test_main(args: &[~str], tests: ~[TestDescAndFn]) {
either::Left(o) => o, either::Left(o) => o,
either::Right(m) => fail!(m) either::Right(m) => fail!(m)
}; };
if !run_tests_console(&opts, tests) { fail!(~"Some tests failed"); } if !run_tests_console(&opts, tests) { fail!("Some tests failed"); }
} }
// A variant optimized for invocation with a static test vector. // A variant optimized for invocation with a static test vector.
@ -109,7 +109,7 @@ pub fn test_main_static(args: &[~str], tests: &[TestDescAndFn]) {
TestDescAndFn { testfn: StaticBenchFn(f), desc: copy t.desc }, TestDescAndFn { testfn: StaticBenchFn(f), desc: copy t.desc },
_ => { _ => {
fail!(~"non-static tests passed to test::test_main_static"); fail!("non-static tests passed to test::test_main_static");
} }
} }
}; };
@ -250,7 +250,7 @@ pub fn run_tests_console(opts: &TestOpts,
io::Truncate]) { io::Truncate]) {
result::Ok(w) => Some(w), result::Ok(w) => Some(w),
result::Err(ref s) => { result::Err(ref s) => {
fail!(fmt!("can't open output file: %s", *s)) fail!("can't open output file: %s", *s)
} }
}, },
None => None None => None
@ -849,7 +849,7 @@ mod tests {
let args = ~[~"progname", ~"filter"]; let args = ~[~"progname", ~"filter"];
let opts = match parse_opts(args) { let opts = match parse_opts(args) {
either::Left(copy o) => o, either::Left(copy o) => o,
_ => fail!(~"Malformed arg in first_free_arg_should_be_a_filter") _ => fail!("Malformed arg in first_free_arg_should_be_a_filter")
}; };
assert!("filter" == (copy opts.filter).get()); assert!("filter" == (copy opts.filter).get());
} }
@ -859,7 +859,7 @@ mod tests {
let args = ~[~"progname", ~"filter", ~"--ignored"]; let args = ~[~"progname", ~"filter", ~"--ignored"];
let opts = match parse_opts(args) { let opts = match parse_opts(args) {
either::Left(copy o) => o, either::Left(copy o) => o,
_ => fail!(~"Malformed arg in parse_ignored_flag") _ => fail!("Malformed arg in parse_ignored_flag")
}; };
assert!((opts.run_ignored)); assert!((opts.run_ignored));
} }

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