mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-13 20:46:48 +00:00
Avoid line break when rhs of assignment is an invalid macro
This commit is contained in:
parent
be18e7af90
commit
6afb0e856c
12
src/expr.rs
12
src/expr.rs
@ -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()
|
||||
|
@ -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",
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user