-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Comprehensively support trailing commas in std/core macros #48056
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5fa97c3
add tests for macro trailing commas
ExpHP 96eed86
libcore/libstd: fix commas in macro_rules! macros
ExpHP 1137fb1
libsyntax/ext: trailing commas in builtin macros
ExpHP b7c6dc6
update the builtin macro doc stubs
ExpHP 9205f3d
macro-commas test cleanup
ExpHP af503be
ignore-pretty for the macro-comma-support test
ExpHP File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// Companion test to the similarly-named file in run-pass. | ||
|
||
// compile-flags: -C debug_assertions=yes | ||
// revisions: std core | ||
|
||
#![cfg_attr(core, no_std)] | ||
|
||
#[cfg(std)] use std::fmt; | ||
#[cfg(core)] use core::fmt; | ||
|
||
// (see documentation of the similarly-named test in run-pass) | ||
fn to_format_or_not_to_format() { | ||
let falsum = || false; | ||
|
||
// assert!(true, "{}",); // see run-pass | ||
|
||
assert_eq!(1, 1, "{}",); | ||
//[core]~^ ERROR no arguments | ||
//[std]~^^ ERROR no arguments | ||
assert_ne!(1, 2, "{}",); | ||
//[core]~^ ERROR no arguments | ||
//[std]~^^ ERROR no arguments | ||
|
||
// debug_assert!(true, "{}",); // see run-pass | ||
|
||
debug_assert_eq!(1, 1, "{}",); | ||
//[core]~^ ERROR no arguments | ||
//[std]~^^ ERROR no arguments | ||
debug_assert_ne!(1, 2, "{}",); | ||
//[core]~^ ERROR no arguments | ||
//[std]~^^ ERROR no arguments | ||
|
||
#[cfg(std)] { | ||
eprint!("{}",); | ||
//[std]~^ ERROR no arguments | ||
} | ||
|
||
#[cfg(std)] { | ||
// FIXME: compile-fail says "expected error not found" even though | ||
// rustc does emit an error | ||
// eprintln!("{}",); | ||
// <DISABLED> [std]~^ ERROR no arguments | ||
} | ||
|
||
#[cfg(std)] { | ||
format!("{}",); | ||
//[std]~^ ERROR no arguments | ||
} | ||
|
||
format_args!("{}",); | ||
//[core]~^ ERROR no arguments | ||
//[std]~^^ ERROR no arguments | ||
|
||
// if falsum() { panic!("{}",); } // see run-pass | ||
|
||
#[cfg(std)] { | ||
print!("{}",); | ||
//[std]~^ ERROR no arguments | ||
} | ||
|
||
#[cfg(std)] { | ||
// FIXME: compile-fail says "expected error not found" even though | ||
// rustc does emit an error | ||
// println!("{}",); | ||
// <DISABLED> [std]~^ ERROR no arguments | ||
} | ||
|
||
unimplemented!("{}",); | ||
//[core]~^ ERROR no arguments | ||
//[std]~^^ ERROR no arguments | ||
|
||
// if falsum() { unreachable!("{}",); } // see run-pass | ||
|
||
struct S; | ||
impl fmt::Display for S { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
write!(f, "{}",)?; | ||
//[core]~^ ERROR no arguments | ||
//[std]~^^ ERROR no arguments | ||
|
||
// FIXME: compile-fail says "expected error not found" even though | ||
// rustc does emit an error | ||
// writeln!(f, "{}",)?; | ||
// <DISABLED> [core]~^ ERROR no arguments | ||
// <DISABLED> [std]~^^ ERROR no arguments | ||
Ok(()) | ||
} | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// This is a companion to the similarly-named test in run-pass. | ||
// | ||
// It tests macros that unavoidably produce compile errors. | ||
|
||
fn compile_error() { | ||
compile_error!("lel"); //~ ERROR lel | ||
compile_error!("lel",); //~ ERROR lel | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover FIXME
Unless someone knows what's up, I'm tempted to just leave this one here, to document that it would be tested here if it could.
(IMO the regressions that would be caught by this test are far, far less likely to occur than the ones that would be caught by the corresponding tests in
run-pass
.)