Auto merge of #36825 - sbwtw:master, r=alexcrichton
add println!() macro with out any arguments lets add println!() to write "\n". like java https://docs.oracle.com/javase/7/docs/api/java/io/PrintStream.html#println()
This commit is contained in:
@@ -112,12 +112,14 @@ macro_rules! print {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
/// println!();
|
||||||
/// println!("hello there!");
|
/// println!("hello there!");
|
||||||
/// println!("format {} arguments", "some");
|
/// println!("format {} arguments", "some");
|
||||||
/// ```
|
/// ```
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
macro_rules! println {
|
macro_rules! println {
|
||||||
|
() => (print!("\n"));
|
||||||
($fmt:expr) => (print!(concat!($fmt, "\n")));
|
($fmt:expr) => (print!(concat!($fmt, "\n")));
|
||||||
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
|
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,10 @@
|
|||||||
// This could break some internal logic that assumes the length of a doc comment is at least 5,
|
// This could break some internal logic that assumes the length of a doc comment is at least 5,
|
||||||
// leading to an ICE.
|
// leading to an ICE.
|
||||||
|
|
||||||
fn main() {
|
macro_rules! one_arg_macro {
|
||||||
println!(/**/); //~ ERROR unexpected end
|
($fmt:expr) => (print!(concat!($fmt, "\n")));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
one_arg_macro!(/**/); //~ ERROR unexpected end
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,11 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
|
macro_rules! one_arg_macro {
|
||||||
|
($fmt:expr) => (print!(concat!($fmt, "\n")));
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!();
|
one_arg_macro!();
|
||||||
//~^ ERROR unexpected end of macro invocation
|
//~^ ERROR unexpected end of macro invocation
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user