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/libstd | |
| 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/libstd')
| -rw-r--r-- | src/libstd/arc.rs | 4 | ||||
| -rw-r--r-- | src/libstd/base64.rs | 8 | ||||
| -rw-r--r-- | src/libstd/bitv.rs | 6 | ||||
| -rw-r--r-- | src/libstd/dlist.rs | 34 | ||||
| -rw-r--r-- | src/libstd/ebml.rs | 52 | ||||
| -rw-r--r-- | src/libstd/fileinput.rs | 2 | ||||
| -rw-r--r-- | src/libstd/flatpipes.rs | 6 | ||||
| -rw-r--r-- | src/libstd/future.rs | 4 | ||||
| -rw-r--r-- | src/libstd/getopts.rs | 8 | ||||
| -rw-r--r-- | src/libstd/json.rs | 24 | ||||
| -rw-r--r-- | src/libstd/list.rs | 4 | ||||
| -rw-r--r-- | src/libstd/net_ip.rs | 10 | ||||
| -rw-r--r-- | src/libstd/net_tcp.rs | 24 | ||||
| -rw-r--r-- | src/libstd/num/rational.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sort.rs | 14 | ||||
| -rw-r--r-- | src/libstd/sort_stage0.rs | 14 | ||||
| -rw-r--r-- | src/libstd/sync.rs | 10 | ||||
| -rw-r--r-- | src/libstd/test.rs | 10 | ||||
| -rw-r--r-- | src/libstd/timer.rs | 8 | ||||
| -rw-r--r-- | src/libstd/treemap.rs | 4 | ||||
| -rw-r--r-- | src/libstd/uv_global_loop.rs | 4 |
21 files changed, 123 insertions, 129 deletions
diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index d3f774a1cd5..df49771258e 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -208,9 +208,9 @@ pub impl<T:Owned> MutexARC<T> { fn check_poison(is_mutex: bool, failed: bool) { if failed { if is_mutex { - fail!(~"Poisoned MutexARC - another task failed inside!"); + fail!("Poisoned MutexARC - another task failed inside!"); } else { - fail!(~"Poisoned rw_arc - another task failed inside!"); + fail!("Poisoned rw_arc - another task failed inside!"); } } } diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index 85ba2707863..68242f88fae 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -82,7 +82,7 @@ impl<'self> ToBase64 for &'self [u8] { str::push_char(&mut s, CHARS[(n >> 6u) & 63u]); str::push_char(&mut s, '='); } - _ => fail!(~"Algebra is broken, please alert the math police") + _ => fail!("Algebra is broken, please alert the math police") } s } @@ -136,7 +136,7 @@ impl FromBase64 for ~[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 mut padding = 0u; @@ -173,10 +173,10 @@ impl FromBase64 for ~[u8] { r.push(((n >> 10u) & 0xFFu) as u8); return copy r; } - _ => fail!(~"invalid base64 padding") + _ => fail!("invalid base64 padding") } } - _ => fail!(~"invalid base64 character") + _ => fail!("invalid base64 character") } i += 1u; diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 09f86f30d32..e31818ecc1c 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -236,7 +236,7 @@ pub struct Bitv { } 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 { @@ -1308,7 +1308,7 @@ mod tests { let mut b = Bitv::new(14, true); b.clear(); 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); b.clear(); for b.ones |i| { - fail!(fmt!("found 1 at %?", i)); + fail!("found 1 at %?", i); } } diff --git a/src/libstd/dlist.rs b/src/libstd/dlist.rs index 741bd629680..84bd803afe7 100644 --- a/src/libstd/dlist.rs +++ b/src/libstd/dlist.rs @@ -40,18 +40,18 @@ priv impl<T> DListNode<T> { match self.next { Some(neighbour) => match neighbour.prev { 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 => () } match self.prev { Some(neighbour) => match neighbour.next { 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 => () } @@ -68,7 +68,7 @@ pub impl<T> DListNode<T> { fn next_node(@mut self) -> @mut DListNode<T> { match self.next_link() { 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. @@ -80,7 +80,7 @@ pub impl<T> DListNode<T> { fn prev_node(@mut self) -> @mut DListNode<T> { match self.prev_link() { 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, // but those wouldn't allow for O(1) append. 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() || managed::mut_ptr_eq(self.hd.expect(~"headless dlist?"), nobe)) && (nobe.next.is_some() || managed::mut_ptr_eq(self.tl.expect(~"tailless dlist?"), 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>) { 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; } @@ -318,16 +318,14 @@ pub impl<T> DList<T> { fn head_n(@mut self) -> @mut DListNode<T> { match self.hd { Some(nobe) => nobe, - None => fail!( - ~"Attempted to get the head of an empty dlist.") + None => fail!("Attempted to get the head of an empty dlist.") } } /// Get the node at the list's tail, failing if empty. O(1). fn tail_n(@mut self) -> @mut DListNode<T> { match self.tl { Some(nobe) => nobe, - None => fail!( - ~"Attempted to get the tail of an empty dlist.") + None => fail!("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>) { 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 { self.link(self.tl, them.hd); @@ -357,7 +355,7 @@ pub impl<T> DList<T> { */ fn prepend(@mut self, them: @mut DList<T>) { 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 { 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. if self.size == 0 { - fail!(~"The dlist became empty during iteration??") + fail!("The dlist became empty during iteration??") } if !nobe.linked || (!((nobe.prev.is_some() @@ -533,7 +531,7 @@ impl<T> BaseIter<T> for @mut DList<T> { && (nobe.next.is_some() || managed::mut_ptr_eq(self.tl.expect(~"tailless dlist?"), nobe)))) { - fail!(~"Removing a dlist node during iteration is forbidden!") + fail!("Removing a dlist node during iteration is forbidden!") } link = nobe.next_link(); } diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index 98618e4928b..842a434ada4 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -116,7 +116,7 @@ pub mod reader { (data[start + 3u] as uint), next: start + 4u}; } - fail!(~"vint too big"); + fail!("vint too big"); } #[cfg(target_arch = "x86")] @@ -319,9 +319,9 @@ pub mod reader { self.pos = r_doc.end; let str = doc_as_str(r_doc); if lbl != str { - fail!(fmt!("Expected label %s but found %s", + fail!("Expected label %s but found %s", lbl, - str)); + str); } } } @@ -330,7 +330,7 @@ pub mod reader { fn next_doc(&mut self, exp_tag: EbmlEncoderTag) -> Doc { debug!(". next_doc(exp_tag=%?)", exp_tag); 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 } = doc_at(self.parent.data, self.pos); @@ -338,12 +338,12 @@ pub mod reader { copy self.parent.start, copy self.parent.end, copy self.pos, r_tag, r_doc.start, r_doc.end); if r_tag != (exp_tag as uint) { - fail!(fmt!("expected EBML doc with tag %? but found tag %?", - exp_tag, r_tag)); + fail!("expected EBML doc with tag %? but found tag %?", + exp_tag, r_tag); } if r_doc.end > self.parent.end { - fail!(fmt!("invalid EBML, child extends to 0x%x, \ - parent to 0x%x", r_doc.end, self.parent.end)); + fail!("invalid EBML, child extends to 0x%x, \ + parent to 0x%x", r_doc.end, self.parent.end); } self.pos = r_doc.end; r_doc @@ -393,7 +393,7 @@ pub mod reader { fn read_uint(&mut self) -> uint { let v = doc_as_u64(self.next_doc(EsUint)); 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 } @@ -414,7 +414,7 @@ pub mod reader { let v = doc_as_u64(self.next_doc(EsInt)) as i64; if v > (int::max_value as i64) || v < (int::min_value as i64) { 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 } @@ -423,10 +423,10 @@ pub mod reader { doc_as_u8(self.next_doc(EsBool)) as bool } - fn read_f64(&mut self) -> f64 { fail!(~"read_f64()"); } - fn read_f32(&mut self) -> f32 { fail!(~"read_f32()"); } - fn read_float(&mut self) -> float { fail!(~"read_float()"); } - fn read_char(&mut self) -> char { fail!(~"read_char()"); } + fn read_f64(&mut self) -> f64 { fail!("read_f64()"); } + fn read_f32(&mut self) -> f32 { fail!("read_f32()"); } + fn read_float(&mut self) -> float { fail!("read_float()"); } + fn read_char(&mut self) -> char { fail!("read_char()"); } fn read_str(&mut self) -> ~str { doc_as_str(self.next_doc(EsStr)) } // Compound types: @@ -602,7 +602,7 @@ pub mod reader { fn read_map<T>(&mut self, _: &fn(&mut Decoder, uint) -> T) -> T { debug!("read_map()"); - fail!(~"read_map is unimplemented"); + fail!("read_map is unimplemented"); } fn read_map_elt_key<T>(&mut self, @@ -610,7 +610,7 @@ pub mod reader { _: &fn(&mut Decoder) -> T) -> T { 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, @@ -618,7 +618,7 @@ pub mod reader { _: &fn(&mut Decoder) -> T) -> T { 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]), 4u => w.write(&[0x10u8 | ((n >> 24_u) as u8), (n >> 16_u) 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 < 0x200000_u { write_sized_vuint(w, n, 3u); 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)] @@ -847,17 +847,17 @@ pub mod writer { // FIXME (#2742): implement these fn emit_f64(&mut self, _v: f64) { - fail!(~"Unimplemented: serializing an f64"); + fail!("Unimplemented: serializing an f64"); } fn emit_f32(&mut self, _v: f32) { - fail!(~"Unimplemented: serializing an f32"); + fail!("Unimplemented: serializing an f32"); } fn emit_float(&mut self, _v: float) { - fail!(~"Unimplemented: serializing a float"); + fail!("Unimplemented: serializing a float"); } fn emit_char(&mut self, _v: char) { - fail!(~"Unimplemented: serializing a char"); + fail!("Unimplemented: serializing a char"); } 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)) { - fail!(~"emit_map is unimplemented"); + fail!("emit_map is unimplemented"); } 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)) { - fail!(~"emit_map_elt_val is unimplemented"); + fail!("emit_map_elt_val is unimplemented"); } } } diff --git a/src/libstd/fileinput.rs b/src/libstd/fileinput.rs index c3622fad53b..a31827f95d1 100644 --- a/src/libstd/fileinput.rs +++ b/src/libstd/fileinput.rs @@ -598,7 +598,7 @@ mod test { let expected_path = match line { "1" | "2" => copy filenames[0], "3" | "4" => copy filenames[2], - _ => fail!(~"unexpected line") + _ => fail!("unexpected line") }; assert_eq!(copy state.current_path, expected_path); count += 1; diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index 6547ff8eefb..dc95c50c31b 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -258,7 +258,7 @@ impl<T,U:Unflattener<T>,P:BytePort> GenericPort<T> for FlatPort<T, U, P> { fn recv(&self) -> T { match self.try_recv() { Some(val) => val, - None => fail!(~"port is closed") + None => fail!("port is closed") } } 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 { - fail!(~"flatpipe: unrecognized command"); + fail!("flatpipe: unrecognized command"); } } } @@ -473,7 +473,7 @@ pub mod flatteners { Ok(json) => { json::Decoder(json) } - Err(e) => fail!(fmt!("flatpipe: can't parse json: %?", e)) + Err(e) => fail!("flatpipe: can't parse json: %?", e) } } } diff --git a/src/libstd/future.rs b/src/libstd/future.rs index 9906be13cb9..be33c0f4663 100644 --- a/src/libstd/future.rs +++ b/src/libstd/future.rs @@ -67,14 +67,14 @@ pub impl<A> Future<A> { { match self.state { Forced(ref mut v) => { return cast::transmute(v); } - Evaluating => fail!(~"Recursive forcing of future!"), + Evaluating => fail!("Recursive forcing of future!"), Pending(_) => {} } } { let state = replace(&mut self.state, Evaluating); match state { - Forced(_) | Evaluating => fail!(~"Logic error."), + Forced(_) | Evaluating => fail!("Logic error."), Pending(f) => { self.state = Forced(f()); cast::transmute(self.get_ref()) diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index f66b56381f0..1cb63124456 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -554,7 +554,7 @@ pub mod groups { _} = copy *lopt; 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)), hasarg: hasarg, @@ -571,7 +571,7 @@ pub mod groups { hasarg: hasarg, 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() { 0 => ~"", 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 @@ -686,7 +686,7 @@ mod tests { assert!((opt_present(m, ~"test"))); assert!((opt_str(m, ~"test") == ~"20")); } - _ => { fail!(~"test_reqopt_long failed"); } + _ => { fail!("test_reqopt_long failed"); } } } diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 2acbcf5c7ec..7702b46ddcb 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -853,7 +853,7 @@ impl serialize::Decoder for Decoder { debug!("read_nil"); match self.stack.pop() { 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"); match self.stack.pop() { 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"); match self.stack.pop() { Number(f) => f, - value => fail!(fmt!("not a number: %?", value)) + value => fail!("not a number: %?", value) } } fn read_char(&mut self) -> char { let mut v = ~[]; 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] } @@ -898,7 +898,7 @@ impl serialize::Decoder for Decoder { debug!("read_str"); match self.stack.pop() { 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() { 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)) { Some(idx) => idx, - None => fail!(fmt!("Unknown variant name: %?", name)), + None => fail!("Unknown variant name: %?", name), }; f(self, idx) } @@ -979,7 +979,7 @@ impl serialize::Decoder for Decoder { Object(obj) => { let mut obj = obj; 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) => { self.stack.push(json); f(self) @@ -988,7 +988,7 @@ impl serialize::Decoder for Decoder { self.stack.push(Object(obj)); value } - value => fail!(fmt!("not an object: %?", value)) + value => fail!("not an object: %?", value) } } @@ -1038,7 +1038,7 @@ impl serialize::Decoder for Decoder { } len } - _ => fail!(~"not a list"), + _ => fail!("not a list"), }; f(self, len) } @@ -1060,7 +1060,7 @@ impl serialize::Decoder for Decoder { } len } - json => fail!(fmt!("not an object: %?", json)), + json => fail!("not an object: %?", json), }; f(self, len) } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 13ef377fabe..aa4abbac9d3 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -93,7 +93,7 @@ pub fn len<T>(ls: @List<T>) -> uint { pub fn tail<T:Copy>(ls: @List<T>) -> @List<T> { match *ls { 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 { Cons(copy hd, _) => hd, // makes me sad - _ => fail!(~"head invoked on empty list") + _ => fail!("head invoked on empty list") } } diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs index 58775c5f2e4..f928f10b5fc 100644 --- a/src/libstd/net_ip.rs +++ b/src/libstd/net_ip.rs @@ -59,14 +59,14 @@ pub fn format_addr(ip: &IpAddr) -> ~str { Ipv4(ref addr) => unsafe { let result = uv_ip4_name(addr); if result == ~"" { - fail!(~"failed to convert inner sockaddr_in address to str") + fail!("failed to convert inner sockaddr_in address to str") } result }, Ipv6(ref addr) => unsafe { let result = uv_ip6_name(addr); if result == ~"" { - fail!(~"failed to convert inner sockaddr_in address to str") + fail!("failed to convert inner sockaddr_in address to str") } result } @@ -394,7 +394,7 @@ mod test { assert!(true); } 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); } 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 ga_result = get_addr(localhost_name, iotask); 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 // this.. mostly just wanting to see it work, atm. diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 20e1a272910..8cf2a44b0a6 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -1646,7 +1646,7 @@ mod test { hl_loop); match actual_resp_result.get_err() { ConnectionRefused => (), - _ => fail!(~"unknown error.. expected connection_refused") + _ => fail!("unknown error.. expected connection_refused") } } pub fn impl_gl_tcp_ipv4_server_address_in_use() { @@ -1687,8 +1687,8 @@ mod test { assert!(true); } _ => { - fail!(~"expected address_in_use listen error,"+ - ~"but got a different error varient. check logs."); + fail!("expected address_in_use listen error,\ + but got a different error varient. check logs."); } } } @@ -1706,8 +1706,8 @@ mod test { assert!(true); } _ => { - fail!(~"expected address_in_use listen error,"+ - ~"but got a different error varient. check logs."); + fail!("expected address_in_use listen error,\ + but got a different error varient. check logs."); } } } @@ -1888,14 +1888,13 @@ mod test { if result::is_err(&listen_result) { match result::get_err(&listen_result) { GenericListenErr(ref name, ref msg) => { - fail!(fmt!("SERVER: exited abnormally name %s msg %s", - *name, *msg)); + fail!("SERVER: exited abnormally name %s msg %s", *name, *msg); } AccessDenied => { - fail!(~"SERVER: exited abnormally, got access denied.."); + fail!("SERVER: exited abnormally, got access denied.."); } 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); }, |new_conn, kill_ch| { - fail!(fmt!("SERVER: shouldn't be called.. %? %?", - new_conn, kill_ch)); + fail!("SERVER: shouldn't be called.. %? %?", new_conn, kill_ch); }); // err check on listen_result if result::is_err(&listen_result) { result::get_err(&listen_result) } 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", err_data.err_name, err_data.err_msg); // meh. torn on what to do here. - fail!(~"tcp_write_single failed"); + fail!("tcp_write_single failed"); } } } diff --git a/src/libstd/num/rational.rs b/src/libstd/num/rational.rs index 9b92b7241b9..a47f68091a7 100644 --- a/src/libstd/num/rational.rs +++ b/src/libstd/num/rational.rs @@ -48,7 +48,7 @@ impl<T: Copy + Num + Ord> #[inline(always)] pub fn new(numer: T, denom: T) -> Ratio<T> { if denom == Zero::zero() { - fail!(~"denominator == 0"); + fail!("denominator == 0"); } let mut ret = Ratio::new_raw(numer, denom); ret.reduce(); diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 876eb716a38..0d94a1830a6 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -581,7 +581,7 @@ impl<T:Copy + Ord> MergeState<T> { shift_vec(array, dest, c2, len2); swap(&mut array[dest+len2], &mut tmp[c1]); } else if len1 == 0 { - fail!(~"Comparison violates its contract!"); + fail!("Comparison violates its contract!"); } else { assert!(len2 == 0); assert!(len1 > 1); @@ -703,7 +703,7 @@ impl<T:Copy + Ord> MergeState<T> { shift_vec(array, dest+1, c1+1, len1); swap(&mut array[dest], &mut tmp[c2]); } else if len2 == 0 { - fail!(~"Comparison violates its contract!"); + fail!("Comparison violates its contract!"); } else { assert!(len1 == 0); assert!(len2 != 0); @@ -949,7 +949,7 @@ mod test_tim_sort { fn lt(&self, other: &CVal) -> bool { let mut rng = rand::rng(); if rng.gen::<float>() > 0.995 { - fail!(~"It's happening!!!"); + fail!("It's happening!!!"); } (*self).val < other.val } @@ -1004,7 +1004,7 @@ mod test_tim_sort { }; tim_sort(arr); - fail!(~"Guarantee the fail"); + fail!("Guarantee the fail"); } struct DVal { val: uint } @@ -1065,7 +1065,7 @@ mod big_tests { fn isSorted<T:Ord>(arr: &[T]) { for uint::range(0, arr.len()-1) |i| { 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]) { for uint::range(0, arr.len()-1) |i| { 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)); } } - _ => fail!(~"Expected key to work"), + _ => fail!("Expected key to work"), } } } diff --git a/src/libstd/sort_stage0.rs b/src/libstd/sort_stage0.rs index 00bd325dd0c..270f7196d29 100644 --- a/src/libstd/sort_stage0.rs +++ b/src/libstd/sort_stage0.rs @@ -577,7 +577,7 @@ impl<T:Copy + Ord> MergeState<T> { copy_vec(array, dest, array, c2, len2); util::swap(&mut array[dest+len2], &mut tmp[c1]); } else if len1 == 0 { - fail!(~"Comparison violates its contract!"); + fail!("Comparison violates its contract!"); } else { assert!(len2 == 0); assert!(len1 > 1); @@ -699,7 +699,7 @@ impl<T:Copy + Ord> MergeState<T> { copy_vec(array, dest+1, array, c1+1, len1); util::swap(&mut array[dest], &mut tmp[c2]); } else if len2 == 0 { - fail!(~"Comparison violates its contract!"); + fail!("Comparison violates its contract!"); } else { assert!(len1 == 0); assert!(len2 != 0); @@ -941,7 +941,7 @@ mod test_tim_sort { impl Ord for CVal { fn lt(&self, other: &CVal) -> bool { 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 } fn le(&self, other: &CVal) -> bool { (*self).val <= other.val } @@ -995,7 +995,7 @@ mod test_tim_sort { }; tim_sort(arr); - fail!(~"Guarantee the fail"); + fail!("Guarantee the fail"); } struct DVal { val: uint } @@ -1056,7 +1056,7 @@ mod big_tests { fn isSorted<T:Ord>(arr: &const [T]) { for uint::range(0, arr.len()-1) |i| { 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]) { for uint::range(0, arr.len()-1) |i| { 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)); } } - _ => fail!(~"Expected key to work"), + _ => fail!("Expected key to work"), } } } diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index 108f24d60dc..023fc18cdc1 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -329,11 +329,11 @@ fn check_cvar_bounds<U>(out_of_bounds: Option<uint>, id: uint, act: &str, blk: &fn() -> U) -> U { match out_of_bounds { Some(0) => - fail!(fmt!("%s with illegal ID %u - this lock has no condvars!", - act, id)), + fail!("%s with illegal ID %u - this lock has no condvars!", + act, id), Some(length) => - fail!(fmt!("%s with illegal ID %u - ID must be less than %u", - act, id, length)), + fail!("%s with illegal ID %u - ID must be less than %u", + act, id, length), None => blk() } } @@ -578,7 +578,7 @@ pub impl RWlock { token: RWlockWriteMode<'a>) -> RWlockReadMode<'a> { 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 { do task::unkillable { diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 71cbc0d7a6a..78f46b4ca03 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -89,7 +89,7 @@ pub fn test_main(args: &[~str], tests: ~[TestDescAndFn]) { either::Left(o) => o, 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. @@ -109,7 +109,7 @@ pub fn test_main_static(args: &[~str], tests: &[TestDescAndFn]) { 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]) { result::Ok(w) => Some(w), result::Err(ref s) => { - fail!(fmt!("can't open output file: %s", *s)) + fail!("can't open output file: %s", *s) } }, None => None @@ -849,7 +849,7 @@ mod tests { let args = ~[~"progname", ~"filter"]; let opts = match parse_opts(args) { 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()); } @@ -859,7 +859,7 @@ mod tests { let args = ~[~"progname", ~"filter", ~"--ignored"]; let opts = match parse_opts(args) { either::Left(copy o) => o, - _ => fail!(~"Malformed arg in parse_ignored_flag") + _ => fail!("Malformed arg in parse_ignored_flag") }; assert!((opts.run_ignored)); } diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index 234982a12bc..e9fd0414244 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -63,13 +63,11 @@ pub fn delayed_send<T:Owned>(iotask: &IoTask, } else { let error_msg = uv::ll::get_last_err_info( loop_ptr); - fail!(~"timer::delayed_send() start failed: " + - error_msg); + fail!("timer::delayed_send() start failed: %s", error_msg); } } else { let error_msg = uv::ll::get_last_err_info(loop_ptr); - fail!(~"timer::delayed_send() init failed: " + - error_msg); + fail!("timer::delayed_send() init failed: %s", error_msg); } } }; @@ -158,7 +156,7 @@ extern fn delayed_send_cb(handle: *uv::ll::uv_timer_t, status: libc::c_int) { } else { let loop_ptr = uv::ll::get_loop_for_uv_handle(handle); let error_msg = uv::ll::get_last_err_info(loop_ptr); - fail!(~"timer::sleep() init failed: "+error_msg); + fail!("timer::sleep() init failed: %s", error_msg); } } } diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 2b39458d32d..e0ee3a1ee01 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -716,7 +716,7 @@ pub impl<K: TotalOrd, V> TreeNode<K, V> { #[cfg(stage0)] fn each<'r, K: TotalOrd, V>(_: &'r Option<~TreeNode<K, V>>, _: &fn(&'r K, &'r V) -> bool) -> bool { - fail!(~"don't use me in stage0!") + fail!("don't use me in stage0!") } #[cfg(not(stage0))] fn each<'r, K: TotalOrd, V>(node: &'r Option<~TreeNode<K, V>>, @@ -728,7 +728,7 @@ fn each<'r, K: TotalOrd, V>(node: &'r Option<~TreeNode<K, V>>, #[cfg(stage0)] fn each_reverse<'r, K: TotalOrd, V>(_: &'r Option<~TreeNode<K, V>>, _: &fn(&'r K, &'r V) -> bool) -> bool { - fail!(~"don't use me in stage0!") + fail!("don't use me in stage0!") } #[cfg(not(stage0))] fn each_reverse<'r, K: TotalOrd, V>(node: &'r Option<~TreeNode<K, V>>, diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index 97df64d5266..c7b5d9eef72 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -180,11 +180,11 @@ mod test { simple_timer_cb, 1u, 0u); if(start_status != 0i32) { - fail!(~"failure on ll::timer_start()"); + fail!("failure on ll::timer_start()"); } } else { - fail!(~"failure on ll::timer_init()"); + fail!("failure on ll::timer_init()"); } } }; |
