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

@ -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| { } }