Fallout of changing format_args!(f, args) to f(format_args!(args)).
This commit is contained in:
@@ -17,6 +17,50 @@
|
||||
#![experimental]
|
||||
#![macro_escape]
|
||||
|
||||
// NOTE(stage0): Remove cfg after a snapshot
|
||||
#[cfg(not(stage0))]
|
||||
/// The entry point for panic of Rust tasks.
|
||||
///
|
||||
/// This macro is used to inject panic into a Rust task, causing the task to
|
||||
/// unwind and panic entirely. Each task's panic can be reaped as the
|
||||
/// `Box<Any>` type, and the single-argument form of the `panic!` macro will be
|
||||
/// the value which is transmitted.
|
||||
///
|
||||
/// The multi-argument form of this macro panics with a string and has the
|
||||
/// `format!` syntax for building a string.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```should_fail
|
||||
/// # #![allow(unreachable_code)]
|
||||
/// panic!();
|
||||
/// panic!("this is a terrible mistake!");
|
||||
/// panic!(4i); // panic with the value of 4 to be collected elsewhere
|
||||
/// panic!("this is a {} {message}", "fancy", message = "message");
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! panic {
|
||||
() => ({
|
||||
panic!("explicit panic")
|
||||
});
|
||||
($msg:expr) => ({
|
||||
// static requires less code at runtime, more constant data
|
||||
static _FILE_LINE: (&'static str, uint) = (file!(), line!());
|
||||
::std::rt::begin_unwind($msg, &_FILE_LINE)
|
||||
});
|
||||
($fmt:expr, $($arg:tt)*) => ({
|
||||
// The leading _'s are to avoid dead code warnings if this is
|
||||
// used inside a dead function. Just `#[allow(dead_code)]` is
|
||||
// insufficient, since the user may have
|
||||
// `#[forbid(dead_code)]` and which cannot be overridden.
|
||||
static _FILE_LINE: (&'static str, uint) = (file!(), line!());
|
||||
::std::rt::begin_unwind_fmt(format_args!($fmt, $($arg)*), &_FILE_LINE)
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove macro after a snapshot
|
||||
#[cfg(stage0)]
|
||||
/// The entry point for panic of Rust tasks.
|
||||
///
|
||||
/// This macro is used to inject panic into a Rust task, causing the task to
|
||||
@@ -245,6 +289,26 @@ macro_rules! unimplemented {
|
||||
() => (panic!("not yet implemented"))
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove cfg after a snapshot
|
||||
#[cfg(not(stage0))]
|
||||
/// Use the syntax described in `std::fmt` to create a value of type `String`.
|
||||
/// See `std::fmt` for more information.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// format!("test");
|
||||
/// format!("hello {}", "world!");
|
||||
/// format!("x = {}, y = {y}", 10i, y = 30i);
|
||||
/// ```
|
||||
#[macro_export]
|
||||
#[stable]
|
||||
macro_rules! format {
|
||||
($($arg:tt)*) => (::std::fmt::format(format_args!($($arg)*)))
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove macro after a snapshot
|
||||
#[cfg(stage0)]
|
||||
/// Use the syntax described in `std::fmt` to create a value of type `String`.
|
||||
/// See `std::fmt` for more information.
|
||||
///
|
||||
@@ -263,6 +327,28 @@ macro_rules! format {
|
||||
)
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove cfg after a snapshot
|
||||
#[cfg(not(stage0))]
|
||||
/// Use the `format!` syntax to write data into a buffer of type `&mut Writer`.
|
||||
/// See `std::fmt` for more information.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// # #![allow(unused_must_use)]
|
||||
///
|
||||
/// let mut w = Vec::new();
|
||||
/// write!(&mut w, "test");
|
||||
/// write!(&mut w, "formatted {}", "arguments");
|
||||
/// ```
|
||||
#[macro_export]
|
||||
#[stable]
|
||||
macro_rules! write {
|
||||
($dst:expr, $($arg:tt)*) => ((&mut *$dst).write_fmt(format_args!($($arg)*)))
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove macro after a snapshot
|
||||
#[cfg(stage0)]
|
||||
/// Use the `format!` syntax to write data into a buffer of type `&mut Writer`.
|
||||
/// See `std::fmt` for more information.
|
||||
///
|
||||
@@ -294,6 +380,18 @@ macro_rules! writeln {
|
||||
)
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove cfg after a snapshot
|
||||
#[cfg(not(stage0))]
|
||||
/// Equivalent to the `println!` macro except that a newline is not printed at
|
||||
/// the end of the message.
|
||||
#[macro_export]
|
||||
#[stable]
|
||||
macro_rules! print {
|
||||
($($arg:tt)*) => (::std::io::stdio::print_args(format_args!($($arg)*)))
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove macro after a snapshot
|
||||
#[cfg(stage0)]
|
||||
/// Equivalent to the `println!` macro except that a newline is not printed at
|
||||
/// the end of the message.
|
||||
#[macro_export]
|
||||
@@ -302,6 +400,28 @@ macro_rules! print {
|
||||
($($arg:tt)*) => (format_args!(::std::io::stdio::print_args, $($arg)*))
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove cfg after a snapshot
|
||||
#[cfg(not(stage0))]
|
||||
/// Macro for printing to a task's stdout handle.
|
||||
///
|
||||
/// Each task can override its stdout handle via `std::io::stdio::set_stdout`.
|
||||
/// The syntax of this macro is the same as that used for `format!`. For more
|
||||
/// information, see `std::fmt` and `std::io::stdio`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// println!("hello there!");
|
||||
/// println!("format {} arguments", "some");
|
||||
/// ```
|
||||
#[macro_export]
|
||||
#[stable]
|
||||
macro_rules! println {
|
||||
($($arg:tt)*) => (::std::io::stdio::println_args(format_args!($($arg)*)))
|
||||
}
|
||||
|
||||
// NOTE(stage0): Remove macro after a snapshot
|
||||
#[cfg(stage0)]
|
||||
/// Macro for printing to a task's stdout handle.
|
||||
///
|
||||
/// Each task can override its stdout handle via `std::io::stdio::set_stdout`.
|
||||
@@ -411,11 +531,10 @@ macro_rules! log {
|
||||
pub mod builtin {
|
||||
/// The core macro for formatted string creation & output.
|
||||
///
|
||||
/// This macro takes as its first argument a callable expression which will
|
||||
/// receive as its first argument a value of type `&fmt::Arguments`. This
|
||||
/// value can be passed to the functions in `std::fmt` for performing useful
|
||||
/// functions. All other formatting macros (`format!`, `write!`,
|
||||
/// `println!`, etc) are proxied through this one.
|
||||
/// This macro produces a value of type `fmt::Arguments`. This value can be
|
||||
/// passed to the functions in `std::fmt` for performing useful functions.
|
||||
/// All other formatting macros (`format!`, `write!`, `println!`, etc) are
|
||||
/// proxied through this one.
|
||||
///
|
||||
/// For more information, see the documentation in `std::fmt`.
|
||||
///
|
||||
@@ -424,15 +543,12 @@ pub mod builtin {
|
||||
/// ```rust
|
||||
/// use std::fmt;
|
||||
///
|
||||
/// let s = format_args!(fmt::format, "hello {}", "world");
|
||||
/// let s = fmt::format(format_args!("hello {}", "world"));
|
||||
/// assert_eq!(s, format!("hello {}", "world"));
|
||||
///
|
||||
/// format_args!(|args| {
|
||||
/// // pass `args` to another function, etc.
|
||||
/// }, "hello {}", "world");
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! format_args { ($closure:expr, $fmt:expr $($args:tt)*) => ({
|
||||
macro_rules! format_args { ($fmt:expr $($args:tt)*) => ({
|
||||
/* compiler built-in */
|
||||
}) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user