diff options
| author | Björn Steinbrink <bsteinbr@gmail.com> | 2013-05-06 00:18:51 +0200 |
|---|---|---|
| committer | Björn Steinbrink <bsteinbr@gmail.com> | 2013-05-14 16:36:23 +0200 |
| commit | bdc182cc41c2741edc6fdc4ec09b8522479aab40 (patch) | |
| tree | e4d26bbc1b47702ef46cd01bbaa5b5dad8633416 /src/libcore | |
| parent | 84745b483f322671f894b9e8d0a462c46275a9d3 (diff) | |
| download | rust-bdc182cc41c2741edc6fdc4ec09b8522479aab40.tar.gz rust-bdc182cc41c2741edc6fdc4ec09b8522479aab40.zip | |
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.
Diffstat (limited to 'src/libcore')
29 files changed, 123 insertions, 125 deletions
diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 6f0e03fb895..cacde5535db 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -46,7 +46,7 @@ pub impl<T> Cell<T> { fn take(&self) -> T { let this = unsafe { transmute_mut(self) }; if this.is_empty() { - fail!(~"attempt to take an empty cell"); + fail!("attempt to take an empty cell"); } replace(&mut this.value, None).unwrap() @@ -56,7 +56,7 @@ pub impl<T> Cell<T> { fn put_back(&self, value: T) { let this = unsafe { transmute_mut(self) }; 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); } diff --git a/src/libcore/char.rs b/src/libcore/char.rs index a9c46b81f86..68f283f1ad8 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -145,7 +145,7 @@ pub fn is_digit_radix(c: char, radix: uint) -> bool { #[inline] pub fn to_digit(c: char, radix: uint) -> Option<uint> { 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 { '0' .. '9' => c as uint - ('0' as uint), @@ -168,7 +168,7 @@ pub fn to_digit(c: char, radix: uint) -> Option<uint> { #[inline] pub fn from_digit(num: uint, radix: uint) -> Option<char> { 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 < 10 { @@ -241,7 +241,7 @@ pub fn len_utf8_bytes(c: char) -> uint { else if code < max_two_b { 2u } else if code < max_three_b { 3u } else if code < max_four_b { 4u } - else { fail!(~"invalid character!") } + else { fail!("invalid character!") } } #[cfg(not(test))] diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index f4eb856865d..34c60202b3f 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -210,7 +210,7 @@ impl<T: Owned> Peekable<T> for Port<T> { let mut endp = replace(self_endp, None); let peek = match endp { Some(ref mut endp) => peek(endp), - None => fail!(~"peeking empty stream") + None => fail!("peeking empty stream") }; *self_endp = endp; peek @@ -222,7 +222,7 @@ impl<T: Owned> Selectable for Port<T> { fn header(&mut self) -> *mut PacketHeader { match self.endp { 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) { 0 => Left(()), 1 => Right(()), - _ => fail!(~"wait returned unexpected index"), + _ => fail!("wait returned unexpected index"), } } diff --git a/src/libcore/either.rs b/src/libcore/either.rs index 1e29311e645..618a484a515 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -135,7 +135,7 @@ pub fn unwrap_left<T,U>(eith: Either<T,U>) -> T { match eith { 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 { Right(x) => x, - Left(_) => fail!(~"either::unwrap_right Left") + Left(_) => fail!("either::unwrap_right Left") } } diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index 590d4ab3bcb..264b2a78965 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -200,7 +200,7 @@ priv impl<K:Hash + Eq,V> HashMap<K, V> { fn value_for_bucket<'a>(&'a self, idx: uint) -> &'a V { match self.buckets[idx] { 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 fn insert_internal(&mut self, hash: uint, k: K, v: V) -> Option<V> { match self.bucket_for_key_with_hash(hash, &k) { - TableFull => { fail!(~"Internal logic error"); } + TableFull => { fail!("Internal logic error"); } FoundHole(idx) => { debug!("insert fresh (%?->%?) at 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 %?", k, v, idx, hash); match self.buckets[idx] { - None => { fail!(~"insert_internal: Internal logic error") } + None => { fail!("insert_internal: Internal logic error") } Some(ref mut b) => { b.hash = hash; 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 idx = match self.bucket_for_key_with_hash(hash, &k) { - TableFull => fail!(~"Internal logic error"), + TableFull => fail!("Internal logic error"), FoundEntry(idx) => idx, FoundHole(idx) => { 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 idx = match self.bucket_for_key_with_hash(hash, &k) { - TableFull => fail!(~"Internal logic error"), + TableFull => fail!("Internal logic error"), FoundEntry(idx) => idx, FoundHole(idx) => { 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 idx = match self.bucket_for_key_with_hash(hash, &k) { - TableFull => fail!(~"Internal logic error"), + TableFull => fail!("Internal logic error"), FoundEntry(idx) => idx, FoundHole(idx) => { 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 idx = match self.bucket_for_key_with_hash(hash, &k) { - TableFull => fail!(~"Internal logic error"), + TableFull => fail!("Internal logic error"), FoundEntry(idx) => idx, FoundHole(idx) => { 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 { match self.find(k) { Some(v) => v, - None => fail!(fmt!("No entry found for key: %?", k)), + None => fail!("No entry found for key: %?", k), } } diff --git a/src/libcore/local_data.rs b/src/libcore/local_data.rs index d4b02a0ad9b..a440a7f6410 100644 --- a/src/libcore/local_data.rs +++ b/src/libcore/local_data.rs @@ -132,15 +132,15 @@ fn test_tls_modify() { fn my_key(_x: @~str) { } local_data_modify(my_key, |data| { match data { - Some(@ref val) => fail!(~"unwelcome value: " + *val), + Some(@ref val) => fail!("unwelcome value: %s", *val), None => Some(@~"first data") } }); local_data_modify(my_key, |data| { match data { Some(@~"first data") => Some(@~"next data"), - Some(@ref val) => fail!(~"wrong value: " + *val), - None => fail!(~"missing value") + Some(@ref val) => fail!("wrong value: %s", *val), + None => fail!("missing value") } }); assert!(*(local_data_pop(my_key).get()) == ~"next data"); @@ -223,4 +223,4 @@ fn test_static_pointer() { static VALUE: int = 0; local_data_set(key, @&VALUE); } -} \ No newline at end of file +} diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 21e55af39eb..af30e87bb0c 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -772,7 +772,7 @@ pub fn to_str_hex(num: f32) -> ~str { pub fn to_str_radix(num: f32, rdx: uint) -> ~str { let (r, special) = strconv::to_str_common( &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") } r } diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 3c9df4040d8..240d84b8403 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -814,7 +814,7 @@ pub fn to_str_hex(num: f64) -> ~str { pub fn to_str_radix(num: f64, rdx: uint) -> ~str { let (r, special) = strconv::to_str_common( &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") } r } diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs index 22abc76c3d3..8b3c7b1e79e 100644 --- a/src/libcore/num/float.rs +++ b/src/libcore/num/float.rs @@ -133,7 +133,7 @@ pub fn to_str_hex(num: float) -> ~str { pub fn to_str_radix(num: float, radix: uint) -> ~str { let (r, special) = strconv::to_str_common( &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") } r } diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index f2bba6a4639..348f72f9f0a 100644 --- a/src/libcore/num/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -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 { let mut i = start; if step == 0 { - fail!(~"range_step called with step == 0"); + fail!("range_step called with step == 0"); } else if step > 0 { // ascending while i < stop { if !it(i) { return false; } @@ -923,16 +923,16 @@ mod tests { // None of the `fail`s should execute. for range(10,0) |_i| { - fail!(~"unreachable"); + fail!("unreachable"); } for range_rev(0,10) |_i| { - fail!(~"unreachable"); + fail!("unreachable"); } for range_step(10,0,1) |_i| { - fail!(~"unreachable"); + fail!("unreachable"); } for range_step(0,10,-1) |_i| { - fail!(~"unreachable"); + fail!("unreachable"); } } diff --git a/src/libcore/num/strconv.rs b/src/libcore/num/strconv.rs index 5ed99a83995..044b0d4a36c 100644 --- a/src/libcore/num/strconv.rs +++ b/src/libcore/num/strconv.rs @@ -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, sign: SignFormat, digits: SignificantDigits) -> (~[u8], bool) { if (radix as int) < 2 { - fail!(fmt!("to_str_bytes_common: radix %? to low, \ - must lie in the range [2, 36]", radix)); + fail!("to_str_bytes_common: radix %? to low, \ + must lie in the range [2, 36]", radix); } else if radix as int > 36 { - fail!(fmt!("to_str_bytes_common: radix %? to high, \ - must lie in the range [2, 36]", radix)); + fail!("to_str_bytes_common: radix %? to high, \ + must lie in the range [2, 36]", radix); } 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> { match exponent { ExpDec if radix >= DIGIT_E_RADIX // decimal exponent 'e' - => fail!(fmt!("from_str_bytes_common: radix %? incompatible with \ - use of 'e' as decimal exponent", radix)), + => fail!("from_str_bytes_common: radix %? incompatible with \ + use of 'e' as decimal exponent", radix), ExpBin if radix >= DIGIT_P_RADIX // binary exponent 'p' - => fail!(fmt!("from_str_bytes_common: radix %? incompatible with \ - use of 'p' as binary exponent", radix)), + => fail!("from_str_bytes_common: radix %? incompatible with \ + use of 'p' as binary exponent", radix), _ if special && radix >= DIGIT_I_RADIX // first digit of 'inf' - => fail!(fmt!("from_str_bytes_common: radix %? incompatible with \ - special values 'inf' and 'NaN'", radix)), + => fail!("from_str_bytes_common: radix %? incompatible with \ + special values 'inf' and 'NaN'", radix), _ if (radix as int) < 2 - => fail!(fmt!("from_str_bytes_common: radix %? to low, \ - must lie in the range [2, 36]", radix)), + => fail!("from_str_bytes_common: radix %? to low, \ + must lie in the range [2, 36]", radix), _ if (radix as int) > 36 - => fail!(fmt!("from_str_bytes_common: radix %? to high, \ - must lie in the range [2, 36]", radix)), + => fail!("from_str_bytes_common: radix %? to high, \ + must lie in the range [2, 36]", radix), _ => () } diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs index 1c115ee5072..da0815c264b 100644 --- a/src/libcore/num/uint-template.rs +++ b/src/libcore/num/uint-template.rs @@ -57,7 +57,7 @@ pub fn _range_step(start: T, it: &fn(T) -> bool) -> bool { let mut i = start; if step == 0 { - fail!(~"range_step called with step == 0"); + fail!("range_step called with step == 0"); } if step >= 0 { while i < stop { @@ -630,16 +630,16 @@ mod tests { // None of the `fail`s should execute. for range(0,0) |_i| { - fail!(~"unreachable"); + fail!("unreachable"); } for range_rev(0,0) |_i| { - fail!(~"unreachable"); + fail!("unreachable"); } for range_step(10,0,1) |_i| { - fail!(~"unreachable"); + fail!("unreachable"); } for range_step(0,1,-10) |_i| { - fail!(~"unreachable"); + fail!("unreachable"); } } diff --git a/src/libcore/old_iter.rs b/src/libcore/old_iter.rs index 13d8fd26654..7cffcb10a53 100644 --- a/src/libcore/old_iter.rs +++ b/src/libcore/old_iter.rs @@ -269,7 +269,7 @@ pub fn min<A:Copy + Ord,IA:BaseIter<A>>(this: &IA) -> A { } } { 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, - None => fail!(~"max called on empty iterator") + None => fail!("max called on empty iterator") } } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index e171552af4c..9aaa2921fe7 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -265,7 +265,7 @@ pub impl<T> Option<T> { fn get_ref<'a>(&'a self) -> &'a T { match *self { 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 { match *self { 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 { Some(x) => x, - None => fail!(~"option::unwrap none") + None => fail!("option::unwrap none") } } @@ -325,7 +325,7 @@ pub impl<T> Option<T> { */ #[inline(always)] 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() } @@ -365,7 +365,7 @@ pub impl<T:Copy> Option<T> { fn get(self) -> T { match self { Some(copy x) => return x, - None => fail!(~"option::get none") + None => fail!("option::get none") } } diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 3e87f4f8dbb..c512372d7c6 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -178,8 +178,8 @@ pub fn env() -> ~[(~str,~str)] { }; let ch = GetEnvironmentStringsA(); if (ch as uint == 0) { - fail!(fmt!("os::env() failure getting env string from OS: %s", - os::last_os_error())); + fail!("os::env() failure getting env string from OS: %s", + os::last_os_error()); } let mut curr_ptr: uint = ch as uint; let mut result = ~[]; @@ -201,8 +201,8 @@ pub fn env() -> ~[(~str,~str)] { } let environ = rust_env_pairs(); if (environ as uint == 0) { - fail!(fmt!("os::env() failure getting env string from OS: %s", - os::last_os_error())); + fail!("os::env() failure getting env string from OS: %s", + os::last_os_error()); } let mut result = ~[]; ptr::array_each(environ, |e| { @@ -744,8 +744,7 @@ pub fn list_dir(p: &Path) -> ~[~str] { while more_files != 0 { let fp_buf = rust_list_dir_wfd_fp_buf(wfd_ptr); if fp_buf as uint == 0 { - fail!(~"os::list_dir() failure:"+ - ~" got null ptr from wfd"); + fail!("os::list_dir() failure: got null ptr from wfd"); } else { 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], TMPBUF_SZ as size_t); if err < 0 { - fail!(~"strerror_r failure"); + fail!("strerror_r failure"); } str::raw::from_c_str(&buf[0]) @@ -1100,7 +1099,7 @@ pub fn last_os_error() -> ~str { &mut buf[0], TMPBUF_SZ as DWORD, ptr::null()); if res == 0 { - fail!(fmt!("[%?] FormatMessage failure", errno())); + fail!("[%?] FormatMessage failure", errno()); } 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 #[cfg(target_os = "win32")] pub fn glob(pattern: &str) -> ~[Path] { - fail!(~"glob() is unimplemented on Windows") + fail!("glob() is unimplemented on Windows") } #[cfg(target_os = "macos")] @@ -1638,7 +1637,7 @@ mod tests { let in_mode = in.get_mode(); let rs = os::copy_file(&in, &out); if (!os::path_exists(&in)) { - fail!(fmt!("%s doesn't exist", in.to_str())); + fail!("%s doesn't exist", in.to_str()); } assert!((rs)); let rslt = run::run_program(~"diff", ~[in.to_str(), out.to_str()]); diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index fb80a43347e..c0cf4c052c5 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -281,7 +281,7 @@ fn wait_event(this: *rust_task) -> *libc::c_void { let killed = rustrt::task_wait_event(this, &mut event); if killed && !task::failing() { - fail!(~"killed") + fail!("killed") } event } @@ -365,7 +365,7 @@ pub fn send<T,Tbuffer>(mut p: SendPacketBuffered<T,Tbuffer>, //unsafe { forget(p); } return true; } - Full => fail!(~"duplicate send"), + Full => fail!("duplicate send"), Blocked => { debug!("waking up task for %?", p_); let old_task = swap_task(&mut p.header.blocked_task, ptr::null()); @@ -478,7 +478,7 @@ fn try_recv_<T:Owned>(p: &mut Packet<T>) -> Option<T> { debug!("woke up, p.state = %?", copy p.header.state); } Blocked => if first { - fail!(~"blocking on already blocked packet") + fail!("blocking on already blocked packet") }, Full => { 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 { match (*p.header()).state { Empty | Terminated => false, - Blocked => fail!(~"peeking on blocked packet"), + Blocked => fail!("peeking on blocked packet"), Full => true } } @@ -543,7 +543,7 @@ fn sender_terminate<T:Owned>(p: *mut Packet<T>) { } Full => { // This is impossible - fail!(~"you dun goofed") + fail!("you dun goofed") } Terminated => { assert!(p.header.blocked_task.is_null()); @@ -609,7 +609,7 @@ pub fn wait_many<T: Selectable>(pkts: &mut [T]) -> uint { (*p).state = old; break; } - Blocked => fail!(~"blocking on blocked packet"), + Blocked => fail!("blocking on blocked packet"), Empty => () } } @@ -704,7 +704,7 @@ pub impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> { let header = ptr::to_mut_unsafe_ptr(&mut packet.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); 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 { 0 => Left((try_recv(a), 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) { 0 => Left(()), 1 => Right(()), - _ => fail!(~"wait returned unexpected index") + _ => fail!("wait returned unexpected index") } } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 0aff6e06e69..9feb8676036 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -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)) { debug!("array_each_with_len: before iterate"); 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; 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)) { 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); debug!("array_each inferred len: %u", diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs index 0bf8635d1c8..53f51fe1da2 100644 --- a/src/libcore/repr.rs +++ b/src/libcore/repr.rs @@ -532,7 +532,7 @@ impl TyVisitor for ReprVisitor { -> bool { let var_stk: &mut ~[VariantState] = self.var_stk; match var_stk.pop() { - SearchingFor(*) => fail!(~"enum value matched no variant"), + SearchingFor(*) => fail!("enum value matched no variant"), _ => true } } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index b7de6678783..72704a429ed 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -42,7 +42,7 @@ pub fn get<T:Copy,U>(res: &Result<T, U>) -> T { match *res { Ok(copy t) => t, 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 { Ok(ref t) => t, 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 { match *res { 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 { match res { 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 { match res { Err(u) => u, - Ok(_) => fail!(~"unwrap called on an ok result") + Ok(_) => fail!("unwrap called on an ok result") } } diff --git a/src/libcore/rt/local_services.rs b/src/libcore/rt/local_services.rs index 01bef5e2458..bc945707e62 100644 --- a/src/libcore/rt/local_services.rs +++ b/src/libcore/rt/local_services.rs @@ -163,7 +163,7 @@ pub fn borrow_local_services(f: &fn(&mut LocalServices)) { f(&mut task.local_services) } 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) } None => { - fail!(~"no local services for schedulers yet") + fail!("no local services for schedulers yet") } } } diff --git a/src/libcore/rt/sched/mod.rs b/src/libcore/rt/sched/mod.rs index ba057254583..dda1f27550f 100644 --- a/src/libcore/rt/sched/mod.rs +++ b/src/libcore/rt/sched/mod.rs @@ -295,7 +295,7 @@ pub impl Scheduler { Some(DoNothing) => { 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 // because borrowck thinks the three patterns are conflicting diff --git a/src/libcore/run.rs b/src/libcore/run.rs index c865e77cc6b..c0c1698ebc0 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -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; 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, 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; 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, 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; 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, 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); @@ -252,7 +252,7 @@ fn spawn_process_internal(prog: &str, args: &[~str], CloseHandle(si.hStdError); 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, @@ -379,7 +379,7 @@ fn spawn_process_internal(prog: &str, args: &[~str], let pid = fork(); 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 { return RunProgramResult {pid: pid, handle: ptr::null()}; } @@ -387,13 +387,13 @@ fn spawn_process_internal(prog: &str, args: &[~str], rustrt::rust_unset_sigprocmask(); 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 { - 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 { - 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 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| { do str::as_c_str(*dir) |dirp| { 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| { execvp(*argv, argv); // 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; } (n, _) => { - fail!(fmt!("program_output received an unexpected file \ - number: %u", n)); + fail!("program_output received an unexpected file \ + number: %u", n); } }; count -= 1; @@ -713,14 +713,14 @@ pub fn waitpid(pid: pid_t) -> int { let proc = OpenProcess(SYNCHRONIZE | PROCESS_QUERY_INFORMATION, FALSE, pid as DWORD); if proc.is_null() { - fail!(fmt!("failure in OpenProcess: %s", os::last_os_error())); + fail!("failure in OpenProcess: %s", os::last_os_error()); } loop { let mut status = 0; if GetExitCodeProcess(proc, &mut status) == FALSE { 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 { CloseHandle(proc); @@ -728,7 +728,7 @@ pub fn waitpid(pid: pid_t) -> int { } if WaitForSingleObject(proc, INFINITE) == WAIT_FAILED { 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; 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) { diff --git a/src/libcore/str.rs b/src/libcore/str.rs index d31152e1e1c..ce6b7e495ee 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -1051,8 +1051,8 @@ pub fn _each_split_within<'a>(ss: &'a str, (B, Cr, UnderLim) => { B } (B, Cr, OverLim) if (i - last_start + 1) > lim - => fail!(fmt!("word starting with %? longer than limit!", - self::slice(ss, last_start, i + 1))), + => fail!("word starting with %? longer than limit!", + self::slice(ss, last_start, i + 1)), (B, Cr, OverLim) => { slice(); slice_start = last_start; B } (B, Ws, UnderLim) => { last_end = i; C } (B, Ws, OverLim) => { last_end = i; slice(); A } diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs index 1518f80a125..d57bd5528bc 100644 --- a/src/libcore/task/mod.rs +++ b/src/libcore/task/mod.rs @@ -198,7 +198,7 @@ pub fn task() -> TaskBuilder { priv impl TaskBuilder { fn consume(&mut self) -> TaskBuilder { 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; let gen_body = replace(&mut self.gen_body, None); @@ -263,7 +263,7 @@ pub impl TaskBuilder { // sending out messages. 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. @@ -494,7 +494,7 @@ pub fn yield() { let task_ = rt::rust_get_task(); let killed = rt::rust_task_yield(task_); if killed && !failing() { - fail!(~"killed"); + fail!("killed"); } } } diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 9a1689ca056..fc38702bc16 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -569,10 +569,10 @@ pub fn spawn_raw(opts: TaskOpts, f: ~fn()) { spawn_raw_newsched(opts, f) } SchedulerContext => { - fail!(~"can't spawn from scheduler context") + fail!("can't spawn from scheduler context") } 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 { 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 { @@ -719,11 +719,11 @@ fn spawn_raw_oldsched(mut opts: TaskOpts, f: ~fn()) { SingleThreaded => 1u, ThreadPerCore => unsafe { rt::rust_num_threads() }, ThreadPerTask => { - fail!(~"ThreadPerTask scheduling mode unimplemented") + fail!("ThreadPerTask scheduling mode unimplemented") } ManualThreads(threads) => { if threads == 0u { - fail!(~"can not create a scheduler with no threads"); + fail!("can not create a scheduler with no threads"); } threads } diff --git a/src/libcore/unstable/exchange_alloc.rs b/src/libcore/unstable/exchange_alloc.rs index 57ed579e88d..3b35c2fb804 100644 --- a/src/libcore/unstable/exchange_alloc.rs +++ b/src/libcore/unstable/exchange_alloc.rs @@ -46,7 +46,7 @@ stuff in exchange_alloc::malloc pub unsafe fn malloc_raw(size: uint) -> *c_void { let p = c_malloc(size as size_t); if p.is_null() { - fail!(~"Failure in malloc_raw: result ptr is null"); + fail!("Failure in malloc_raw: result ptr is null"); } p } diff --git a/src/libcore/unstable/sync.rs b/src/libcore/unstable/sync.rs index e22046f04f9..4d5c3bf7a78 100644 --- a/src/libcore/unstable/sync.rs +++ b/src/libcore/unstable/sync.rs @@ -198,8 +198,7 @@ pub impl<T:Owned> Exclusive<T> { let rec = self.x.get(); do (*rec).lock.lock { if (*rec).failed { - fail!( - ~"Poisoned exclusive - another task failed inside!"); + fail!("Poisoned exclusive - another task failed inside!"); } (*rec).failed = true; let result = f(&mut (*rec).data); diff --git a/src/libcore/util.rs b/src/libcore/util.rs index ba176872b9a..d270fb23aaa 100644 --- a/src/libcore/util.rs +++ b/src/libcore/util.rs @@ -171,7 +171,7 @@ fn choose_weighted_item(v: &[Item]) -> Item { */ pub fn unreachable() -> ! { - fail!(~"internal error: entered unreachable code"); + fail!("internal error: entered unreachable code"); } #[cfg(test)] diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 89f5b73953a..190b493a6f0 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -237,7 +237,7 @@ pub fn build_sized_opt<A>(size: Option<uint>, /// Returns the first element of a vector 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] } @@ -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. 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] } @@ -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 { let ln = v.len(); 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]); unsafe { @@ -601,7 +601,7 @@ pub fn pop<T>(v: &mut ~[T]) -> T { pub fn pop<T>(v: &mut ~[T]) -> T { let ln = v.len(); 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]); unsafe { @@ -620,7 +620,7 @@ pub fn pop<T>(v: &mut ~[T]) -> T { pub fn swap_remove<T>(v: &mut ~[T], index: uint) -> T { let ln = v.len(); if index >= ln { - 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 { swap(*v, index, ln - 1); |
