std: Remove usage of fmt!

This commit is contained in:
Alex Crichton 2013-09-27 17:02:31 -07:00
parent aaf6cc3a84
commit a8ba31dbf3
68 changed files with 497 additions and 509 deletions

View File

@ -236,7 +236,7 @@ pub mod raw {
let alloc = n * (*ty).size;
let total_size = alloc + sys::size_of::<Vec<()>>();
if alloc / (*ty).size != n || total_size < alloc {
fail!("vector size is too large: %u", n);
fail2!("vector size is too large: {}", n);
}
(*ptr) = local_realloc(*ptr as *(), total_size) as *mut Box<Vec<()>>;
(**ptr).data.alloc = alloc;

View File

@ -116,7 +116,7 @@ impl CString {
///
/// Fails if the CString is null.
pub fn with_ref<T>(&self, f: &fn(*libc::c_char) -> T) -> T {
if self.buf.is_null() { fail!("CString is null!"); }
if self.buf.is_null() { fail2!("CString is null!"); }
f(self.buf)
}
@ -126,7 +126,7 @@ impl CString {
///
/// Fails if the CString is null.
pub fn with_mut_ref<T>(&mut self, f: &fn(*mut libc::c_char) -> T) -> T {
if self.buf.is_null() { fail!("CString is null!"); }
if self.buf.is_null() { fail2!("CString is null!"); }
f(unsafe { cast::transmute_mut_unsafe(self.buf) })
}
@ -152,7 +152,7 @@ impl CString {
/// Fails if the CString is null.
#[inline]
pub fn as_bytes<'a>(&'a self) -> &'a [u8] {
if self.buf.is_null() { fail!("CString is null!"); }
if self.buf.is_null() { fail2!("CString is null!"); }
unsafe {
cast::transmute((self.buf, self.len() + 1))
}
@ -273,7 +273,7 @@ impl<'self> ToCStr for &'self [u8] {
do self.as_imm_buf |self_buf, self_len| {
let buf = libc::malloc(self_len as libc::size_t + 1) as *mut u8;
if buf.is_null() {
fail!("failed to allocate memory!");
fail2!("failed to allocate memory!");
}
ptr::copy_memory(buf, self_buf, self_len);

View File

@ -44,7 +44,7 @@ impl<T> Cell<T> {
pub fn take(&self) -> T {
let this = unsafe { transmute_mut(self) };
if this.is_empty() {
fail!("attempt to take an empty cell");
fail2!("attempt to take an empty cell");
}
this.value.take_unwrap()
@ -60,7 +60,7 @@ impl<T> Cell<T> {
pub 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");
fail2!("attempt to put a value back into a full cell");
}
this.value = Some(value);
}

View File

@ -187,7 +187,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!("to_digit: radix %? is to high (maximum 36)", radix);
fail2!("to_digit: radix {} is to high (maximum 36)", radix);
}
let val = match c {
'0' .. '9' => c as uint - ('0' as uint),
@ -214,7 +214,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!("from_digit: radix %? is to high (maximum 36)", num);
fail2!("from_digit: radix {} is to high (maximum 36)", num);
}
if num < radix {
unsafe {
@ -342,7 +342,7 @@ pub fn len_utf8_bytes(c: char) -> uint {
_ if code < MAX_TWO_B => 2u,
_ if code < MAX_THREE_B => 3u,
_ if code < MAX_FOUR_B => 4u,
_ => fail!("invalid character!"),
_ => fail2!("invalid character!"),
}
}

View File

@ -56,7 +56,7 @@ do my_error::cond.trap(|raised_int| {
Condition handling is useful in cases where propagating errors is either to
cumbersome or just not necessary in the first place. It should also be noted,
though, that if there is not handler installed when a condition is raised, then
the task invokes `fail!()` and will terminate.
the task invokes `fail2!()` and will terminate.
## More Info
@ -127,8 +127,8 @@ impl<T, U> Condition<T, U> {
/// If a handler is found, its return value is returned, otherwise this
/// function will not return.
pub fn raise(&self, t: T) -> U {
let msg = fmt!("Unhandled condition: %s: %?", self.name, t);
self.raise_default(t, || fail!(msg.clone()))
let msg = format!("Unhandled condition: {}: {:?}", self.name, t);
self.raise_default(t, || fail2!("{}", msg.clone()))
}
/// Performs the same functionality as `raise`, except that when no handler
@ -136,11 +136,11 @@ impl<T, U> Condition<T, U> {
pub fn raise_default(&self, t: T, default: &fn() -> U) -> U {
match local_data::pop(self.key) {
None => {
debug!("Condition.raise: found no handler");
debug2!("Condition.raise: found no handler");
default()
}
Some(handler) => {
debug!("Condition.raise: found handler");
debug2!("Condition.raise: found handler");
match handler.prev {
None => {}
Some(hp) => local_data::set(self.key, hp)
@ -183,7 +183,7 @@ impl<'self, T, U> Trap<'self, T, U> {
/// ```
pub fn inside<V>(&self, inner: &'self fn() -> V) -> V {
let _g = Guard { cond: self.cond };
debug!("Trap: pushing handler to TLS");
debug2!("Trap: pushing handler to TLS");
local_data::set(self.cond.key, self.handler);
inner()
}
@ -197,7 +197,7 @@ struct Guard<'self, T, U> {
#[unsafe_destructor]
impl<'self, T, U> Drop for Guard<'self, T, U> {
fn drop(&mut self) {
debug!("Guard: popping handler from TLS");
debug2!("Guard: popping handler from TLS");
let curr = local_data::pop(self.cond.key);
match curr {
None => {}
@ -216,20 +216,20 @@ mod test {
}
fn trouble(i: int) {
debug!("trouble: raising condition");
debug2!("trouble: raising condition");
let j = sadness::cond.raise(i);
debug!("trouble: handler recovered with %d", j);
debug2!("trouble: handler recovered with {}", j);
}
fn nested_trap_test_inner() {
let mut inner_trapped = false;
do sadness::cond.trap(|_j| {
debug!("nested_trap_test_inner: in handler");
debug2!("nested_trap_test_inner: in handler");
inner_trapped = true;
0
}).inside {
debug!("nested_trap_test_inner: in protected block");
debug2!("nested_trap_test_inner: in protected block");
trouble(1);
}
@ -241,10 +241,10 @@ mod test {
let mut outer_trapped = false;
do sadness::cond.trap(|_j| {
debug!("nested_trap_test_outer: in handler");
debug2!("nested_trap_test_outer: in handler");
outer_trapped = true; 0
}).inside {
debug!("nested_guard_test_outer: in protected block");
debug2!("nested_guard_test_outer: in protected block");
nested_trap_test_inner();
trouble(1);
}
@ -256,13 +256,13 @@ mod test {
let mut inner_trapped = false;
do sadness::cond.trap(|_j| {
debug!("nested_reraise_trap_test_inner: in handler");
debug2!("nested_reraise_trap_test_inner: in handler");
inner_trapped = true;
let i = 10;
debug!("nested_reraise_trap_test_inner: handler re-raising");
debug2!("nested_reraise_trap_test_inner: handler re-raising");
sadness::cond.raise(i)
}).inside {
debug!("nested_reraise_trap_test_inner: in protected block");
debug2!("nested_reraise_trap_test_inner: in protected block");
trouble(1);
}
@ -274,10 +274,10 @@ mod test {
let mut outer_trapped = false;
do sadness::cond.trap(|_j| {
debug!("nested_reraise_trap_test_outer: in handler");
debug2!("nested_reraise_trap_test_outer: in handler");
outer_trapped = true; 0
}).inside {
debug!("nested_reraise_trap_test_outer: in protected block");
debug2!("nested_reraise_trap_test_outer: in protected block");
nested_reraise_trap_test_inner();
}
@ -289,10 +289,10 @@ mod test {
let mut trapped = false;
do sadness::cond.trap(|j| {
debug!("test_default: in handler");
debug2!("test_default: in handler");
sadness::cond.raise_default(j, || { trapped=true; 5 })
}).inside {
debug!("test_default: in protected block");
debug2!("test_default: in protected block");
trouble(1);
}

View File

@ -78,7 +78,7 @@ impl<L, R> Either<L, R> {
pub fn expect_left(self, reason: &str) -> L {
match self {
Left(x) => x,
Right(_) => fail!(reason.to_owned())
Right(_) => fail2!("{}", reason.to_owned())
}
}
@ -94,7 +94,7 @@ impl<L, R> Either<L, R> {
pub fn expect_right(self, reason: &str) -> R {
match self {
Right(x) => x,
Left(_) => fail!(reason.to_owned())
Left(_) => fail2!("{}", reason.to_owned())
}
}

View File

@ -234,7 +234,7 @@ impl<'self> Parser<'self> {
Some((_, c @ '#')) | Some((_, c @ '{')) |
Some((_, c @ '\\')) | Some((_, c @ '}')) => { c }
Some((_, c)) => {
self.err(fmt!("invalid escape character `%c`", c));
self.err(format!("invalid escape character `{}`", c));
c
}
None => {
@ -378,7 +378,7 @@ impl<'self> Parser<'self> {
return None;
}
method => {
self.err(fmt!("unknown method: `%s`", method));
self.err(format!("unknown method: `{}`", method));
return None;
}
}
@ -448,8 +448,8 @@ impl<'self> Parser<'self> {
Some((_, 'f')) => {
let word = self.word();
if word != "offset" {
self.err(fmt!("expected `offset`, found `%s`",
word));
self.err(format!("expected `offset`, found `{}`",
word));
} else {
if !self.consume(':') {
self.err(~"`offset` must be followed by `:`");
@ -490,7 +490,8 @@ impl<'self> Parser<'self> {
"few" => Left(Few),
"many" => Left(Many),
word => {
self.err(fmt!("unexpected plural selector `%s`", word));
self.err(format!("unexpected plural selector `{}`",
word));
if word == "" {
break
} else {

View File

@ -493,10 +493,10 @@ mod tests {
}
while t < 64 {
debug!("siphash test %?", t);
debug2!("siphash test {}", t);
let vec = u8to64_le!(vecs[t], 0);
let out = Bytes(buf.as_slice()).hash_keyed(k0, k1);
debug!("got %?, expected %?", out, vec);
debug2!("got {:?}, expected {:?}", out, vec);
assert_eq!(vec, out);
stream_full.reset();
@ -504,7 +504,7 @@ mod tests {
let f = stream_full.result_str();
let i = stream_inc.result_str();
let v = to_hex_str(&vecs[t]);
debug!("%d: (%s) => inc=%s full=%s", t, v, i, f);
debug2!("{}: ({}) => inc={} full={}", t, v, i, f);
assert!(f == i && f == v);

View File

@ -179,7 +179,7 @@ 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 => fail2!("HashMap::find: internal logic error"),
}
}
@ -196,7 +196,7 @@ 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 => { fail2!("Internal logic error"); }
FoundHole(idx) => {
self.buckets[idx] = Some(Bucket{hash: hash, key: k,
value: v});
@ -205,7 +205,7 @@ impl<K:Hash + Eq,V> HashMap<K, V> {
}
FoundEntry(idx) => {
match self.buckets[idx] {
None => { fail!("insert_internal: Internal logic error") }
None => { fail2!("insert_internal: Internal logic error") }
Some(ref mut b) => {
b.hash = hash;
b.key = k;
@ -374,7 +374,7 @@ 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 => fail2!("Internal logic error"),
FoundEntry(idx) => { found(&k, self.mut_value_for_bucket(idx), a); idx }
FoundHole(idx) => {
let v = not_found(&k, a);
@ -413,7 +413,7 @@ impl<K: Hash + Eq, V> HashMap<K, V> {
pub fn get<'a>(&'a self, k: &K) -> &'a V {
match self.find(k) {
Some(v) => v,
None => fail!("No entry found for key: %?", k),
None => fail2!("No entry found for key: {:?}", k),
}
}
@ -422,7 +422,7 @@ impl<K: Hash + Eq, V> HashMap<K, V> {
pub fn get_mut<'a>(&'a mut self, k: &K) -> &'a mut V {
match self.find_mut(k) {
Some(v) => v,
None => fail!("No entry found for key: %?", k),
None => fail2!("No entry found for key: {:?}", k),
}
}
@ -826,7 +826,7 @@ mod test_map {
assert!(m.insert(5, 14));
let new = 100;
match m.find_mut(&5) {
None => fail!(), Some(x) => *x = new
None => fail2!(), Some(x) => *x = new
}
assert_eq!(m.find(&5), Some(&new));
}
@ -943,7 +943,7 @@ mod test_map {
assert!(m.find(&1).is_none());
m.insert(1, 2);
match m.find(&1) {
None => fail!(),
None => fail2!(),
Some(v) => assert!(*v == 2)
}
}

View File

@ -947,9 +947,8 @@ impl Reader for *libc::FILE {
match libc::ferror(*self) {
0 => (),
_ => {
error!("error reading buffer");
error!("%s", os::last_os_error());
fail!();
error2!("error reading buffer: {}", os::last_os_error());
fail2!();
}
}
}
@ -1194,9 +1193,8 @@ impl Writer for *libc::FILE {
len as size_t,
*self);
if nout != len as size_t {
error!("error writing buffer");
error!("%s", os::last_os_error());
fail!();
error2!("error writing buffer: {}", os::last_os_error());
fail2!();
}
}
}
@ -1264,9 +1262,8 @@ impl Writer for fd_t {
let vb = ptr::offset(vbuf, count as int) as *c_void;
let nout = libc::write(*self, vb, len as IoSize);
if nout < 0 as IoRet {
error!("error writing buffer");
error!("%s", os::last_os_error());
fail!();
error2!("error writing buffer: {}", os::last_os_error());
fail2!();
}
count += nout as uint;
}
@ -1274,12 +1271,12 @@ impl Writer for fd_t {
}
}
fn seek(&self, _offset: int, _whence: SeekStyle) {
error!("need 64-bit foreign calls for seek, sorry");
fail!();
error2!("need 64-bit foreign calls for seek, sorry");
fail2!();
}
fn tell(&self) -> uint {
error!("need 64-bit foreign calls for tell, sorry");
fail!();
error2!("need 64-bit foreign calls for tell, sorry");
fail2!();
}
fn flush(&self) -> int { 0 }
fn get_type(&self) -> WriterType {
@ -1347,7 +1344,7 @@ pub fn mk_file_writer(path: &Path, flags: &[FileFlag])
}
};
if fd < (0 as c_int) {
Err(fmt!("error opening %s: %s", path.to_str(), os::last_os_error()))
Err(format!("error opening {}: {}", path.to_str(), os::last_os_error()))
} else {
Ok(fd_writer(fd, true))
}
@ -1924,17 +1921,17 @@ mod tests {
#[test]
fn test_simple() {
let tmpfile = &Path("tmp/lib-io-test-simple.tmp");
debug!(tmpfile);
debug2!("{:?}", tmpfile);
let frood: ~str =
~"A hoopy frood who really knows where his towel is.";
debug!(frood.clone());
debug2!("{}", frood.clone());
{
let out = io::file_writer(tmpfile, [io::Create, io::Truncate]).unwrap();
out.write_str(frood);
}
let inp = io::file_reader(tmpfile).unwrap();
let frood2: ~str = inp.read_c_str();
debug!(frood2.clone());
debug2!("{}", frood2.clone());
assert_eq!(frood, frood2);
}
@ -1951,14 +1948,14 @@ mod tests {
{
let file = io::file_reader(&path).unwrap();
do file.each_byte() |_| {
fail!("must be empty")
fail2!("must be empty")
};
}
{
let file = io::file_reader(&path).unwrap();
do file.each_char() |_| {
fail!("must be empty")
fail2!("must be empty")
};
}
}
@ -2045,7 +2042,7 @@ mod tests {
Err(e) => {
assert_eq!(e, ~"error opening not a file");
}
Ok(_) => fail!()
Ok(_) => fail2!()
}
}
@ -2085,7 +2082,7 @@ mod tests {
Err(e) => {
assert!(e.starts_with("error opening"));
}
Ok(_) => fail!()
Ok(_) => fail2!()
}
}
@ -2095,7 +2092,7 @@ mod tests {
Err(e) => {
assert!(e.starts_with("error opening"));
}
Ok(_) => fail!()
Ok(_) => fail2!()
}
}

View File

@ -723,7 +723,7 @@ pub trait ExactSize<A> : DoubleEndedIterator<A> {
Some(x) => {
i = match i.checked_sub(&1) {
Some(x) => x,
None => fail!("rposition: incorrect ExactSize")
None => fail2!("rposition: incorrect ExactSize")
};
if predicate(x) {
return Some(i)
@ -2452,7 +2452,7 @@ mod tests {
assert!(v.iter().all(|&x| x < 10));
assert!(!v.iter().all(|&x| x.is_even()));
assert!(!v.iter().all(|&x| x > 100));
assert!(v.slice(0, 0).iter().all(|_| fail!()));
assert!(v.slice(0, 0).iter().all(|_| fail2!()));
}
#[test]
@ -2461,7 +2461,7 @@ mod tests {
assert!(v.iter().any(|&x| x < 10));
assert!(v.iter().any(|&x| x.is_even()));
assert!(!v.iter().any(|&x| x > 100));
assert!(!v.slice(0, 0).iter().any(|_| fail!()));
assert!(!v.slice(0, 0).iter().any(|_| fail2!()));
}
#[test]
@ -2602,7 +2602,7 @@ mod tests {
let mut i = 0;
do v.iter().rposition |_elt| {
if i == 2 {
fail!()
fail2!()
}
i += 1;
false
@ -2746,12 +2746,12 @@ mod tests {
fn test_double_ended_range() {
assert_eq!(range(11i, 14).invert().collect::<~[int]>(), ~[13i, 12, 11]);
for _ in range(10i, 0).invert() {
fail!("unreachable");
fail2!("unreachable");
}
assert_eq!(range(11u, 14).invert().collect::<~[uint]>(), ~[13u, 12, 11]);
for _ in range(10u, 0).invert() {
fail!("unreachable");
fail2!("unreachable");
}
}

View File

@ -143,8 +143,8 @@ pub fn pop<T: 'static>(key: Key<T>) -> Option<T> {
match *entry {
Some((k, _, loan)) if k == key_value => {
if loan != NoLoan {
fail!("TLS value cannot be removed because it is currently \
borrowed as %s", loan.describe());
fail2!("TLS value cannot be removed because it is currently \
borrowed as {}", loan.describe());
}
// Move the data out of the `entry` slot via util::replace.
// This is guaranteed to succeed because we already matched
@ -240,8 +240,8 @@ fn get_with<T: 'static, U>(key: Key<T>,
}
(ImmLoan, ImmLoan) => {}
(want, cur) => {
fail!("TLS slot cannot be borrowed as %s because \
it is already borrowed as %s",
fail2!("TLS slot cannot be borrowed as {} because \
it is already borrowed as {}",
want.describe(), cur.describe());
}
}
@ -304,8 +304,8 @@ pub fn set<T: 'static>(key: Key<T>, data: T) {
match *entry {
Some((ekey, _, loan)) if key == ekey => {
if loan != NoLoan {
fail!("TLS value cannot be overwritten because it is
already borrowed as %s", loan.describe())
fail2!("TLS value cannot be overwritten because it is
already borrowed as {}", loan.describe())
}
true
}
@ -388,15 +388,15 @@ mod tests {
static my_key: Key<@~str> = &Key;
modify(my_key, |data| {
match data {
Some(@ref val) => fail!("unwelcome value: %s", *val),
Some(@ref val) => fail2!("unwelcome value: {}", *val),
None => Some(@~"first data")
}
});
modify(my_key, |data| {
match data {
Some(@~"first data") => Some(@~"next data"),
Some(@ref val) => fail!("wrong value: %s", *val),
None => fail!("missing value")
Some(@ref val) => fail2!("wrong value: {}", *val),
None => fail2!("missing value")
}
});
assert!(*(pop(my_key).unwrap()) == ~"next data");
@ -456,11 +456,11 @@ mod tests {
set(str_key, @~"string data");
set(box_key, @@());
set(int_key, @42);
fail!();
fail2!();
}
// Not quite nondeterministic.
set(int_key, @31337);
fail!();
fail2!();
}
#[test]

View File

@ -12,16 +12,16 @@
#[doc(hidden)];
macro_rules! rterrln (
($( $arg:expr),+) => ( {
::rt::util::dumb_println(fmt!( $($arg),+ ));
($($arg:tt)*) => ( {
::rt::util::dumb_println(format!($($arg)*));
} )
)
// Some basic logging. Enabled by passing `--cfg rtdebug` to the libstd build.
macro_rules! rtdebug (
($( $arg:expr),+) => ( {
($($arg:tt)*) => ( {
if cfg!(rtdebug) {
rterrln!( $($arg),+ )
rterrln!($($arg)*)
}
})
)
@ -30,7 +30,7 @@ macro_rules! rtassert (
( $arg:expr ) => ( {
if ::rt::util::ENFORCE_SANITY {
if !$arg {
rtabort!("assertion failed: %s", stringify!($arg));
rtabort!("assertion failed: {}", stringify!($arg));
}
}
} )
@ -38,13 +38,13 @@ macro_rules! rtassert (
macro_rules! rtabort(
($( $msg:expr),+) => ( {
::rt::util::abort(fmt!($($msg),+));
($($msg:tt)*) => ( {
::rt::util::abort(format!($($msg)*));
} )
)
macro_rules! assert_once_ever(
($( $msg:expr),+) => ( {
($($msg:tt)+) => ( {
// FIXME(#8472) extra function should not be needed to hide unsafe
fn assert_once_ever() {
unsafe {
@ -52,7 +52,8 @@ macro_rules! assert_once_ever(
// Double-check lock to avoid a swap in the common case.
if already_happened != 0 ||
::unstable::intrinsics::atomic_xchg_relaxed(&mut already_happened, 1) != 0 {
fail!(fmt!("assert_once_ever happened twice: %s", fmt!($($msg),+)));
fail2!("assert_once_ever happened twice: {}",
format!($($msg)+));
}
}
}

View File

@ -816,8 +816,8 @@ impl num::ToStrRadix for f32 {
fn to_str_radix(&self, rdx: uint) -> ~str {
let (r, special) = strconv::float_to_str_common(
*self, rdx, true, strconv::SignNeg, strconv::DigAll);
if special { fail!("number has a special value, \
try to_str_radix_special() if those are expected") }
if special { fail2!("number has a special value, \
try to_str_radix_special() if those are expected") }
r
}
}

View File

@ -864,8 +864,8 @@ impl num::ToStrRadix for f64 {
fn to_str_radix(&self, rdx: uint) -> ~str {
let (r, special) = strconv::float_to_str_common(
*self, rdx, true, strconv::SignNeg, strconv::DigAll);
if special { fail!("number has a special value, \
try to_str_radix_special() if those are expected") }
if special { fail2!("number has a special value, \
try to_str_radix_special() if those are expected") }
r
}
}

View File

@ -181,7 +181,7 @@ impl num::ToStrRadix for float {
fn to_str_radix(&self, radix: uint) -> ~str {
let (r, special) = strconv::float_to_str_common(
*self, radix, true, strconv::SignNeg, strconv::DigAll);
if special { fail!("number has a special value, \
if special { fail2!("number has a special value, \
try to_str_radix_special() if those are expected") }
r
}
@ -1329,16 +1329,16 @@ mod tests {
// note: NaN != NaN, hence this slightly complex test
match from_str::<float>("NaN") {
Some(f) => assert!(f.is_nan()),
None => fail!()
None => fail2!()
}
// note: -0 == 0, hence these slightly more complex tests
match from_str::<float>("-0") {
Some(v) if v.is_zero() => assert!(v.is_negative()),
_ => fail!()
_ => fail2!()
}
match from_str::<float>("0") {
Some(v) if v.is_zero() => assert!(v.is_positive()),
_ => fail!()
_ => fail2!()
}
assert!(from_str::<float>("").is_none());
@ -1376,16 +1376,16 @@ mod tests {
// note: NaN != NaN, hence this slightly complex test
match from_str_hex("NaN") {
Some(f) => assert!(f.is_nan()),
None => fail!()
None => fail2!()
}
// note: -0 == 0, hence these slightly more complex tests
match from_str_hex("-0") {
Some(v) if v.is_zero() => assert!(v.is_negative()),
_ => fail!()
_ => fail2!()
}
match from_str_hex("0") {
Some(v) if v.is_zero() => assert!(v.is_positive()),
_ => fail!()
_ => fail2!()
}
assert_eq!(from_str_hex("e"), Some(14.));
assert_eq!(from_str_hex("E"), Some(14.));

View File

@ -474,19 +474,19 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Div<T,T>+
) -> Option<T> {
match exponent {
ExpDec if radix >= DIGIT_E_RADIX // decimal exponent 'e'
=> fail!("from_str_bytes_common: radix %? incompatible with \
=> fail2!("from_str_bytes_common: radix {:?} incompatible with \
use of 'e' as decimal exponent", radix),
ExpBin if radix >= DIGIT_P_RADIX // binary exponent 'p'
=> fail!("from_str_bytes_common: radix %? incompatible with \
=> fail2!("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!("from_str_bytes_common: radix %? incompatible with \
=> fail2!("from_str_bytes_common: radix {:?} incompatible with \
special values 'inf' and 'NaN'", radix),
_ if (radix as int) < 2
=> fail!("from_str_bytes_common: radix %? to low, \
=> fail2!("from_str_bytes_common: radix {:?} to low, \
must lie in the range [2, 36]", radix),
_ if (radix as int) > 36
=> fail!("from_str_bytes_common: radix %? to high, \
=> fail2!("from_str_bytes_common: radix {:?} to high, \
must lie in the range [2, 36]", radix),
_ => ()
}

View File

@ -278,7 +278,7 @@ impl<T> Option<T> {
pub fn get_ref<'a>(&'a self) -> &'a T {
match *self {
Some(ref x) => x,
None => fail!("called `Option::get_ref()` on a `None` value"),
None => fail2!("called `Option::get_ref()` on a `None` value"),
}
}
@ -298,7 +298,7 @@ impl<T> Option<T> {
pub fn get_mut_ref<'a>(&'a mut self) -> &'a mut T {
match *self {
Some(ref mut x) => x,
None => fail!("called `Option::get_mut_ref()` on a `None` value"),
None => fail2!("called `Option::get_mut_ref()` on a `None` value"),
}
}
@ -320,7 +320,7 @@ impl<T> Option<T> {
pub fn unwrap(self) -> T {
match self {
Some(x) => x,
None => fail!("called `Option::unwrap()` on a `None` value"),
None => fail2!("called `Option::unwrap()` on a `None` value"),
}
}
@ -333,7 +333,7 @@ impl<T> Option<T> {
#[inline]
pub fn take_unwrap(&mut self) -> T {
if self.is_none() {
fail!("called `Option::take_unwrap()` on a `None` value")
fail2!("called `Option::take_unwrap()` on a `None` value")
}
self.take().unwrap()
}
@ -348,7 +348,7 @@ impl<T> Option<T> {
pub fn expect(self, reason: &str) -> T {
match self {
Some(val) => val,
None => fail!(reason.to_owned()),
None => fail2!("{}", reason.to_owned()),
}
}
@ -722,21 +722,23 @@ mod tests {
let new_val = 11;
let mut x = Some(val);
let mut it = x.mut_iter();
{
let mut it = x.mut_iter();
assert_eq!(it.size_hint(), (1, Some(1)));
assert_eq!(it.size_hint(), (1, Some(1)));
match it.next() {
Some(interior) => {
assert_eq!(*interior, val);
*interior = new_val;
assert_eq!(x, Some(new_val));
match it.next() {
Some(interior) => {
assert_eq!(*interior, val);
*interior = new_val;
}
None => assert!(false),
}
None => assert!(false),
}
assert_eq!(it.size_hint(), (0, Some(0)));
assert!(it.next().is_none());
assert_eq!(it.size_hint(), (0, Some(0)));
assert!(it.next().is_none());
}
assert_eq!(x, Some(new_val));
}
#[test]

View File

@ -75,7 +75,7 @@ pub fn getcwd() -> Path {
do buf.as_mut_buf |buf, len| {
unsafe {
if libc::getcwd(buf, len as size_t).is_null() {
fail!()
fail2!()
}
Path(str::raw::from_c_str(buf as *c_char))
@ -182,7 +182,8 @@ pub fn env() -> ~[(~str,~str)] {
};
let ch = GetEnvironmentStringsA();
if (ch as uint == 0) {
fail!("os::env() failure getting env string from OS: %s", os::last_os_error());
fail2!("os::env() failure getting env string from OS: {}",
os::last_os_error());
}
let result = str::raw::from_c_multistring(ch as *libc::c_char, None);
FreeEnvironmentStringsA(ch);
@ -197,13 +198,13 @@ pub fn env() -> ~[(~str,~str)] {
}
let environ = rust_env_pairs();
if (environ as uint == 0) {
fail!("os::env() failure getting env string from OS: %s", os::last_os_error());
fail2!("os::env() failure getting env string from OS: {}",
os::last_os_error());
}
let mut result = ~[];
ptr::array_each(environ, |e| {
let env_pair = str::raw::from_c_str(e);
debug!("get_env_pairs: %s",
env_pair);
debug2!("get_env_pairs: {}", env_pair);
result.push(env_pair);
});
result
@ -213,8 +214,7 @@ pub fn env() -> ~[(~str,~str)] {
let mut pairs = ~[];
for p in input.iter() {
let vs: ~[&str] = p.splitn_iter('=', 1).collect();
debug!("splitting: len: %u",
vs.len());
debug2!("splitting: len: {}", vs.len());
assert_eq!(vs.len(), 2);
pairs.push((vs[0].to_owned(), vs[1].to_owned()));
}
@ -443,7 +443,7 @@ fn dup2(src: c_int, dst: c_int) -> c_int {
/// Returns the proper dll filename for the given basename of a file.
pub fn dll_filename(base: &str) -> ~str {
fmt!("%s%s%s", DLL_PREFIX, base, DLL_SUFFIX)
format!("{}{}{}", DLL_PREFIX, base, DLL_SUFFIX)
}
/// Optionally returns the filesystem path to the current executable which is
@ -722,14 +722,14 @@ pub fn list_dir(p: &Path) -> ~[~str] {
fn rust_list_dir_val(ptr: *dirent_t) -> *libc::c_char;
}
let mut strings = ~[];
debug!("os::list_dir -- BEFORE OPENDIR");
debug2!("os::list_dir -- BEFORE OPENDIR");
let dir_ptr = do p.with_c_str |buf| {
opendir(buf)
};
if (dir_ptr as uint != 0) {
debug!("os::list_dir -- opendir() SUCCESS");
debug2!("os::list_dir -- opendir() SUCCESS");
let mut entry_ptr = readdir(dir_ptr);
while (entry_ptr as uint != 0) {
strings.push(str::raw::from_c_str(rust_list_dir_val(
@ -739,11 +739,9 @@ pub fn list_dir(p: &Path) -> ~[~str] {
closedir(dir_ptr);
}
else {
debug!("os::list_dir -- opendir() FAILURE");
debug2!("os::list_dir -- opendir() FAILURE");
}
debug!(
"os::list_dir -- AFTER -- #: %?",
strings.len());
debug2!("os::list_dir -- AFTER -- \\#: {}", strings.len());
strings
}
#[cfg(windows)]
@ -777,7 +775,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");
fail2!("os::list_dir() failure: got null ptr from wfd");
}
else {
let fp_vec = vec::from_buf(
@ -1101,7 +1099,7 @@ pub fn last_os_error() -> ~str {
do buf.as_mut_buf |buf, len| {
unsafe {
if strerror_r(errno() as c_int, buf, len as size_t) < 0 {
fail!("strerror_r failure");
fail2!("strerror_r failure");
}
str::raw::from_c_str(buf as *c_char)
@ -1166,7 +1164,7 @@ pub fn last_os_error() -> ~str {
len as DWORD,
ptr::null());
if res == 0 {
fail!("[%?] FormatMessage failure", errno());
fail2!("[%?] FormatMessage failure", errno());
}
}
@ -1222,7 +1220,7 @@ fn real_args() -> ~[~str] {
match rt::args::clone() {
Some(args) => args,
None => fail!("process arguments not initialized")
None => fail2!("process arguments not initialized")
}
}
@ -1385,13 +1383,13 @@ impl to_str::ToStr for MapError {
negative length or unaligned offset",
ErrNoMapSupport=> ~"File doesn't support mapping",
ErrNoMem => ~"Invalid address, or not enough available memory",
ErrUnknown(code) => fmt!("Unknown error=%?", code),
ErrUnknown(code) => format!("Unknown error={}", code),
ErrUnsupProt => ~"Protection mode unsupported",
ErrUnsupOffset => ~"Offset in virtual memory mode is unsupported",
ErrAlreadyExists => ~"File mapping for specified file already exists",
ErrVirtualAlloc(code) => fmt!("VirtualAlloc failure=%?", code),
ErrCreateFileMappingW(code) => fmt!("CreateFileMappingW failure=%?", code),
ErrMapViewOfFile(code) => fmt!("MapViewOfFile failure=%?", code)
ErrVirtualAlloc(code) => format!("VirtualAlloc failure={}", code),
ErrCreateFileMappingW(code) => format!("CreateFileMappingW failure={}", code),
ErrMapViewOfFile(code) => format!("MapViewOfFile failure={}", code)
}
}
}
@ -1466,11 +1464,11 @@ impl Drop for MemoryMap {
unsafe {
match libc::munmap(self.data as *c_void, self.len) {
0 => (),
-1 => error!(match errno() as c_int {
libc::EINVAL => ~"invalid addr or len",
e => fmt!("unknown errno=%?", e)
}),
r => error!(fmt!("Unexpected result %?", r))
-1 => match errno() as c_int {
libc::EINVAL => error2!("invalid addr or len"),
e => error2!("unknown errno={}", e)
},
r => error2!("Unexpected result {}", r)
}
}
}
@ -1598,15 +1596,15 @@ impl Drop for MemoryMap {
if libc::VirtualFree(self.data as *mut c_void,
self.len,
libc::MEM_RELEASE) == FALSE {
error!(fmt!("VirtualFree failed: %?", errno()));
error!(format!("VirtualFree failed: {}", errno()));
}
},
MapFile(mapping) => {
if libc::UnmapViewOfFile(self.data as LPCVOID) == FALSE {
error!(fmt!("UnmapViewOfFile failed: %?", errno()));
error!(format!("UnmapViewOfFile failed: {}", errno()));
}
if libc::CloseHandle(mapping as HANDLE) == FALSE {
error!(fmt!("CloseHandle failed: %?", errno()));
error!(format!("CloseHandle failed: {}", errno()));
}
}
}
@ -1727,7 +1725,7 @@ mod tests {
#[test]
pub fn last_os_error() {
debug!(os::last_os_error());
debug2!("{}", os::last_os_error());
}
#[test]
@ -1782,7 +1780,7 @@ mod tests {
}
let n = make_rand_name();
setenv(n, s);
debug!(s.clone());
debug2!("{}", s.clone());
assert_eq!(getenv(n), option::Some(s));
}
@ -1791,7 +1789,7 @@ mod tests {
let path = os::self_exe_path();
assert!(path.is_some());
let path = path.unwrap();
debug!(path.clone());
debug2!("{:?}", path.clone());
// Hard to test this function
assert!(path.is_absolute);
@ -1804,7 +1802,7 @@ mod tests {
assert!(e.len() > 0u);
for p in e.iter() {
let (n, v) = (*p).clone();
debug!(n.clone());
debug2!("{:?}", n.clone());
let v2 = getenv(n);
// MingW seems to set some funky environment variables like
// "=C:=C:\MinGW\msys\1.0\bin" and "!::=::\" that are returned
@ -1829,10 +1827,10 @@ mod tests {
fn test() {
assert!((!Path("test-path").is_absolute));
debug!("Current working directory: %s", getcwd().to_str());
debug2!("Current working directory: {}", getcwd().to_str());
debug!(make_absolute(&Path("test-path")));
debug!(make_absolute(&Path("/usr/bin")));
debug2!("{:?}", make_absolute(&Path("test-path")));
debug2!("{:?}", make_absolute(&Path("/usr/bin")));
}
#[test]
@ -1895,7 +1893,7 @@ mod tests {
assert!(dirs.len() > 0u);
for dir in dirs.iter() {
debug!((*dir).clone());
debug2!("{:?}", (*dir).clone());
}
}
@ -1969,7 +1967,7 @@ mod tests {
let in_mode = input.get_mode();
let rs = os::copy_file(&input, &out);
if (!os::path_exists(&input)) {
fail!("%s doesn't exist", input.to_str());
fail2!("{} doesn't exist", input.to_str());
}
assert!((rs));
let rslt = run::process_status("diff", [input.to_str(), out.to_str()]);
@ -2001,7 +1999,7 @@ mod tests {
os::MapWritable
]) {
Ok(chunk) => chunk,
Err(msg) => fail!(msg.to_str())
Err(msg) => fail2!(msg.to_str())
};
assert!(chunk.len >= 16);
@ -2057,7 +2055,7 @@ mod tests {
MapOffset(size / 2)
]) {
Ok(chunk) => chunk,
Err(msg) => fail!(msg.to_str())
Err(msg) => fail2!(msg.to_str())
};
assert!(chunk.len > 0);

View File

@ -134,8 +134,8 @@ pub trait GenericPath : Clone + Eq + ToStr {
match (t.len(), self.filestem()) {
(0, None) => (*self).clone(),
(0, Some(ref s)) => self.with_filename(*s),
(_, None) => self.with_filename(fmt!(".%s", t)),
(_, Some(ref s)) => self.with_filename(fmt!("%s.%s", *s, t)),
(_, None) => self.with_filename(format!(".{}", t)),
(_, Some(ref s)) => self.with_filename(format!("{}.{}", *s, t)),
}
}
@ -190,7 +190,7 @@ pub trait GenericPath : Clone + Eq + ToStr {
/// True if `self` is an ancestor of `other`.
// See `test_is_ancestor_of` for examples.
fn is_ancestor_of(&self, other: &Self) -> bool {
debug!("%s / %s %? %?", self.to_str(), other.to_str(), self.is_absolute(),
debug2!("{} / {} {} {}", self.to_str(), other.to_str(), self.is_absolute(),
self.components().len());
self == other ||
(!other.components().is_empty() &&
@ -1101,8 +1101,8 @@ mod tests {
let ss = wp.to_str();
let sss = s.to_owned();
if (ss != sss) {
debug!("got %s", ss);
debug!("expected %s", sss);
debug2!("got {}", ss);
debug2!("expected {}", sss);
assert_eq!(ss, sss);
}
}
@ -1167,8 +1167,8 @@ mod tests {
let ss = wp.to_str();
let sss = s.to_owned();
if (ss != sss) {
debug!("got %s", ss);
debug!("expected %s", sss);
debug2!("got {}", ss);
debug2!("expected {}", sss);
assert_eq!(ss, sss);
}
}
@ -1230,8 +1230,8 @@ mod tests {
let ss = wp.to_str();
let sss = s.to_owned();
if (ss != sss) {
debug!("got %s", ss);
debug!("expected %s", sss);
debug2!("got {}", ss);
debug2!("expected {}", sss);
assert_eq!(ss, sss);
}
}
@ -1448,7 +1448,7 @@ mod tests {
let p2 = PosixPath("/home/brian/Dev/rust/build/stage2/bin/..").push_rel(
&PosixPath("lib/rustc/i686-unknown-linux-gnu/lib/libstd.so"));
let res = p1.get_relative_to(&p2);
debug!("test_relative_to8: %s vs. %s",
debug2!("test_relative_to8: {} vs. {}",
res.to_str(),
PosixPath(".").to_str());
assert_eq!(res, PosixPath("."));
@ -1458,7 +1458,7 @@ mod tests {
let p2 = WindowsPath("\\home\\brian\\Dev\\rust\\build\\stage2\\bin\\..").push_rel(
&WindowsPath("lib\\rustc\\i686-unknown-linux-gnu\\lib\\libstd.so"));
let res = p1.get_relative_to(&p2);
debug!("test_relative_to8: %s vs. %s",
debug2!("test_relative_to8: {} vs. {}",
res.to_str(),
WindowsPath(".").to_str());
assert_eq!(res, WindowsPath("."));

View File

@ -236,16 +236,16 @@ pub fn to_mut_unsafe_ptr<T>(thing: &mut T) -> *mut T {
SAFETY NOTE: Pointer-arithmetic. Dragons be here.
*/
pub unsafe fn array_each_with_len<T>(arr: **T, len: uint, cb: &fn(*T)) {
debug!("array_each_with_len: before iterate");
debug2!("array_each_with_len: before iterate");
if (arr as uint == 0) {
fail!("ptr::array_each_with_len failure: arr input is null pointer");
fail2!("ptr::array_each_with_len failure: arr input is null pointer");
}
//let start_ptr = *arr;
for e in range(0, len) {
let n = offset(arr, e as int);
cb(*n);
}
debug!("array_each_with_len: after iterate");
debug2!("array_each_with_len: after iterate");
}
/**
@ -259,11 +259,10 @@ 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");
fail2!("ptr::array_each_with_len failure: arr input is null pointer");
}
let len = buf_len(arr);
debug!("array_each inferred len: %u",
len);
debug2!("array_each inferred len: {}", len);
array_each_with_len(arr, len, cb);
}
@ -670,8 +669,8 @@ pub mod ptr_tests {
let expected = do expected_arr[ctr].with_ref |buf| {
str::raw::from_c_str(buf)
};
debug!(
"test_ptr_array_each_with_len e: %s, a: %s",
debug2!(
"test_ptr_array_each_with_len e: {}, a: {}",
expected, actual);
assert_eq!(actual, expected);
ctr += 1;
@ -707,8 +706,8 @@ pub mod ptr_tests {
let expected = do expected_arr[ctr].with_ref |buf| {
str::raw::from_c_str(buf)
};
debug!(
"test_ptr_array_each e: %s, a: %s",
debug2!(
"test_ptr_array_each e: {}, a: {}",
expected, actual);
assert_eq!(actual, expected);
ctr += 1;

View File

@ -897,7 +897,7 @@ mod test {
let mut ra = IsaacRng::new_seeded(seed);
// Regression test that isaac is actually using the above vector
let r = ra.next();
error!("%?", r);
debug2!("{:?}", r);
assert!(r == 890007737u32 // on x86_64
|| r == 2935188040u32); // on x86
}
@ -940,7 +940,7 @@ mod test {
let mut r = rng();
let a = r.gen::<float>();
let b = r.gen::<float>();
debug!((a, b));
debug2!("{:?}", (a, b));
}
#[test]
@ -953,9 +953,9 @@ mod test {
#[test]
fn test_gen_ascii_str() {
let mut r = rng();
debug!(r.gen_ascii_str(10u));
debug!(r.gen_ascii_str(10u));
debug!(r.gen_ascii_str(10u));
debug2!("{}", r.gen_ascii_str(10u));
debug2!("{}", r.gen_ascii_str(10u));
debug2!("{}", r.gen_ascii_str(10u));
assert_eq!(r.gen_ascii_str(0u).len(), 0u);
assert_eq!(r.gen_ascii_str(10u).len(), 10u);
assert_eq!(r.gen_ascii_str(16u).len(), 16u);

View File

@ -189,7 +189,7 @@ impl<'self> ReprVisitor<'self> {
} else if mtbl == 1 {
// skip, this is ast::m_imm
} else {
fail!("invalid mutability value");
fail2!("invalid mutability value");
}
}
@ -312,7 +312,7 @@ impl<'self> TyVisitor for ReprVisitor<'self> {
// Type no longer exists, vestigial function.
fn visit_estr_fixed(&mut self, _n: uint, _sz: uint,
_align: uint) -> bool { fail!(); }
_align: uint) -> bool { fail2!(); }
fn visit_box(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
self.writer.write(['@' as u8]);
@ -355,7 +355,7 @@ impl<'self> TyVisitor for ReprVisitor<'self> {
}
// Type no longer exists, vestigial function.
fn visit_vec(&mut self, _mtbl: uint, _inner: *TyDesc) -> bool { fail!(); }
fn visit_vec(&mut self, _mtbl: uint, _inner: *TyDesc) -> bool { fail2!(); }
fn visit_unboxed_vec(&mut self, mtbl: uint, inner: *TyDesc) -> bool {
do self.get::<raw::Vec<()>> |this, b| {
@ -567,7 +567,7 @@ impl<'self> TyVisitor for ReprVisitor<'self> {
_align: uint)
-> bool {
match self.var_stk.pop() {
SearchingFor(*) => fail!("enum value matched no variant"),
SearchingFor(*) => fail2!("enum value matched no variant"),
_ => true
}
}

View File

@ -46,7 +46,8 @@ impl<T, E: ToStr> Result<T, E> {
pub fn get_ref<'a>(&'a self) -> &'a T {
match *self {
Ok(ref t) => t,
Err(ref e) => fail!("called `Result::get_ref()` on `Err` value: %s", e.to_str()),
Err(ref e) => fail2!("called `Result::get_ref()` on `Err` value: {}",
e.to_str()),
}
}
@ -106,7 +107,8 @@ impl<T, E: ToStr> Result<T, E> {
pub fn unwrap(self) -> T {
match self {
Ok(t) => t,
Err(e) => fail!("called `Result::unwrap()` on `Err` value: %s", e.to_str()),
Err(e) => fail2!("called `Result::unwrap()` on `Err` value: {}",
e.to_str()),
}
}
@ -123,7 +125,7 @@ impl<T, E: ToStr> Result<T, E> {
pub fn expect(self, reason: &str) -> T {
match self {
Ok(t) => t,
Err(_) => fail!(reason.to_owned()),
Err(_) => fail2!("{}", reason.to_owned()),
}
}
@ -133,7 +135,7 @@ impl<T, E: ToStr> Result<T, E> {
pub fn expect_err(self, reason: &str) -> E {
match self {
Err(e) => e,
Ok(_) => fail!(reason.to_owned()),
Ok(_) => fail2!("{}", reason.to_owned()),
}
}
@ -547,7 +549,7 @@ mod tests {
Err(2));
// test that it does not take more elements than it needs
let functions = [|| Ok(()), || Err(1), || fail!()];
let functions = [|| Ok(()), || Err(1), || fail2!()];
assert_eq!(collect(functions.iter().map(|f| (*f)())),
Err(1));
@ -567,7 +569,7 @@ mod tests {
Err(2));
// test that it does not take more elements than it needs
let functions = [|| Ok(()), || Err(1), || fail!()];
let functions = [|| Ok(()), || Err(1), || fail2!()];
assert_eq!(fold_(functions.iter()
.map(|f| (*f)())),

View File

@ -163,14 +163,14 @@ mod imp {
}
pub fn take() -> Option<~[~str]> {
fail!()
fail2!()
}
pub fn put(_args: ~[~str]) {
fail!()
fail2!()
}
pub fn clone() -> Option<~[~str]> {
fail!()
fail2!()
}
}

View File

@ -78,7 +78,7 @@ unsafe fn fail_borrowed(box: *mut raw::Box<()>, file: *c_char, line: size_t) {
msg.push_str(sep);
let filename = str::raw::from_c_str(entry.file);
msg.push_str(filename);
msg.push_str(fmt!(":%u", entry.line as uint));
msg.push_str(format!(":{}", entry.line));
sep = " and at ";
}
}
@ -221,7 +221,7 @@ pub unsafe fn unrecord_borrow(a: *u8, old_ref_count: uint,
assert!(!borrow_list.is_empty());
let br = borrow_list.pop();
if br.box != a || br.file != file || br.line != line {
let err = fmt!("wrong borrow found, br=%?", br);
let err = format!("wrong borrow found, br={:?}", br);
do err.with_c_str |msg_p| {
sys::begin_unwind_(msg_p, file, line)
}

View File

@ -196,7 +196,7 @@ impl<T> PortOne<T> {
match self.try_recv() {
Some(val) => val,
None => {
fail!("receiving on closed channel");
fail2!("receiving on closed channel");
}
}
}
@ -495,7 +495,7 @@ impl<T> GenericPort<T> for Port<T> {
match self.try_recv() {
Some(val) => val,
None => {
fail!("receiving on closed channel");
fail2!("receiving on closed channel");
}
}
}
@ -650,7 +650,7 @@ impl<T: Send> GenericPort<T> for SharedPort<T> {
match self.try_recv() {
Some(val) => val,
None => {
fail!("receiving on a closed channel");
fail2!("receiving on a closed channel");
}
}
}
@ -770,7 +770,7 @@ mod test {
port.recv();
};
// What is our res?
rtdebug!("res is: %?", res.is_err());
rtdebug!("res is: {:?}", res.is_err());
assert!(res.is_err());
}
}

View File

@ -167,9 +167,9 @@ fn initialize_call_frame(regs: &mut Registers, fptr: *c_void, arg: *c_void,
unsafe { *sp = 0; }
rtdebug!("creating call frame");
rtdebug!("fptr %x", fptr as uint);
rtdebug!("arg %x", arg as uint);
rtdebug!("sp %x", sp as uint);
rtdebug!("fptr {}", fptr as uint);
rtdebug!("arg {}", arg as uint);
rtdebug!("sp {}", sp as uint);
regs[RUSTRT_ARG0] = arg as uint;
regs[RUSTRT_RSP] = sp as uint;

View File

@ -85,7 +85,7 @@ unsafe fn entries(crate_map: *CrateMap) -> *ModEntry {
return (*v0).entries;
}
1 => return (*crate_map).entries,
_ => fail!("Unknown crate map version!")
_ => fail2!("Unknown crate map version!")
}
}
@ -96,7 +96,7 @@ unsafe fn iterator(crate_map: *CrateMap) -> **CrateMap {
return vec::raw::to_ptr((*v0).children);
}
1 => return vec::raw::to_ptr((*crate_map).children),
_ => fail!("Unknown crate map version!")
_ => fail2!("Unknown crate map version!")
}
}

View File

@ -15,45 +15,45 @@ use super::{Reader, Writer};
struct PortReader<P>;
impl<P: GenericPort<~[u8]>> PortReader<P> {
pub fn new(_port: P) -> PortReader<P> { fail!() }
pub fn new(_port: P) -> PortReader<P> { fail2!() }
}
impl<P: GenericPort<~[u8]>> Reader for PortReader<P> {
fn read(&mut self, _buf: &mut [u8]) -> Option<uint> { fail!() }
fn read(&mut self, _buf: &mut [u8]) -> Option<uint> { fail2!() }
fn eof(&mut self) -> bool { fail!() }
fn eof(&mut self) -> bool { fail2!() }
}
struct ChanWriter<C>;
impl<C: GenericChan<~[u8]>> ChanWriter<C> {
pub fn new(_chan: C) -> ChanWriter<C> { fail!() }
pub fn new(_chan: C) -> ChanWriter<C> { fail2!() }
}
impl<C: GenericChan<~[u8]>> Writer for ChanWriter<C> {
fn write(&mut self, _buf: &[u8]) { fail!() }
fn write(&mut self, _buf: &[u8]) { fail2!() }
fn flush(&mut self) { fail!() }
fn flush(&mut self) { fail2!() }
}
struct ReaderPort<R>;
impl<R: Reader> ReaderPort<R> {
pub fn new(_reader: R) -> ReaderPort<R> { fail!() }
pub fn new(_reader: R) -> ReaderPort<R> { fail2!() }
}
impl<R: Reader> GenericPort<~[u8]> for ReaderPort<R> {
fn recv(&self) -> ~[u8] { fail!() }
fn recv(&self) -> ~[u8] { fail2!() }
fn try_recv(&self) -> Option<~[u8]> { fail!() }
fn try_recv(&self) -> Option<~[u8]> { fail2!() }
}
struct WriterChan<W>;
impl<W: Writer> WriterChan<W> {
pub fn new(_writer: W) -> WriterChan<W> { fail!() }
pub fn new(_writer: W) -> WriterChan<W> { fail2!() }
}
impl<W: Writer> GenericChan<~[u8]> for WriterChan<W> {
fn send(&self, _x: ~[u8]) { fail!() }
fn send(&self, _x: ~[u8]) { fail2!() }
}

View File

@ -288,7 +288,7 @@ impl<T: Reader> ReaderUtil for T {
let mut buf = [0];
match self.read(buf) {
Some(0) => {
debug!("read 0 bytes. trying again");
debug2!("read 0 bytes. trying again");
self.read_byte()
}
Some(1) => Some(buf[0]),

View File

@ -59,7 +59,7 @@ use path::Path;
/// }).inside {
/// let stream = match open(p, Create, ReadWrite) {
/// Some(s) => s,
/// None => fail!("whoops! I'm sure this raised, anyways..");
/// None => fail2!("whoops! I'm sure this raised, anyways..");
/// }
/// // do some stuff with that stream
///
@ -223,7 +223,7 @@ pub fn rmdir<P: PathLike>(path: &P) {
/// }).inside {
/// let info = match stat(p) {
/// Some(s) => s,
/// None => fail!("whoops! I'm sure this raised, anyways..");
/// None => fail2!("whoops! I'm sure this raised, anyways..");
/// }
/// if stat.is_file {
/// // just imagine the possibilities ...
@ -271,7 +271,7 @@ pub fn stat<P: PathLike>(path: &P) -> Option<FileStat> {
/// else { cb(entry); }
/// }
/// }
/// else { fail!("nope"); }
/// else { fail2!("nope"); }
/// }
///
/// # Errors
@ -596,7 +596,7 @@ impl FileInfo for Path { }
/// else { cb(entry); }
/// }
/// }
/// else { fail!("nope"); }
/// else { fail2!("nope"); }
/// }
/// ```
trait DirectoryInfo : FileSystemInfo {
@ -631,7 +631,8 @@ trait DirectoryInfo : FileSystemInfo {
kind: PathAlreadyExists,
desc: "Path already exists",
detail:
Some(fmt!("%s already exists; can't mkdir it", self.get_path().to_str()))
Some(format!("{} already exists; can't mkdir it",
self.get_path().to_str()))
})
},
None => mkdir(self.get_path())
@ -657,8 +658,8 @@ trait DirectoryInfo : FileSystemInfo {
let ioerr = IoError {
kind: MismatchedFileTypeForOperation,
desc: "Cannot do rmdir() on a non-directory",
detail: Some(fmt!(
"%s is a non-directory; can't rmdir it",
detail: Some(format!(
"{} is a non-directory; can't rmdir it",
self.get_path().to_str()))
};
io_error::cond.raise(ioerr);
@ -669,7 +670,8 @@ trait DirectoryInfo : FileSystemInfo {
io_error::cond.raise(IoError {
kind: PathDoesntExist,
desc: "Path doesn't exist",
detail: Some(fmt!("%s doesn't exist; can't rmdir it", self.get_path().to_str()))
detail: Some(format!("{} doesn't exist; can't rmdir it",
self.get_path().to_str()))
})
}
}
@ -707,7 +709,7 @@ mod test {
let mut read_stream = open(filename, Open, Read).unwrap();
let mut read_buf = [0, .. 1028];
let read_str = match read_stream.read(read_buf).unwrap() {
-1|0 => fail!("shouldn't happen"),
-1|0 => fail2!("shouldn't happen"),
n => str::from_utf8(read_buf.slice_to(n))
};
assert!(read_str == message.to_owned());
@ -875,7 +877,7 @@ mod test {
}
let stat_res = match stat(filename) {
Some(s) => s,
None => fail!("shouldn't happen")
None => fail2!("shouldn't happen")
};
assert!(stat_res.is_file);
unlink(filename);
@ -889,7 +891,7 @@ mod test {
mkdir(filename);
let stat_res = match stat(filename) {
Some(s) => s,
None => fail!("shouldn't happen")
None => fail2!("shouldn't happen")
};
assert!(stat_res.is_dir);
rmdir(filename);
@ -942,7 +944,7 @@ mod test {
dir.mkdir();
let prefix = "foo";
for n in range(0,3) {
let f = dir.push(fmt!("%d.txt", n));
let f = dir.push(format!("{}.txt", n));
let mut w = f.open_writer(Create);
let msg_str = (prefix + n.to_str().to_owned()).to_owned();
let msg = msg_str.as_bytes();
@ -959,14 +961,14 @@ mod test {
let read_str = str::from_utf8(mem);
let expected = match n {
Some(n) => prefix+n,
None => fail!("really shouldn't happen..")
None => fail2!("really shouldn't happen..")
};
assert!(expected == read_str);
}
f.unlink();
}
},
None => fail!("shouldn't happen")
None => fail2!("shouldn't happen")
}
dir.rmdir();
}

View File

@ -29,9 +29,9 @@ impl<W: Writer> DeflateWriter<W> {
}
impl<W: Writer> Writer for DeflateWriter<W> {
fn write(&mut self, _buf: &[u8]) { fail!() }
fn write(&mut self, _buf: &[u8]) { fail2!() }
fn flush(&mut self) { fail!() }
fn flush(&mut self) { fail2!() }
}
impl<W: Writer> Decorator<W> for DeflateWriter<W> {
@ -68,9 +68,9 @@ impl<R: Reader> InflateReader<R> {
}
impl<R: Reader> Reader for InflateReader<R> {
fn read(&mut self, _buf: &mut [u8]) -> Option<uint> { fail!() }
fn read(&mut self, _buf: &mut [u8]) -> Option<uint> { fail2!() }
fn eof(&mut self) -> bool { fail!() }
fn eof(&mut self) -> bool { fail2!() }
}
impl<R: Reader> Decorator<R> for InflateReader<R> {

View File

@ -40,7 +40,7 @@ impl Writer for MemWriter {
impl Seek for MemWriter {
fn tell(&self) -> u64 { self.buf.len() as u64 }
fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail!() }
fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail2!() }
}
impl Decorator<~[u8]> for MemWriter {
@ -102,7 +102,7 @@ impl Reader for MemReader {
impl Seek for MemReader {
fn tell(&self) -> u64 { self.pos as u64 }
fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail!() }
fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail2!() }
}
impl Decorator<~[u8]> for MemReader {
@ -143,15 +143,15 @@ impl<'self> BufWriter<'self> {
}
impl<'self> Writer for BufWriter<'self> {
fn write(&mut self, _buf: &[u8]) { fail!() }
fn write(&mut self, _buf: &[u8]) { fail2!() }
fn flush(&mut self) { fail!() }
fn flush(&mut self) { fail2!() }
}
impl<'self> Seek for BufWriter<'self> {
fn tell(&self) -> u64 { fail!() }
fn tell(&self) -> u64 { fail2!() }
fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail!() }
fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail2!() }
}
@ -193,7 +193,7 @@ impl<'self> Reader for BufReader<'self> {
impl<'self> Seek for BufReader<'self> {
fn tell(&self) -> u64 { self.pos as u64 }
fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail!() }
fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail2!() }
}
///Calls a function with a MemWriter and returns

View File

@ -585,7 +585,7 @@ pub fn standard_error(kind: IoErrorKind) -> IoError {
detail: None
}
}
_ => fail!()
_ => fail2!()
}
}

View File

@ -25,25 +25,25 @@ impl FileDesc {
///
/// The `FileDesc` takes ownership of the file descriptor
/// and will close it upon destruction.
pub fn new(_fd: fd_t) -> FileDesc { fail!() }
pub fn new(_fd: fd_t) -> FileDesc { fail2!() }
}
impl Reader for FileDesc {
fn read(&mut self, _buf: &mut [u8]) -> Option<uint> { fail!() }
fn read(&mut self, _buf: &mut [u8]) -> Option<uint> { fail2!() }
fn eof(&mut self) -> bool { fail!() }
fn eof(&mut self) -> bool { fail2!() }
}
impl Writer for FileDesc {
fn write(&mut self, _buf: &[u8]) { fail!() }
fn write(&mut self, _buf: &[u8]) { fail2!() }
fn flush(&mut self) { fail!() }
fn flush(&mut self) { fail2!() }
}
impl Seek for FileDesc {
fn tell(&self) -> u64 { fail!() }
fn tell(&self) -> u64 { fail2!() }
fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail!() }
fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail2!() }
}
pub struct CFile(*FILE);
@ -53,22 +53,22 @@ impl CFile {
///
/// The `CFile` takes ownership of the file descriptor
/// and will close it upon destruction.
pub fn new(_file: *FILE) -> CFile { fail!() }
pub fn new(_file: *FILE) -> CFile { fail2!() }
}
impl Reader for CFile {
fn read(&mut self, _buf: &mut [u8]) -> Option<uint> { fail!() }
fn read(&mut self, _buf: &mut [u8]) -> Option<uint> { fail2!() }
fn eof(&mut self) -> bool { fail!() }
fn eof(&mut self) -> bool { fail2!() }
}
impl Writer for CFile {
fn write(&mut self, _buf: &[u8]) { fail!() }
fn write(&mut self, _buf: &[u8]) { fail2!() }
fn flush(&mut self) { fail!() }
fn flush(&mut self) { fail2!() }
}
impl Seek for CFile {
fn tell(&self) -> u64 { fail!() }
fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail!() }
fn tell(&self) -> u64 { fail2!() }
fn seek(&mut self, _pos: i64, _style: SeekStyle) { fail2!() }
}

View File

@ -8,7 +8,6 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use num::FromStrRadix;
use vec::MutableCloneableVector;
use to_str::ToStr;
use from_str::FromStr;
@ -27,37 +26,22 @@ impl ToStr for IpAddr {
fn to_str(&self) -> ~str {
match *self {
Ipv4Addr(a, b, c, d) =>
fmt!("%u.%u.%u.%u",
a as uint, b as uint, c as uint, d as uint),
format!("{}.{}.{}.{}", a, b, c, d),
// Ipv4 Compatible address
Ipv6Addr(0, 0, 0, 0, 0, 0, g, h) => {
let a = fmt!("%04x", g as uint);
let b = FromStrRadix::from_str_radix(a.slice(2, 4), 16).unwrap();
let a = FromStrRadix::from_str_radix(a.slice(0, 2), 16).unwrap();
let c = fmt!("%04x", h as uint);
let d = FromStrRadix::from_str_radix(c.slice(2, 4), 16).unwrap();
let c = FromStrRadix::from_str_radix(c.slice(0, 2), 16).unwrap();
fmt!("::%u.%u.%u.%u", a, b, c, d)
format!("::{}.{}.{}.{}", (g >> 8) as u8, g as u8,
(h >> 8) as u8, h as u8)
}
// Ipv4-Mapped address
Ipv6Addr(0, 0, 0, 0, 0, 0xFFFF, g, h) => {
let a = fmt!("%04x", g as uint);
let b = FromStrRadix::from_str_radix(a.slice(2, 4), 16).unwrap();
let a = FromStrRadix::from_str_radix(a.slice(0, 2), 16).unwrap();
let c = fmt!("%04x", h as uint);
let d = FromStrRadix::from_str_radix(c.slice(2, 4), 16).unwrap();
let c = FromStrRadix::from_str_radix(c.slice(0, 2), 16).unwrap();
fmt!("::FFFF:%u.%u.%u.%u", a, b, c, d)
format!("::FFFF:{}.{}.{}.{}", (g >> 8) as u8, g as u8,
(h >> 8) as u8, h as u8)
}
Ipv6Addr(a, b, c, d, e, f, g, h) =>
fmt!("%x:%x:%x:%x:%x:%x:%x:%x",
a as uint, b as uint, c as uint, d as uint,
e as uint, f as uint, g as uint, h as uint)
format!("{}:{}:{}:{}:{}:{}:{}:{}", a, b, c, d, e, f, g, h)
}
}
}
@ -72,8 +56,8 @@ pub struct SocketAddr {
impl ToStr for SocketAddr {
fn to_str(&self) -> ~str {
match self.ip {
Ipv4Addr(*) => fmt!("%s:%u", self.ip.to_str(), self.port as uint),
Ipv6Addr(*) => fmt!("[%s]:%u", self.ip.to_str(), self.port as uint),
Ipv4Addr(*) => format!("{}:{}", self.ip.to_str(), self.port),
Ipv6Addr(*) => format!("[{}]:{}", self.ip.to_str(), self.port),
}
}
}

View File

@ -38,7 +38,7 @@ impl TcpStream {
match stream {
Ok(s) => Some(TcpStream::new(s)),
Err(ioerr) => {
rtdebug!("failed to connect: %?", ioerr);
rtdebug!("failed to connect: {:?}", ioerr);
io_error::cond.raise(ioerr);
None
}
@ -49,7 +49,7 @@ impl TcpStream {
match (**self).peer_name() {
Ok(pn) => Some(pn),
Err(ioerr) => {
rtdebug!("failed to get peer name: %?", ioerr);
rtdebug!("failed to get peer name: {:?}", ioerr);
io_error::cond.raise(ioerr);
None
}
@ -60,7 +60,7 @@ impl TcpStream {
match (**self).socket_name() {
Ok(sn) => Some(sn),
Err(ioerr) => {
rtdebug!("failed to get socket name: %?", ioerr);
rtdebug!("failed to get socket name: {:?}", ioerr);
io_error::cond.raise(ioerr);
None
}
@ -82,7 +82,7 @@ impl Reader for TcpStream {
}
}
fn eof(&mut self) -> bool { fail!() }
fn eof(&mut self) -> bool { fail2!() }
}
impl Writer for TcpStream {
@ -117,7 +117,7 @@ impl TcpListener {
match (**self).socket_name() {
Ok(sn) => Some(sn),
Err(ioerr) => {
rtdebug!("failed to get socket name: %?", ioerr);
rtdebug!("failed to get socket name: {:?}", ioerr);
io_error::cond.raise(ioerr);
None
}

View File

@ -61,7 +61,7 @@ impl UdpSocket {
match (***self).socket_name() {
Ok(sn) => Some(sn),
Err(ioerr) => {
rtdebug!("failed to get socket name: %?", ioerr);
rtdebug!("failed to get socket name: {:?}", ioerr);
io_error::cond.raise(ioerr);
None
}
@ -92,7 +92,7 @@ impl Reader for UdpStream {
}
}
fn eof(&mut self) -> bool { fail!() }
fn eof(&mut self) -> bool { fail2!() }
}
impl Writer for UdpStream {
@ -102,7 +102,7 @@ impl Writer for UdpStream {
}
}
fn flush(&mut self) { fail!() }
fn flush(&mut self) { fail2!() }
}
#[cfg(test)]
@ -151,10 +151,10 @@ mod test {
assert_eq!(buf[0], 99);
assert_eq!(src, client_ip);
}
None => fail!()
None => fail2!()
}
}
None => fail!()
None => fail2!()
}
}
@ -164,7 +164,7 @@ mod test {
port.take().recv();
client.sendto([99], server_ip)
}
None => fail!()
None => fail2!()
}
}
}
@ -190,10 +190,10 @@ mod test {
assert_eq!(buf[0], 99);
assert_eq!(src, client_ip);
}
None => fail!()
None => fail2!()
}
}
None => fail!()
None => fail2!()
}
}
@ -203,7 +203,7 @@ mod test {
port.take().recv();
client.sendto([99], server_ip)
}
None => fail!()
None => fail2!()
}
}
}
@ -230,10 +230,10 @@ mod test {
assert_eq!(nread, 1);
assert_eq!(buf[0], 99);
}
None => fail!()
None => fail2!()
}
}
None => fail!()
None => fail2!()
}
}
@ -245,7 +245,7 @@ mod test {
port.take().recv();
stream.write([99]);
}
None => fail!()
None => fail2!()
}
}
}
@ -272,10 +272,10 @@ mod test {
assert_eq!(nread, 1);
assert_eq!(buf[0], 99);
}
None => fail!()
None => fail2!()
}
}
None => fail!()
None => fail2!()
}
}
@ -287,7 +287,7 @@ mod test {
port.take().recv();
stream.write([99]);
}
None => fail!()
None => fail2!()
}
}
}

View File

@ -16,36 +16,36 @@ pub struct UnixStream;
impl UnixStream {
pub fn connect<P: PathLike>(_path: &P) -> Option<UnixStream> {
fail!()
fail2!()
}
}
impl Reader for UnixStream {
fn read(&mut self, _buf: &mut [u8]) -> Option<uint> { fail!() }
fn read(&mut self, _buf: &mut [u8]) -> Option<uint> { fail2!() }
fn eof(&mut self) -> bool { fail!() }
fn eof(&mut self) -> bool { fail2!() }
}
impl Writer for UnixStream {
fn write(&mut self, _v: &[u8]) { fail!() }
fn write(&mut self, _v: &[u8]) { fail2!() }
fn flush(&mut self) { fail!() }
fn flush(&mut self) { fail2!() }
}
pub struct UnixListener;
impl UnixListener {
pub fn bind<P: PathLike>(_path: &P) -> Option<UnixListener> {
fail!()
fail2!()
}
}
impl Listener<UnixStream, UnixAcceptor> for UnixListener {
fn listen(self) -> Option<UnixAcceptor> { fail!() }
fn listen(self) -> Option<UnixAcceptor> { fail2!() }
}
pub struct UnixAcceptor;
impl Acceptor<UnixStream> for UnixAcceptor {
fn accept(&mut self) -> Option<UnixStream> { fail!() }
fn accept(&mut self) -> Option<UnixStream> { fail2!() }
}

View File

@ -59,7 +59,7 @@ impl Reader for PipeStream {
}
}
fn eof(&mut self) -> bool { fail!() }
fn eof(&mut self) -> bool { fail2!() }
}
impl Writer for PipeStream {
@ -72,5 +72,5 @@ impl Writer for PipeStream {
}
}
fn flush(&mut self) { fail!() }
fn flush(&mut self) { fail2!() }
}

View File

@ -11,15 +11,15 @@
use prelude::*;
use super::{Reader, Writer};
pub fn stdin() -> StdReader { fail!() }
pub fn stdin() -> StdReader { fail2!() }
pub fn stdout() -> StdWriter { fail!() }
pub fn stdout() -> StdWriter { fail2!() }
pub fn stderr() -> StdReader { fail!() }
pub fn stderr() -> StdReader { fail2!() }
pub fn print(_s: &str) { fail!() }
pub fn print(_s: &str) { fail2!() }
pub fn println(_s: &str) { fail!() }
pub fn println(_s: &str) { fail2!() }
pub enum StdStream {
StdIn,
@ -30,23 +30,23 @@ pub enum StdStream {
pub struct StdReader;
impl StdReader {
pub fn new(_stream: StdStream) -> StdReader { fail!() }
pub fn new(_stream: StdStream) -> StdReader { fail2!() }
}
impl Reader for StdReader {
fn read(&mut self, _buf: &mut [u8]) -> Option<uint> { fail!() }
fn read(&mut self, _buf: &mut [u8]) -> Option<uint> { fail2!() }
fn eof(&mut self) -> bool { fail!() }
fn eof(&mut self) -> bool { fail2!() }
}
pub struct StdWriter;
impl StdWriter {
pub fn new(_stream: StdStream) -> StdWriter { fail!() }
pub fn new(_stream: StdStream) -> StdWriter { fail2!() }
}
impl Writer for StdWriter {
fn write(&mut self, _buf: &[u8]) { fail!() }
fn write(&mut self, _buf: &[u8]) { fail2!() }
fn flush(&mut self) { fail!() }
fn flush(&mut self) { fail2!() }
}

View File

@ -36,7 +36,7 @@ impl Timer {
match timer {
Ok(t) => Some(Timer(t)),
Err(ioerr) => {
rtdebug!("Timer::init: failed to init: %?", ioerr);
rtdebug!("Timer::init: failed to init: {:?}", ioerr);
io_error::cond.raise(ioerr);
None
}

View File

@ -306,7 +306,7 @@ impl BlockedTask {
match flag.compare_and_swap(KILL_RUNNING, task_ptr, Relaxed) {
KILL_RUNNING => Right(Killable(flag_arc)),
KILL_KILLED => Left(revive_task_ptr(task_ptr, Some(flag_arc))),
x => rtabort!("can't block task! kill flag = %?", x),
x => rtabort!("can't block task! kill flag = {}", x),
}
}
}
@ -403,7 +403,7 @@ impl KillHandle {
// FIXME(#7544)(bblum): is it really necessary to prohibit double kill?
match inner.unkillable.compare_and_swap(KILL_RUNNING, KILL_UNKILLABLE, Relaxed) {
KILL_RUNNING => { }, // normal case
KILL_KILLED => if !already_failing { fail!(KILLED_MSG) },
KILL_KILLED => if !already_failing { fail2!("{}", KILLED_MSG) },
_ => rtabort!("inhibit_kill: task already unkillable"),
}
}
@ -416,7 +416,7 @@ impl KillHandle {
// FIXME(#7544)(bblum): is it really necessary to prohibit double kill?
match inner.unkillable.compare_and_swap(KILL_UNKILLABLE, KILL_RUNNING, Relaxed) {
KILL_UNKILLABLE => { }, // normal case
KILL_KILLED => if !already_failing { fail!(KILLED_MSG) },
KILL_KILLED => if !already_failing { fail2!("{}", KILLED_MSG) },
_ => rtabort!("allow_kill: task already killable"),
}
}
@ -624,7 +624,7 @@ impl Death {
// synchronization during unwinding or cleanup (for example,
// sending on a notify port). In that case failing won't help.
if self.unkillable == 0 && (!already_failing) && kill_handle.killed() {
fail!(KILLED_MSG);
fail2!("{}", KILLED_MSG);
},
// This may happen during task death (see comments in collect_failure).
None => rtassert!(self.unkillable > 0),
@ -650,7 +650,7 @@ impl Death {
if self.unkillable == 0 {
// we need to decrement the counter before failing.
self.unkillable -= 1;
fail!("Cannot enter a rekillable() block without a surrounding unkillable()");
fail2!("Cannot enter a rekillable() block without a surrounding unkillable()");
}
self.unkillable -= 1;
if self.unkillable == 0 {

View File

@ -90,15 +90,15 @@ fn parse_logging_spec(spec: ~str) -> ~[LogDirective]{
log_level = num;
},
_ => {
dumb_println(fmt!("warning: invalid logging spec \
'%s', ignoring it", parts[1]));
dumb_println(format!("warning: invalid logging spec \
'{}', ignoring it", parts[1]));
loop;
}
}
},
_ => {
dumb_println(fmt!("warning: invalid logging spec '%s',\
ignoring it", s));
dumb_println(format!("warning: invalid logging spec '{}',\
ignoring it", s));
loop;
}
}
@ -165,10 +165,12 @@ fn update_log_settings(crate_map: *u8, settings: ~str) {
}
if n_matches < (dirs.len() as u32) {
dumb_println(fmt!("warning: got %u RUST_LOG specs but only matched %u of them.\n\
You may have mistyped a RUST_LOG spec.\n\
Use RUST_LOG=::help to see the list of crates and modules.\n",
dirs.len() as uint, n_matches as uint));
dumb_println(format!("warning: got {} RUST_LOG specs but only matched\n\
{} of them. You may have mistyped a RUST_LOG \
spec. \n\
Use RUST_LOG=::help to see the list of crates \
and modules.\n",
dirs.len(), n_matches));
}
}

View File

@ -191,7 +191,7 @@ impl Scheduler {
// action will have given it away.
let sched: ~Scheduler = Local::take();
rtdebug!("starting scheduler %u", sched.sched_id());
rtdebug!("starting scheduler {}", sched.sched_id());
sched.run();
// Close the idle callback.
@ -207,7 +207,7 @@ impl Scheduler {
// the cleanup code it runs.
let mut stask: ~Task = Local::take();
rtdebug!("stopping scheduler %u", stask.sched.get_ref().sched_id());
rtdebug!("stopping scheduler {}", stask.sched.get_ref().sched_id());
// Should not have any messages
let message = stask.sched.get_mut_ref().message_queue.pop();
@ -999,7 +999,7 @@ mod test {
Sched(t1_handle)) || {
rtassert!(Task::on_appropriate_sched());
};
rtdebug!("task1 id: **%u**", borrow::to_uint(task1));
rtdebug!("task1 id: **{}**", borrow::to_uint(task1));
let task2 = ~do Task::new_root(&mut normal_sched.stack_pool, None) {
rtassert!(Task::on_appropriate_sched());
@ -1013,7 +1013,7 @@ mod test {
Sched(t4_handle)) {
rtassert!(Task::on_appropriate_sched());
};
rtdebug!("task4 id: **%u**", borrow::to_uint(task4));
rtdebug!("task4 id: **{}**", borrow::to_uint(task4));
let task1 = Cell::new(task1);
let task2 = Cell::new(task2);
@ -1038,7 +1038,7 @@ mod test {
sh.send(Shutdown);
};
rtdebug!("normal task: %u", borrow::to_uint(normal_task));
rtdebug!("normal task: {}", borrow::to_uint(normal_task));
let special_task = ~do Task::new_root(&mut special_sched.stack_pool, None) {
rtdebug!("*about to submit task1*");
@ -1049,7 +1049,7 @@ mod test {
chan.take().send(());
};
rtdebug!("special task: %u", borrow::to_uint(special_task));
rtdebug!("special task: {}", borrow::to_uint(special_task));
let special_sched = Cell::new(special_sched);
let normal_sched = Cell::new(normal_sched);
@ -1238,12 +1238,12 @@ mod test {
while (true) {
match p.recv() {
(1, end_chan) => {
debug!("%d\n", id);
debug2!("{}\n", id);
end_chan.send(());
return;
}
(token, end_chan) => {
debug!("thread: %d got token: %d", id, token);
debug2!("thread: {} got token: {}", id, token);
ch.send((token - 1, end_chan));
if token <= n_tasks {
return;

View File

@ -225,7 +225,7 @@ impl Task {
}
pub fn run(&mut self, f: &fn()) {
rtdebug!("run called on task: %u", borrow::to_uint(self));
rtdebug!("run called on task: {}", borrow::to_uint(self));
// The only try/catch block in the world. Attempt to run the task's
// client-specified code and catch any failures.
@ -329,7 +329,7 @@ impl Task {
impl Drop for Task {
fn drop(&mut self) {
rtdebug!("called drop for a task: %u", borrow::to_uint(self));
rtdebug!("called drop for a task: {}", borrow::to_uint(self));
rtassert!(self.destroyed)
}
}
@ -498,7 +498,7 @@ mod test {
let result = spawntask_try(||());
rtdebug!("trying first assert");
assert!(result.is_ok());
let result = spawntask_try(|| fail!());
let result = spawntask_try(|| fail2!());
rtdebug!("trying second assert");
assert!(result.is_err());
}
@ -516,7 +516,7 @@ mod test {
#[test]
fn logging() {
do run_in_newsched_task() {
info!("here i am. logging in a newsched task");
info2!("here i am. logging in a newsched task");
}
}
@ -558,7 +558,7 @@ mod test {
fn linked_failure() {
do run_in_newsched_task() {
let res = do spawntask_try {
spawntask_random(|| fail!());
spawntask_random(|| fail2!());
};
assert!(res.is_err());
}
@ -599,7 +599,7 @@ mod test {
builder.future_result(|r| result = Some(r));
builder.unlinked();
do builder.spawn {
fail!();
fail2!();
}
assert_eq!(result.unwrap().recv(), Failure);
}

View File

@ -114,7 +114,7 @@ mod darwin_fd_limit {
to_mut_unsafe_ptr(&mut size),
mut_null(), 0) != 0 {
let err = last_os_error();
error!("raise_fd_limit: error calling sysctl: %s", err);
error2!("raise_fd_limit: error calling sysctl: {}", err);
return;
}
@ -122,7 +122,7 @@ mod darwin_fd_limit {
let mut rlim = rlimit{rlim_cur: 0, rlim_max: 0};
if getrlimit(RLIMIT_NOFILE, to_mut_unsafe_ptr(&mut rlim)) != 0 {
let err = last_os_error();
error!("raise_fd_limit: error calling getrlimit: %s", err);
error2!("raise_fd_limit: error calling getrlimit: {}", err);
return;
}
@ -132,7 +132,7 @@ mod darwin_fd_limit {
// Set our newly-increased resource limit
if setrlimit(RLIMIT_NOFILE, to_unsafe_ptr(&rlim)) != 0 {
let err = last_os_error();
error!("raise_fd_limit: error calling setrlimit: %s", err);
error2!("raise_fd_limit: error calling setrlimit: {}", err);
return;
}
}

View File

@ -61,7 +61,7 @@ pub fn default_sched_threads() -> uint {
let opt_n: Option<uint> = FromStr::from_str(nstr);
match opt_n {
Some(n) if n > 0 => n,
_ => rtabort!("`RUST_THREADS` is `%s`, should be a positive integer", nstr)
_ => rtabort!("`RUST_THREADS` is `{}`, should be a positive integer", nstr)
}
}
None => {
@ -127,10 +127,10 @@ which at the time convulsed us with joy, yet which are now partly lost to my
memory and partly incapable of presentation to others.",
_ => "You've met with a terrible fate, haven't you?"
};
rterrln!("%s", "");
rterrln!("%s", quote);
rterrln!("%s", "");
rterrln!("fatal runtime error: %s", msg);
rterrln!("{}", "");
rterrln!("{}", quote);
rterrln!("{}", "");
rterrln!("fatal runtime error: {}", msg);
abort();

View File

@ -505,7 +505,7 @@ mod test {
let unlink_req = FsRequest::new();
let result = unlink_req.unlink_sync(&loop_, &Path(path_str));
assert!(result.is_ok());
} else { fail!("nread was 0.. wudn't expectin' that."); }
} else { fail2!("nread was 0.. wudn't expectin' that."); }
loop_.close();
}
}
@ -595,7 +595,7 @@ mod test {
assert!(uverr.is_none());
let loop_ = req.get_loop();
let stat = req.get_stat();
naive_print(&loop_, fmt!("%?", stat));
naive_print(&loop_, format!("{:?}", stat));
assert!(stat.is_dir());
let rmdir_req = FsRequest::new();
do rmdir_req.rmdir(&loop_, &path) |req,uverr| {

View File

@ -240,7 +240,7 @@ impl UvError {
impl ToStr for UvError {
fn to_str(&self) -> ~str {
fmt!("%s: %s", self.name(), self.desc())
format!("{}: {}", self.name(), self.desc())
}
}
@ -269,7 +269,7 @@ pub fn uv_error_to_io_error(uverr: UvError) -> IoError {
ECONNRESET => ConnectionReset,
EPIPE => BrokenPipe,
err => {
rtdebug!("uverr.code %d", err as int);
rtdebug!("uverr.code {}", err as int);
// XXX: Need to map remaining uv error types
OtherIoError
}

View File

@ -34,7 +34,7 @@ fn sockaddr_to_UvSocketAddr(addr: *uvll::sockaddr) -> UvSocketAddr {
match addr {
_ if is_ip4_addr(addr) => UvIpv4SocketAddr(addr as *uvll::sockaddr_in),
_ if is_ip6_addr(addr) => UvIpv6SocketAddr(addr as *uvll::sockaddr_in6),
_ => fail!(),
_ => fail2!(),
}
}
}
@ -156,8 +156,8 @@ impl StreamWatcher {
}
extern fn read_cb(stream: *uvll::uv_stream_t, nread: ssize_t, buf: Buf) {
rtdebug!("buf addr: %x", buf.base as uint);
rtdebug!("buf len: %d", buf.len as int);
rtdebug!("buf addr: {}", buf.base);
rtdebug!("buf len: {}", buf.len);
let mut stream_watcher: StreamWatcher = NativeHandle::from_native_handle(stream);
let cb = stream_watcher.get_watcher_data().read_cb.get_ref();
let status = status_to_maybe_uv_error(nread as c_int);
@ -266,7 +266,7 @@ impl TcpWatcher {
self.get_watcher_data().connect_cb = Some(cb);
let connect_handle = ConnectRequest::new().native_handle();
rtdebug!("connect_t: %x", connect_handle as uint);
rtdebug!("connect_t: {}", connect_handle);
do socket_addr_as_uv_socket_addr(address) |addr| {
let result = match addr {
UvIpv4SocketAddr(addr) => uvll::tcp_connect(connect_handle,
@ -278,7 +278,7 @@ impl TcpWatcher {
}
extern fn connect_cb(req: *uvll::uv_connect_t, status: c_int) {
rtdebug!("connect_t: %x", req as uint);
rtdebug!("connect_t: {}", req);
let connect_request: ConnectRequest = NativeHandle::from_native_handle(req);
let mut stream_watcher = connect_request.stream();
connect_request.delete();
@ -379,8 +379,8 @@ impl UdpWatcher {
return;
}
rtdebug!("buf addr: %x", buf.base as uint);
rtdebug!("buf len: %d", buf.len as int);
rtdebug!("buf addr: {}", buf.base);
rtdebug!("buf len: {}", buf.len);
let mut udp_watcher: UdpWatcher = NativeHandle::from_native_handle(handle);
let cb = udp_watcher.get_watcher_data().udp_recv_cb.get_ref();
let status = status_to_maybe_uv_error(nread as c_int);
@ -652,11 +652,11 @@ mod test {
let buf = vec_from_uv_buf(buf);
let mut count = count_cell.take();
if status.is_none() {
rtdebug!("got %d bytes", nread);
rtdebug!("got {} bytes", nread);
let buf = buf.unwrap();
for byte in buf.slice(0, nread as uint).iter() {
assert!(*byte == count as u8);
rtdebug!("%u", *byte as uint);
rtdebug!("{}", *byte as uint);
count += 1;
}
} else {
@ -727,12 +727,12 @@ mod test {
let buf = vec_from_uv_buf(buf);
let mut count = count_cell.take();
if status.is_none() {
rtdebug!("got %d bytes", nread);
rtdebug!("got {} bytes", nread);
let buf = buf.unwrap();
let r = buf.slice(0, nread as uint);
for byte in r.iter() {
assert!(*byte == count as u8);
rtdebug!("%u", *byte as uint);
rtdebug!("{}", *byte as uint);
count += 1;
}
} else {
@ -798,12 +798,12 @@ mod test {
let buf = vec_from_uv_buf(buf);
let mut count = 0;
rtdebug!("got %d bytes", nread);
rtdebug!("got {} bytes", nread);
let buf = buf.unwrap();
for &byte in buf.slice(0, nread as uint).iter() {
assert!(byte == count as u8);
rtdebug!("%u", byte as uint);
rtdebug!("{}", byte as uint);
count += 1;
}
assert_eq!(count, MAX);
@ -858,12 +858,12 @@ mod test {
let buf = vec_from_uv_buf(buf);
let mut count = 0;
rtdebug!("got %d bytes", nread);
rtdebug!("got {} bytes", nread);
let buf = buf.unwrap();
for &byte in buf.slice(0, nread as uint).iter() {
assert!(byte == count as u8);
rtdebug!("%u", byte as uint);
rtdebug!("{}", byte as uint);
count += 1;
}
assert_eq!(count, MAX);

View File

@ -199,7 +199,7 @@ fn with_env<T>(env: Option<&[(~str, ~str)]>, f: &fn(**libc::c_char) -> T) -> T {
// As with argv, create some temporary storage and then the actual array
let mut envp = vec::with_capacity(env.len());
for &(ref key, ref value) in env.iter() {
envp.push(fmt!("%s=%s", *key, *value).to_c_str());
envp.push(format!("{}={}", *key, *value).to_c_str());
}
let mut c_envp = vec::with_capacity(envp.len() + 1);
for s in envp.iter() {

View File

@ -1802,7 +1802,7 @@ fn test_simple_tcp_server_and_client() {
let nread = stream.read(buf).unwrap();
assert_eq!(nread, 8);
for i in range(0u, nread) {
rtdebug!("%u", buf[i] as uint);
rtdebug!("{}", buf[i]);
assert_eq!(buf[i], i as u8);
}
}
@ -1919,7 +1919,7 @@ fn test_simple_udp_server_and_client() {
let (nread,src) = server_socket.recvfrom(buf).unwrap();
assert_eq!(nread, 8);
for i in range(0u, nread) {
rtdebug!("%u", buf[i] as uint);
rtdebug!("{}", buf[i]);
assert_eq!(buf[i], i as u8);
}
assert_eq!(src, client_addr);
@ -2031,13 +2031,13 @@ fn test_read_read_read() {
let mut total_bytes_read = 0;
while total_bytes_read < MAX {
let nread = stream.read(buf).unwrap();
rtdebug!("read %u bytes", nread as uint);
rtdebug!("read {} bytes", nread);
total_bytes_read += nread;
for i in range(0u, nread) {
assert_eq!(buf[i], 1);
}
}
rtdebug!("read %u bytes total", total_bytes_read as uint);
rtdebug!("read {} bytes total", total_bytes_read);
}
}
}

View File

@ -199,7 +199,7 @@ impl Process {
fn input_fd(&mut self) -> c_int {
match self.input {
Some(fd) => fd,
None => fail!("This Process's stdin was redirected to an \
None => fail2!("This Process's stdin was redirected to an \
existing file descriptor.")
}
}
@ -207,7 +207,7 @@ impl Process {
fn output_file(&mut self) -> *libc::FILE {
match self.output {
Some(file) => file,
None => fail!("This Process's stdout was redirected to an \
None => fail2!("This Process's stdout was redirected to an \
existing file descriptor.")
}
}
@ -215,7 +215,7 @@ impl Process {
fn error_file(&mut self) -> *libc::FILE {
match self.error {
Some(file) => file,
None => fail!("This Process's stderr was redirected to an \
None => fail2!("This Process's stderr was redirected to an \
existing file descriptor.")
}
}
@ -373,7 +373,7 @@ impl Process {
((1, o), (2, e)) => (e, o),
((2, e), (1, o)) => (e, o),
((x, _), (y, _)) => {
fail!("unexpected file numbers: %u, %u", x, y);
fail2!("unexpected file numbers: {}, {}", x, y);
}
};
@ -482,29 +482,29 @@ fn spawn_process_os(prog: &str, args: &[~str],
let orig_std_in = get_osfhandle(in_fd) as HANDLE;
if orig_std_in == INVALID_HANDLE_VALUE as HANDLE {
fail!("failure in get_osfhandle: %s", os::last_os_error());
fail2!("failure in get_osfhandle: {}", os::last_os_error());
}
if DuplicateHandle(cur_proc, orig_std_in, cur_proc, &mut si.hStdInput,
0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE {
fail!("failure in DuplicateHandle: %s", os::last_os_error());
fail2!("failure in DuplicateHandle: {}", os::last_os_error());
}
let orig_std_out = get_osfhandle(out_fd) as HANDLE;
if orig_std_out == INVALID_HANDLE_VALUE as HANDLE {
fail!("failure in get_osfhandle: %s", os::last_os_error());
fail2!("failure in get_osfhandle: {}", os::last_os_error());
}
if DuplicateHandle(cur_proc, orig_std_out, cur_proc, &mut si.hStdOutput,
0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE {
fail!("failure in DuplicateHandle: %s", os::last_os_error());
fail2!("failure in DuplicateHandle: {}", os::last_os_error());
}
let orig_std_err = get_osfhandle(err_fd) as HANDLE;
if orig_std_err == INVALID_HANDLE_VALUE as HANDLE {
fail!("failure in get_osfhandle: %s", os::last_os_error());
fail2!("failure in get_osfhandle: {}", os::last_os_error());
}
if DuplicateHandle(cur_proc, orig_std_err, cur_proc, &mut si.hStdError,
0, TRUE, DUPLICATE_SAME_ACCESS) == FALSE {
fail!("failure in DuplicateHandle: %s", os::last_os_error());
fail2!("failure in DuplicateHandle: {}", os::last_os_error());
}
let cmd = make_command_line(prog, args);
@ -529,7 +529,7 @@ fn spawn_process_os(prog: &str, args: &[~str],
CloseHandle(si.hStdError);
for msg in create_err.iter() {
fail!("failure in CreateProcess: %s", *msg);
fail2!("failure in CreateProcess: {}", *msg);
}
// We close the thread handle because we don't care about keeping the thread id valid,
@ -669,7 +669,7 @@ fn spawn_process_os(prog: &str, args: &[~str],
let pid = fork();
if pid < 0 {
fail!("failure in fork: %s", os::last_os_error());
fail2!("failure in fork: {}", os::last_os_error());
} else if pid > 0 {
return SpawnProcessResult {pid: pid, handle: ptr::null()};
}
@ -677,13 +677,13 @@ fn spawn_process_os(prog: &str, args: &[~str],
rustrt::rust_unset_sigprocmask();
if dup2(in_fd, 0) == -1 {
fail!("failure in dup2(in_fd, 0): %s", os::last_os_error());
fail2!("failure in dup2(in_fd, 0): {}", os::last_os_error());
}
if dup2(out_fd, 1) == -1 {
fail!("failure in dup2(out_fd, 1): %s", os::last_os_error());
fail2!("failure in dup2(out_fd, 1): {}", os::last_os_error());
}
if dup2(err_fd, 2) == -1 {
fail!("failure in dup3(err_fd, 2): %s", os::last_os_error());
fail2!("failure in dup3(err_fd, 2): {}", os::last_os_error());
}
// close all other fds
for fd in range(3, getdtablesize()).invert() {
@ -692,7 +692,7 @@ fn spawn_process_os(prog: &str, args: &[~str],
do with_dirp(dir) |dirp| {
if !dirp.is_null() && chdir(dirp) == -1 {
fail!("failure in chdir: %s", os::last_os_error());
fail2!("failure in chdir: {}", os::last_os_error());
}
}
@ -703,7 +703,7 @@ fn spawn_process_os(prog: &str, args: &[~str],
do with_argv(prog, args) |argv| {
execvp(*argv, argv);
// execvp only returns if an error occurred
fail!("failure in execvp: %s", os::last_os_error());
fail2!("failure in execvp: {}", os::last_os_error());
}
}
}
@ -749,7 +749,7 @@ fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: &fn(*c_void) -> T) -> T {
let mut tmps = vec::with_capacity(env.len());
for pair in env.iter() {
let kv = fmt!("%s=%s", pair.first(), pair.second());
let kv = format!("{}={}", pair.first(), pair.second());
tmps.push(kv.to_c_str());
}
@ -777,7 +777,7 @@ fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: &fn(*mut c_void) -> T) -> T {
let mut blk = ~[];
for pair in env.iter() {
let kv = fmt!("%s=%s", pair.first(), pair.second());
let kv = format!("{}={}", pair.first(), pair.second());
blk.push_all(kv.as_bytes());
blk.push(0);
}
@ -890,14 +890,14 @@ fn waitpid(pid: pid_t) -> int {
let proc = OpenProcess(SYNCHRONIZE | PROCESS_QUERY_INFORMATION, FALSE, pid as DWORD);
if proc.is_null() {
fail!("failure in OpenProcess: %s", os::last_os_error());
fail2!("failure in OpenProcess: {}", os::last_os_error());
}
loop {
let mut status = 0;
if GetExitCodeProcess(proc, &mut status) == FALSE {
CloseHandle(proc);
fail!("failure in GetExitCodeProcess: %s", os::last_os_error());
fail2!("failure in GetExitCodeProcess: {}", os::last_os_error());
}
if status != STILL_ACTIVE {
CloseHandle(proc);
@ -905,7 +905,7 @@ fn waitpid(pid: pid_t) -> int {
}
if WaitForSingleObject(proc, INFINITE) == WAIT_FAILED {
CloseHandle(proc);
fail!("failure in WaitForSingleObject: %s", os::last_os_error());
fail2!("failure in WaitForSingleObject: {}", os::last_os_error());
}
}
}
@ -943,7 +943,7 @@ fn waitpid(pid: pid_t) -> int {
let mut status = 0 as c_int;
if unsafe { waitpid(pid, &mut status, 0) } == -1 {
fail!("failure in waitpid: %s", os::last_os_error());
fail2!("failure in waitpid: {}", os::last_os_error());
}
return if WIFEXITED(status) {
@ -1342,7 +1342,7 @@ mod tests {
let r = os::env();
for &(ref k, ref v) in r.iter() {
// don't check windows magical empty-named variables
assert!(k.is_empty() || output.contains(fmt!("%s=%s", *k, *v)));
assert!(k.is_empty() || output.contains(format!("{}={}", *k, *v)));
}
}
#[test]
@ -1357,8 +1357,8 @@ mod tests {
for &(ref k, ref v) in r.iter() {
// don't check android RANDOM variables
if *k != ~"RANDOM" {
assert!(output.contains(fmt!("%s=%s", *k, *v)) ||
output.contains(fmt!("%s=\'%s\'", *k, *v)));
assert!(output.contains(format!("{}={}", *k, *v)) ||
output.contains(format!("{}=\'{}\'", *k, *v)));
}
}
}

View File

@ -35,7 +35,7 @@ pub trait SelectPort<T> : SelectPortInner<T> { }
/// port whose data is ready. (If multiple are ready, returns the lowest index.)
pub fn select<A: Select>(ports: &mut [A]) -> uint {
if ports.is_empty() {
fail!("can't select on an empty list");
fail2!("can't select on an empty list");
}
for (index, port) in ports.mut_iter().enumerate() {
@ -116,7 +116,7 @@ pub fn select2<TA, A: SelectPort<TA>, TB, B: SelectPort<TB>>(mut a: A, mut b: B)
match result {
0 => Left ((a.recv_ready(), b)),
1 => Right((a, b.recv_ready())),
x => fail!("impossible case in select2: %?", x)
x => fail2!("impossible case in select2: {:?}", x)
}
}
@ -335,7 +335,7 @@ mod test {
let _ = dead_cs;
}
do task::spawn {
fail!(); // should kill sibling awake
fail2!(); // should kill sibling awake
}
// wait for killed selector to close (NOT send on) its c.

View File

@ -134,8 +134,8 @@ pub fn from_utf8(vv: &[u8]) -> ~str {
match from_utf8_opt(vv) {
None => {
let first_bad_byte = *vv.iter().find(|&b| !is_utf8([*b])).unwrap();
cond.raise(fmt!("from_utf8: input is not UTF-8; first bad byte is %u",
first_bad_byte as uint))
cond.raise(format!("from_utf8: input is not UTF-8; first bad \
byte is {}", first_bad_byte))
}
Some(s) => s
}
@ -161,8 +161,8 @@ pub fn from_utf8_owned(vv: ~[u8]) -> ~str {
if !is_utf8(vv) {
let first_bad_byte = *vv.iter().find(|&b| !is_utf8([*b])).unwrap();
cond.raise(fmt!("from_utf8: input is not UTF-8; first bad byte is %u",
first_bad_byte as uint))
cond.raise(format!("from_utf8: input is not UTF-8; first bad byte is {}",
first_bad_byte))
} else {
unsafe { raw::from_utf8_owned(vv) }
}
@ -1229,7 +1229,7 @@ pub mod raw {
match ctr {
0 => assert_eq!(x, &~"zero"),
1 => assert_eq!(x, &~"one"),
_ => fail!("shouldn't happen!")
_ => fail2!("shouldn't happen!")
}
ctr += 1;
}
@ -2000,8 +2000,8 @@ impl<'self> StrSlice<'self> for &'self str {
if end_byte.is_none() && count == end { end_byte = Some(self.len()) }
match (begin_byte, end_byte) {
(None, _) => fail!("slice_chars: `begin` is beyond end of string"),
(_, None) => fail!("slice_chars: `end` is beyond end of string"),
(None, _) => fail2!("slice_chars: `begin` is beyond end of string"),
(_, None) => fail2!("slice_chars: `end` is beyond end of string"),
(Some(a), Some(b)) => unsafe { raw::slice_bytes(*self, a, b) }
}
}
@ -2723,12 +2723,12 @@ mod tests {
#[test]
fn test_collect() {
let empty = "";
let empty = ~"";
let s: ~str = empty.iter().collect();
assert_eq!(empty, s.as_slice());
let data = "ประเทศไทย中";
assert_eq!(empty, s);
let data = ~"ประเทศไทย中";
let s: ~str = data.iter().collect();
assert_eq!(data, s.as_slice());
assert_eq!(data, s);
}
#[test]
@ -3242,7 +3242,7 @@ mod tests {
// original problem code path anymore.)
let s = ~"";
let _bytes = s.as_bytes();
fail!();
fail2!();
}
#[test]
@ -3300,8 +3300,8 @@ mod tests {
while i < n1 {
let a: u8 = s1[i];
let b: u8 = s2[i];
debug!(a);
debug!(b);
debug2!("{}", a);
debug2!("{}", b);
assert_eq!(a, b);
i += 1u;
}

View File

@ -134,7 +134,7 @@ pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! {
use str::Str;
unsafe {
// XXX: Bad re-allocations. fail! needs some refactoring
// XXX: Bad re-allocations. fail2! needs some refactoring
let msg = str::raw::from_c_str(msg);
let file = str::raw::from_c_str(file);
@ -148,7 +148,7 @@ pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! {
n, msg.as_slice(), file.as_slice(), line);
}
} else {
rterrln!("failed in non-task context at '%s', %s:%i",
rterrln!("failed in non-task context at '{}', {}:{}",
msg, file, line as int);
}

View File

@ -181,7 +181,7 @@ pub fn task() -> TaskBuilder {
impl TaskBuilder {
fn consume(&mut self) -> TaskBuilder {
if self.consumed {
fail!("Cannot copy a task_builder"); // Fake move mode on self
fail2!("Cannot copy a task_builder"); // Fake move mode on self
}
self.consumed = true;
let gen_body = self.gen_body.take();
@ -271,7 +271,7 @@ impl TaskBuilder {
// sending out messages.
if self.opts.notify_chan.is_some() {
fail!("Can't set multiple future_results for one task!");
fail2!("Can't set multiple future_results for one task!");
}
// Construct the future and give it to the caller.
@ -532,7 +532,7 @@ pub fn with_task_name<U>(blk: &fn(Option<&str>) -> U) -> U {
}
}
} else {
fail!("no task name exists in non-green task context")
fail2!("no task name exists in non-green task context")
}
}
@ -640,7 +640,7 @@ fn test_kill_unkillable_task() {
do run_in_newsched_task {
do task::try {
do task::spawn {
fail!();
fail2!();
}
do task::unkillable { }
};
@ -659,7 +659,7 @@ fn test_kill_rekillable_task() {
do task::unkillable {
do task::rekillable {
do task::spawn {
fail!();
fail2!();
}
}
}
@ -689,7 +689,7 @@ fn test_rekillable_nested_failure() {
do unkillable {
do rekillable {
let (port,chan) = comm::stream();
do task::spawn { chan.send(()); fail!(); }
do task::spawn { chan.send(()); fail2!(); }
port.recv(); // wait for child to exist
port.recv(); // block forever, expect to get killed.
}
@ -733,7 +733,7 @@ fn test_spawn_unlinked_unsup_no_fail_down() { // grandchild sends on a port
do 16.times { task::deschedule(); }
ch.send(()); // If killed first, grandparent hangs.
}
fail!(); // Shouldn't kill either (grand)parent or (grand)child.
fail2!(); // Shouldn't kill either (grand)parent or (grand)child.
}
po.recv();
}
@ -743,7 +743,7 @@ fn test_spawn_unlinked_unsup_no_fail_down() { // grandchild sends on a port
fn test_spawn_unlinked_unsup_no_fail_up() { // child unlinked fails
use rt::test::run_in_newsched_task;
do run_in_newsched_task {
do spawn_unlinked { fail!(); }
do spawn_unlinked { fail2!(); }
}
}
#[ignore(reason = "linked failure")]
@ -751,7 +751,7 @@ fn test_spawn_unlinked_unsup_no_fail_up() { // child unlinked fails
fn test_spawn_unlinked_sup_no_fail_up() { // child unlinked fails
use rt::test::run_in_newsched_task;
do run_in_newsched_task {
do spawn_supervised { fail!(); }
do spawn_supervised { fail2!(); }
// Give child a chance to fail-but-not-kill-us.
do 16.times { task::deschedule(); }
}
@ -763,7 +763,7 @@ fn test_spawn_unlinked_sup_fail_down() {
do run_in_newsched_task {
let result: Result<(),()> = do try {
do spawn_supervised { block_forever(); }
fail!(); // Shouldn't leave a child hanging around.
fail2!(); // Shouldn't leave a child hanging around.
};
assert!(result.is_err());
}
@ -783,7 +783,7 @@ fn test_spawn_linked_sup_fail_up() { // child fails; parent fails
b0.opts.supervised = true;
do b0.spawn {
fail!();
fail2!();
}
block_forever(); // We should get punted awake
};
@ -802,7 +802,7 @@ fn test_spawn_linked_sup_fail_down() { // parent fails; child fails
b0.opts.linked = true;
b0.opts.supervised = true;
do b0.spawn { block_forever(); }
fail!(); // *both* mechanisms would be wrong if this didn't kill the child
fail2!(); // *both* mechanisms would be wrong if this didn't kill the child
};
assert!(result.is_err());
}
@ -814,7 +814,7 @@ fn test_spawn_linked_unsup_fail_up() { // child fails; parent fails
do run_in_newsched_task {
let result: Result<(),()> = do try {
// Default options are to spawn linked & unsupervised.
do spawn { fail!(); }
do spawn { fail2!(); }
block_forever(); // We should get punted awake
};
assert!(result.is_err());
@ -828,7 +828,7 @@ fn test_spawn_linked_unsup_fail_down() { // parent fails; child fails
let result: Result<(),()> = do try {
// Default options are to spawn linked & unsupervised.
do spawn { block_forever(); }
fail!();
fail2!();
};
assert!(result.is_err());
}
@ -843,7 +843,7 @@ fn test_spawn_linked_unsup_default_opts() { // parent fails; child fails
let mut builder = task();
builder.linked();
do builder.spawn { block_forever(); }
fail!();
fail2!();
};
assert!(result.is_err());
}
@ -863,7 +863,7 @@ fn test_spawn_failure_propagate_grandchild() {
do spawn_supervised { block_forever(); }
}
do 16.times { task::deschedule(); }
fail!();
fail2!();
};
assert!(result.is_err());
}
@ -880,7 +880,7 @@ fn test_spawn_failure_propagate_secondborn() {
do spawn { block_forever(); } // linked
}
do 16.times { task::deschedule(); }
fail!();
fail2!();
};
assert!(result.is_err());
}
@ -897,7 +897,7 @@ fn test_spawn_failure_propagate_nephew_or_niece() {
do spawn_supervised { block_forever(); }
}
do 16.times { task::deschedule(); }
fail!();
fail2!();
};
assert!(result.is_err());
}
@ -914,7 +914,7 @@ fn test_spawn_linked_sup_propagate_sibling() {
do spawn { block_forever(); } // linked
}
do 16.times { task::deschedule(); }
fail!();
fail2!();
};
assert!(result.is_err());
}
@ -994,7 +994,7 @@ fn test_future_result() {
builder.future_result(|r| result = Some(r));
builder.unlinked();
do builder.spawn {
fail!();
fail2!();
}
assert_eq!(result.unwrap().recv(), Failure);
}
@ -1012,17 +1012,17 @@ fn test_try_success() {
~"Success!"
} {
result::Ok(~"Success!") => (),
_ => fail!()
_ => fail2!()
}
}
#[test]
fn test_try_fail() {
match do try {
fail!()
fail2!()
} {
result::Err(()) => (),
result::Ok(()) => fail!()
result::Ok(()) => fail2!()
}
}
@ -1212,7 +1212,7 @@ fn test_unkillable() {
deschedule();
// We want to fail after the unkillable task
// blocks on recv
fail!();
fail2!();
}
unsafe {
@ -1247,7 +1247,7 @@ fn test_unkillable_nested() {
deschedule();
// We want to fail after the unkillable task
// blocks on recv
fail!();
fail2!();
}
unsafe {
@ -1312,7 +1312,7 @@ fn test_spawn_watched() {
t.watched();
do t.spawn {
task::deschedule();
fail!();
fail2!();
}
}
};
@ -1348,7 +1348,7 @@ fn test_indestructible() {
do t.spawn {
p3.recv();
task::deschedule();
fail!();
fail2!();
}
c3.send(());
p2.recv();

View File

@ -712,7 +712,7 @@ fn test_spawn_raw_unsupervise() {
.. default_task_opts()
};
do spawn_raw(opts) {
fail!();
fail2!();
}
}
@ -741,7 +741,7 @@ fn test_spawn_raw_notify_failure() {
.. default_task_opts()
};
do spawn_raw(opts) {
fail!();
fail2!();
}
assert_eq!(notify_po.recv(), Failure);
}

View File

@ -45,7 +45,7 @@ impl<A:ToStr> ToStr for (A,) {
fn to_str(&self) -> ~str {
match *self {
(ref a,) => {
fmt!("(%s,)", (*a).to_str())
format!("({},)", (*a).to_str())
}
}
}
@ -98,7 +98,7 @@ impl<A:ToStr,B:ToStr> ToStr for (A, B) {
//let &(ref a, ref b) = self;
match *self {
(ref a, ref b) => {
fmt!("(%s, %s)", (*a).to_str(), (*b).to_str())
format!("({}, {})", (*a).to_str(), (*b).to_str())
}
}
}
@ -111,7 +111,7 @@ impl<A:ToStr,B:ToStr,C:ToStr> ToStr for (A, B, C) {
//let &(ref a, ref b, ref c) = self;
match *self {
(ref a, ref b, ref c) => {
fmt!("(%s, %s, %s)",
format!("({}, {}, {})",
(*a).to_str(),
(*b).to_str(),
(*c).to_str()
@ -221,7 +221,7 @@ mod tests {
impl ToStr for StructWithToStrWithoutEqOrHash {
fn to_str(&self) -> ~str {
fmt!("s%d", self.value)
format!("s{}", self.value)
}
}

View File

@ -422,7 +422,7 @@ fn remove<T>(count: &mut uint, child: &mut Child<T>, key: uint,
External(stored, _) if stored == key => {
match replace(child, Nothing) {
External(_, value) => (Some(value), true),
_ => fail!()
_ => fail2!()
}
}
External(*) => (None, false),
@ -531,7 +531,7 @@ mod test_map {
assert!(m.insert(5, 14));
let new = 100;
match m.find_mut(&5) {
None => fail!(), Some(x) => *x = new
None => fail2!(), Some(x) => *x = new
}
assert_eq!(m.find(&5), Some(&new));
}

View File

@ -33,7 +33,7 @@ impl Drop for DynamicLibrary {
}
} {
Ok(()) => {},
Err(str) => fail!(str)
Err(str) => fail2!("{}", str)
}
}
}
@ -96,7 +96,7 @@ mod test {
// The math library does not need to be loaded since it is already
// statically linked in
let libm = match DynamicLibrary::open(None) {
Err(error) => fail!("Could not load self as module: %s", error),
Err(error) => fail2!("Could not load self as module: {}", error),
Ok(libm) => libm
};
@ -104,7 +104,7 @@ mod test {
// this as a C function
let cosine: extern fn(libc::c_double) -> libc::c_double = unsafe {
match libm.symbol("cos") {
Err(error) => fail!("Could not load function cos: %s", error),
Err(error) => fail2!("Could not load function cos: {}", error),
Ok(cosine) => cosine
}
};
@ -113,7 +113,7 @@ mod test {
let expected_result = 1.0;
let result = cosine(argument);
if result != expected_result {
fail!("cos(%?) != %? but equaled %? instead", argument,
fail2!("cos({:?}) != {:?} but equaled {:?} instead", argument,
expected_result, result)
}
}
@ -129,7 +129,7 @@ mod test {
let path = GenericPath::from_str("/dev/null");
match DynamicLibrary::open(Some(&path)) {
Err(_) => {}
Ok(_) => fail!("Successfully opened the empty library.")
Ok(_) => fail2!("Successfully opened the empty library.")
}
}
}
@ -241,7 +241,7 @@ pub mod dl {
if 0 == error {
Ok(result)
} else {
Err(fmt!("Error code %?", error))
Err(format!("Error code {}", error))
}
}
}

View File

@ -333,14 +333,14 @@ pub mod ct {
'f' => TyFloat,
'p' => TyPointer,
'?' => TyPoly,
_ => err(fmt!("unknown type in conversion: %c", s.char_at(i)))
_ => err(format!("unknown type in conversion: {}", s.char_at(i)))
};
Parsed::new(t, i + 1)
}
#[cfg(test)]
fn die(s: &str) -> ! { fail!(s.to_owned()) }
fn die(s: &str) -> ! { fail2!(s.to_owned()) }
#[test]
fn test_parse_count() {
@ -698,6 +698,6 @@ mod test {
#[test]
fn fmt_slice() {
let s = "abc";
let _s = fmt!("%s", s);
let _s = format!("{}", s);
}
}

View File

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

View File

@ -27,8 +27,8 @@ pub fn fail_(expr: *c_char, file: *c_char, line: size_t) -> ! {
#[lang="fail_bounds_check"]
pub fn fail_bounds_check(file: *c_char, line: size_t,
index: size_t, len: size_t) {
let msg = fmt!("index out of bounds: the len is %d but the index is %d",
len as int, index as int);
let msg = format!("index out of bounds: the len is {} but the index is {}",
len as int, index as int);
do msg.with_c_str |buf| {
fail_(buf, file, line);
}

View File

@ -172,7 +172,7 @@ impl<T: Send> UnsafeArc<T> {
// If 'put' returns the server end back to us, we were rejected;
// someone else was trying to unwrap. Avoid guaranteed deadlock.
cast::forget(data);
fail!("Another task is already unwrapping this Arc!");
fail2!("Another task is already unwrapping this Arc!");
}
}
}
@ -386,7 +386,7 @@ impl<T:Send> Exclusive<T> {
let rec = self.x.get();
do (*rec).lock.lock {
if (*rec).failed {
fail!("Poisoned Exclusive::new - another task failed inside!");
fail2!("Poisoned Exclusive::new - another task failed inside!");
}
(*rec).failed = true;
let result = f(&mut (*rec).data);
@ -618,7 +618,7 @@ mod tests {
let x2 = x.clone();
do task::spawn {
do 10.times { task::deschedule(); } // try to let the unwrapper go
fail!(); // punt it awake from its deadlock
fail2!(); // punt it awake from its deadlock
}
let _z = x.unwrap();
unsafe { do x2.with |_hello| { } }

View File

@ -1022,7 +1022,7 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] {
/// Returns the first element of a vector, failing if the vector is empty.
#[inline]
fn head(&self) -> &'self T {
if self.len() == 0 { fail!("head: empty vector") }
if self.len() == 0 { fail2!("head: empty vector") }
&self[0]
}
@ -1055,7 +1055,7 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] {
/// Returns the last element of a vector, failing if the vector is empty.
#[inline]
fn last(&self) -> &'self T {
if self.len() == 0 { fail!("last: empty vector") }
if self.len() == 0 { fail2!("last: empty vector") }
&self[self.len() - 1]
}
@ -1301,7 +1301,7 @@ impl<T> OwnedVector<T> for ~[T] {
let alloc = n * sys::nonzero_size_of::<T>();
let size = alloc + sys::size_of::<Vec<()>>();
if alloc / sys::nonzero_size_of::<T>() != n || size < alloc {
fail!("vector size is too large: %u", n);
fail2!("vector size is too large: {}", n);
}
*ptr = realloc_raw(*ptr as *mut c_void, size)
as *mut Vec<()>;
@ -1343,7 +1343,7 @@ impl<T> OwnedVector<T> for ~[T] {
fn reserve_additional(&mut self, n: uint) {
if self.capacity() - self.len() < n {
match self.len().checked_add(&n) {
None => fail!("vec::reserve_additional: `uint` overflow"),
None => fail2!("vec::reserve_additional: `uint` overflow"),
Some(new_cap) => self.reserve_at_least(new_cap)
}
}
@ -1570,7 +1570,7 @@ impl<T> OwnedVector<T> for ~[T] {
fn swap_remove(&mut self, index: uint) -> T {
let ln = self.len();
if index >= ln {
fail!("vec::swap_remove - index %u >= length %u", index, ln);
fail2!("vec::swap_remove - index {} >= length {}", index, ln);
}
if index < ln - 1 {
self.swap(index, ln - 1);
@ -2958,7 +2958,7 @@ mod tests {
3 => assert_eq!(v, [2, 3, 1]),
4 => assert_eq!(v, [2, 1, 3]),
5 => assert_eq!(v, [1, 2, 3]),
_ => fail!(),
_ => fail2!(),
}
}
}
@ -3205,7 +3205,7 @@ mod tests {
#[should_fail]
fn test_from_fn_fail() {
do from_fn(100) |v| {
if v == 50 { fail!() }
if v == 50 { fail2!() }
(~0, @0)
};
}
@ -3224,7 +3224,7 @@ mod tests {
fn clone(&self) -> S {
let s = unsafe { cast::transmute_mut(self) };
s.f += 1;
if s.f == 10 { fail!() }
if s.f == 10 { fail2!() }
S { f: s.f, boxes: s.boxes.clone() }
}
}
@ -3241,7 +3241,7 @@ mod tests {
push((~0, @0));
push((~0, @0));
push((~0, @0));
fail!();
fail2!();
};
}
@ -3251,7 +3251,7 @@ mod tests {
let mut v = ~[];
do v.grow_fn(100) |i| {
if i == 50 {
fail!()
fail2!()
}
(~0, @0)
}
@ -3264,7 +3264,7 @@ mod tests {
let mut i = 0;
do v.map |_elt| {
if i == 2 {
fail!()
fail2!()
}
i += 1;
~[(~0, @0)]
@ -3278,7 +3278,7 @@ mod tests {
let mut i = 0;
do flat_map(v) |_elt| {
if i == 2 {
fail!()
fail2!()
}
i += 1;
~[(~0, @0)]
@ -3292,7 +3292,7 @@ mod tests {
let mut i = 0;
for _ in v.permutations_iter() {
if i == 2 {
fail!()
fail2!()
}
i += 1;
}
@ -3303,7 +3303,7 @@ mod tests {
fn test_as_imm_buf_fail() {
let v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
do v.as_imm_buf |_buf, _i| {
fail!()
fail2!()
}
}
@ -3312,7 +3312,7 @@ mod tests {
fn test_as_mut_buf_fail() {
let mut v = [(~0, @0), (~0, @0), (~0, @0), (~0, @0)];
do v.as_mut_buf |_buf, _i| {
fail!()
fail2!()
}
}
@ -3702,11 +3702,11 @@ mod tests {
assert_eq!(cnt, 11);
let xs = ~[Foo, Foo, Foo];
assert_eq!(fmt!("%?", xs.slice(0, 2).to_owned()),
assert_eq!(format!("{:?}", xs.slice(0, 2).to_owned()),
~"~[vec::tests::Foo, vec::tests::Foo]");
let xs: [Foo, ..3] = [Foo, Foo, Foo];
assert_eq!(fmt!("%?", xs.slice(0, 2).to_owned()),
assert_eq!(format!("{:?}", xs.slice(0, 2).to_owned()),
~"~[vec::tests::Foo, vec::tests::Foo]");
cnt = 0;
for f in xs.iter() {
@ -3749,7 +3749,7 @@ mod bench {
sum += *x;
}
// sum == 11806, to stop dead code elimination.
if sum == 0 {fail!()}
if sum == 0 {fail2!()}
}
}