From d8723aaa8ca8c827b1bbaf1e73923404169b9cfc Mon Sep 17 00:00:00 2001 From: Alan Du Date: Thu, 22 Mar 2018 00:01:09 -0400 Subject: [PATCH 1/2] Fix build --- src/matches.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/matches.rs b/src/matches.rs index 83ff70ea196..42f46608b52 100644 --- a/src/matches.rs +++ b/src/matches.rs @@ -13,8 +13,8 @@ use std::iter::repeat; use config::lists::*; -use syntax::{ast, ptr}; use syntax::codemap::{BytePos, Span}; +use syntax::{ast, ptr}; use codemap::SpanUtils; use comment::combine_strs_with_missing_comments; From d402cd20a8be72ce0eaad08f10d44360aae3506a Mon Sep 17 00:00:00 2001 From: Alan Du Date: Thu, 22 Mar 2018 00:57:22 -0400 Subject: [PATCH 2/2] Close #2551 --- src/expr.rs | 2 +- tests/target/issue-2551.rs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 tests/target/issue-2551.rs diff --git a/src/expr.rs b/src/expr.rs index a1fe1153e55..9aafd71dd22 100644 --- a/src/expr.rs +++ b/src/expr.rs @@ -1547,7 +1547,7 @@ pub fn span_ends_with_comma(context: &RewriteContext, span: Span) -> bool { for (kind, c) in CharClasses::new(context.snippet(span).chars()) { match c { _ if kind.is_comment() || c.is_whitespace() => continue, - ')' | '}' => result = result && prev_char != c, + ')' | '}' => result = result && prev_char != ')' && prev_char != '}', ',' => result = true, _ => result = false, } diff --git a/tests/target/issue-2551.rs b/tests/target/issue-2551.rs new file mode 100644 index 00000000000..d7b0d625b9e --- /dev/null +++ b/tests/target/issue-2551.rs @@ -0,0 +1,3 @@ +mcro!(func(A { + a: 12345667800111111111111, +}));