Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add println!() macro with out any arguments #36825

Merged
merged 1 commit into from
Oct 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/libstd/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,14 @@ macro_rules! print {
/// # Examples
///
/// ```
/// println!();
/// println!("hello there!");
/// println!("format {} arguments", "some");
/// ```
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
macro_rules! println {
() => (print!("\n"));
($fmt:expr) => (print!(concat!($fmt, "\n")));
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
}
Expand Down
6 changes: 5 additions & 1 deletion src/test/compile-fail/empty-comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
// This could break some internal logic that assumes the length of a doc comment is at least 5,
// leading to an ICE.

macro_rules! one_arg_macro {
($fmt:expr) => (print!(concat!($fmt, "\n")));
}

fn main() {
println!(/**/); //~ ERROR unexpected end
one_arg_macro!(/**/); //~ ERROR unexpected end
}
6 changes: 5 additions & 1 deletion src/test/compile-fail/issue-7970a.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

macro_rules! one_arg_macro {
($fmt:expr) => (print!(concat!($fmt, "\n")));
}

fn main() {
println!();
one_arg_macro!();
//~^ ERROR unexpected end of macro invocation
}