Merge pull request #2467 from topecongiro/issue-2466

Skip formatting macro_rules! that are not using {}
This commit is contained in:
Nick Cameron 2018-02-19 18:37:59 +13:00 committed by GitHub
commit 377bb5c97f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 0 deletions

View File

@ -294,6 +294,9 @@ pub fn rewrite_macro_def(
span: Span,
) -> Option<String> {
let snippet = Some(remove_trailing_white_spaces(context.snippet(span)));
if snippet.as_ref().map_or(true, |s| s.ends_with(";")) {
return snippet;
}
let mut parser = MacroParser::new(def.stream().into_trees());
let parsed_def = match parser.parse() {

View File

@ -68,3 +68,12 @@ macro_rules! m {
$line3_xxxxxxxxxxxxxxxxx: expr,
) => {};
}
// #2466
// Skip formatting `macro_rules!` that are not using `{}`.
macro_rules! m (
() => ()
);
macro_rules! m [
() => ()
];

View File

@ -59,3 +59,12 @@ macro_rules! m {
$line3_xxxxxxxxxxxxxxxxx: expr,
) => {};
}
// #2466
// Skip formatting `macro_rules!` that are not using `{}`.
macro_rules! m (
() => ()
);
macro_rules! m [
() => ()
];