From 42aed6bde2fb05a262e21334656cdf91f51744dd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 27 May 2014 20:44:58 -0700 Subject: std: Remove format_strbuf!() This was only ever a transitionary macro. --- src/libstd/ascii.rs | 2 +- src/libstd/fmt.rs | 7 ------- src/libstd/io/fs.rs | 9 ++++----- src/libstd/io/tempfile.rs | 8 ++++---- src/libstd/io/test.rs | 10 +++++----- src/libstd/macros.rs | 8 -------- src/libstd/num/int_macros.rs | 2 +- src/libstd/num/uint_macros.rs | 2 +- src/libstd/os.rs | 4 ++-- src/libstd/path/windows.rs | 2 +- src/libstd/rt/unwind.rs | 2 +- src/libstd/str.rs | 4 ++-- src/libstd/to_str.rs | 2 +- 13 files changed, 23 insertions(+), 39 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 55bbf4ddf75..75b31f9c354 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -783,6 +783,6 @@ mod tests { #[test] fn test_show() { let c = Ascii { chr: 't' as u8 }; - assert_eq!(format_strbuf!("{}", c), "t".to_string()); + assert_eq!(format!("{}", c), "t".to_string()); } } diff --git a/src/libstd/fmt.rs b/src/libstd/fmt.rs index d53a0f93c9b..9bca2f4248c 100644 --- a/src/libstd/fmt.rs +++ b/src/libstd/fmt.rs @@ -562,13 +562,6 @@ pub fn format(args: &Arguments) -> string::String{ str::from_utf8(output.unwrap().as_slice()).unwrap().into_string() } -/// Temporary transition utility -pub fn format_strbuf(args: &Arguments) -> string::String { - let mut output = io::MemWriter::new(); - let _ = write!(&mut output, "{}", args); - str::from_utf8(output.unwrap().as_slice()).unwrap().into_string() -} - #[cfg(stage0)] impl Poly for T { fn fmt(&self, f: &mut Formatter) -> Result { diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index d3e250be9a3..a77c7107f28 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -745,8 +745,7 @@ mod test { pub fn tmpdir() -> TempDir { use os; use rand; - let ret = os::tmpdir().join( - format_strbuf!("rust-{}", rand::random::())); + let ret = os::tmpdir().join(format!("rust-{}", rand::random::())); check!(io::fs::mkdir(&ret, io::UserRWX)); TempDir(ret) } @@ -953,7 +952,7 @@ mod test { check!(mkdir(dir, io::UserRWX)); let prefix = "foo"; for n in range(0,3) { - let f = dir.join(format_strbuf!("{}.txt", n)); + let f = dir.join(format!("{}.txt", n)); let mut w = check!(File::create(&f)); let msg_str = format!("{}{}", prefix, n.to_str()); let msg = msg_str.as_slice().as_bytes(); @@ -1040,7 +1039,7 @@ mod test { let tmpdir = tmpdir(); let mut dirpath = tmpdir.path().clone(); - dirpath.push(format_strbuf!("test-가一ー你好")); + dirpath.push(format!("test-가一ー你好")); check!(mkdir(&dirpath, io::UserRWX)); assert!(dirpath.is_dir()); @@ -1057,7 +1056,7 @@ mod test { let tmpdir = tmpdir(); let unicode = tmpdir.path(); - let unicode = unicode.join(format_strbuf!("test-각丁ー再见")); + let unicode = unicode.join(format!("test-각丁ー再见")); check!(mkdir(&unicode, io::UserRWX)); assert!(unicode.exists()); assert!(!Path::new("test/unicode-bogus-path-각丁ー再见").exists()); diff --git a/src/libstd/io/tempfile.rs b/src/libstd/io/tempfile.rs index 806df838c91..5ca7e417af6 100644 --- a/src/libstd/io/tempfile.rs +++ b/src/libstd/io/tempfile.rs @@ -43,10 +43,10 @@ impl TempDir { for _ in range(0u, 1000) { let filename = - format_strbuf!("rs-{}-{}-{}", - unsafe { libc::getpid() }, - unsafe { CNT.fetch_add(1, atomics::SeqCst) }, - suffix); + format!("rs-{}-{}-{}", + unsafe { libc::getpid() }, + unsafe { CNT.fetch_add(1, atomics::SeqCst) }, + suffix); let p = tmpdir.join(filename); match fs::mkdir(&p, io::UserRWX) { Err(..) => {} diff --git a/src/libstd/io/test.rs b/src/libstd/io/test.rs index bc52bc9946c..4d3dde46b57 100644 --- a/src/libstd/io/test.rs +++ b/src/libstd/io/test.rs @@ -67,14 +67,14 @@ pub fn next_test_unix() -> Path { // base port and pid are an attempt to be unique between multiple // test-runners of different configurations running on one // buildbot, the count is to be unique within this executable. - let string = format_strbuf!("rust-test-unix-path-{}-{}-{}", - base_port(), - unsafe {libc::getpid()}, - unsafe {COUNT.fetch_add(1, Relaxed)}); + let string = format!("rust-test-unix-path-{}-{}-{}", + base_port(), + unsafe {libc::getpid()}, + unsafe {COUNT.fetch_add(1, Relaxed)}); if cfg!(unix) { os::tmpdir().join(string) } else { - Path::new(format_strbuf!("{}{}", r"\\.\pipe\", string)) + Path::new(format!("{}{}", r"\\.\pipe\", string)) } } diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 28b4552fd4c..0b9fc250636 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -229,14 +229,6 @@ macro_rules! format( ) ) -/// Temporary transitionary thing. -#[macro_export] -macro_rules! format_strbuf( - ($($arg:tt)*) => ( - format_args!(::std::fmt::format_strbuf, $($arg)*) - ) -) - /// Use the `format!` syntax to write data into a buffer of type `&mut Writer`. /// See `std::fmt` for more information. /// diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index 7ed00e3dd9d..889a42ec00e 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -78,7 +78,7 @@ impl ToStrRadix for $T { /// Convert to a string in a given base. #[inline] fn to_str_radix(&self, radix: uint) -> String { - format_strbuf!("{}", ::fmt::radix(*self, radix as u8)) + format!("{}", ::fmt::radix(*self, radix as u8)) } } diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index 43048453717..769588d0bcb 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -79,7 +79,7 @@ impl ToStrRadix for $T { /// Convert to a string in a given base. #[inline] fn to_str_radix(&self, radix: uint) -> String { - format_strbuf!("{}", ::fmt::radix(*self, radix as u8)) + format!("{}", ::fmt::radix(*self, radix as u8)) } } diff --git a/src/libstd/os.rs b/src/libstd/os.rs index 7d3758d621d..f960228c63c 100644 --- a/src/libstd/os.rs +++ b/src/libstd/os.rs @@ -437,7 +437,7 @@ pub fn pipe() -> Pipe { /// Returns the proper dll filename for the given basename of a file. pub fn dll_filename(base: &str) -> String { - format_strbuf!("{}{}{}", consts::DLL_PREFIX, base, consts::DLL_SUFFIX) + format!("{}{}{}", consts::DLL_PREFIX, base, consts::DLL_SUFFIX) } /// Optionally returns the filesystem path of the current executable which is @@ -1513,7 +1513,7 @@ mod tests { fn make_rand_name() -> String { let mut rng = rand::task_rng(); - let n = format_strbuf!("TEST{}", rng.gen_ascii_str(10u).as_slice()); + let n = format!("TEST{}", rng.gen_ascii_str(10u).as_slice()); assert!(getenv(n.as_slice()).is_none()); n } diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 1fc2fa1d221..88c3e9def8c 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -900,7 +900,7 @@ pub fn make_non_verbatim(path: &Path) -> Option { } Some(VerbatimUNCPrefix(_,_)) => { // \\?\UNC\server\share - Path::new(format_strbuf!(r"\\{}", repr.slice_from(7))) + Path::new(format!(r"\\{}", repr.slice_from(7))) } }; if new_path.prefix.is_none() { diff --git a/src/libstd/rt/unwind.rs b/src/libstd/rt/unwind.rs index be05bfceaac..f34dcaaa427 100644 --- a/src/libstd/rt/unwind.rs +++ b/src/libstd/rt/unwind.rs @@ -354,7 +354,7 @@ pub fn begin_unwind_fmt(msg: &fmt::Arguments, file: &'static str, // required with the current scheme, and (b) we don't handle // failure + OOM properly anyway (see comment in begin_unwind // below). - begin_unwind_inner(box fmt::format_strbuf(msg), file, line) + begin_unwind_inner(box fmt::format(msg), file, line) } /// This is the entry point of unwinding for fail!() and assert!(). diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 9e15612c72b..b80b2581e08 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -2123,7 +2123,7 @@ mod tests { assert_eq!(s.len(), 5); assert_eq!(s.as_slice(), "abcde"); assert_eq!(s.to_str(), "abcde".to_string()); - assert_eq!(format_strbuf!("{}", s), "abcde".to_string()); + assert_eq!(format!("{}", s), "abcde".to_string()); assert!(s.lt(&Owned("bcdef".to_string()))); assert_eq!(Slice(""), Default::default()); @@ -2131,7 +2131,7 @@ mod tests { assert_eq!(o.len(), 5); assert_eq!(o.as_slice(), "abcde"); assert_eq!(o.to_str(), "abcde".to_string()); - assert_eq!(format_strbuf!("{}", o), "abcde".to_string()); + assert_eq!(format!("{}", o), "abcde".to_string()); assert!(o.lt(&Slice("bcdef"))); assert_eq!(Owned("".to_string()), Default::default()); diff --git a/src/libstd/to_str.rs b/src/libstd/to_str.rs index c2100111e12..3b223b68ee6 100644 --- a/src/libstd/to_str.rs +++ b/src/libstd/to_str.rs @@ -31,7 +31,7 @@ pub trait IntoStr { impl ToStr for T { fn to_str(&self) -> String { - format_strbuf!("{}", *self) + format!("{}", *self) } } -- cgit 1.4.1-3-g733a5