Avoid line break when rhs of assignment is an invalid macro

This commit is contained in:
Seiichi Uchida 2017-06-18 02:35:18 +09:00 committed by topecongiro
parent be18e7af90
commit 6afb0e856c
3 changed files with 13 additions and 11 deletions

View file

@ -2719,17 +2719,7 @@ pub fn rewrite_assign_rhs<S: Into<String>>(
};
// 1 = space between operator and rhs.
let orig_shape = try_opt!(shape.offset_left(last_line_width + 1));
let rhs = match ex.node {
ast::ExprKind::Mac(ref mac) => {
match rewrite_macro(mac, None, context, orig_shape, MacroPosition::Expression) {
None if !context.snippet(ex.span).contains("\n") => {
context.snippet(ex.span).rewrite(context, orig_shape)
}
rhs @ _ => rhs,
}
}
_ => ex.rewrite(context, orig_shape),
};
let rhs = ex.rewrite(context, orig_shape);
fn count_line_breaks(src: &str) -> usize {
src.chars().filter(|&x| x == '\n').count()

View file

@ -79,6 +79,12 @@ fn main() {
not function like
);
// #1712
let image = gray_image!(
00, 01, 02;
10, 11, 12;
20, 21, 22);
// #1577
let json = json!({
"foo": "bar",

View file

@ -110,6 +110,12 @@ fn main() {
not function like
);
// #1712
let image = gray_image!(
00, 01, 02;
10, 11, 12;
20, 21, 22);
// #1577
let json = json!({
"foo": "bar",