mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-07 09:13:07 +03:00
Break after '=' if a single line rhs exceeds max width
This commit is contained in:
+4
-2
@@ -2895,7 +2895,7 @@ pub fn rewrite_assign_rhs<S: Into<String>>(
|
||||
let rhs = try_opt!(choose_rhs(
|
||||
context,
|
||||
ex,
|
||||
shape,
|
||||
orig_shape,
|
||||
ex.rewrite(context, orig_shape)
|
||||
));
|
||||
Some(lhs + &rhs)
|
||||
@@ -2908,7 +2908,9 @@ fn choose_rhs(
|
||||
orig_rhs: Option<String>,
|
||||
) -> Option<String> {
|
||||
match orig_rhs {
|
||||
Some(ref new_str) if !new_str.contains('\n') => Some(format!(" {}", new_str)),
|
||||
Some(ref new_str) if !new_str.contains('\n') && new_str.len() <= shape.width => {
|
||||
Some(format!(" {}", new_str))
|
||||
}
|
||||
_ => {
|
||||
// Expression did not fit on the same line as the identifier.
|
||||
// Try splitting the line and see if that works better.
|
||||
|
||||
Reference in New Issue
Block a user