Merge pull request #2019 from topecongiro/issue-2018

Break after '=' if a single line rhs exceeds max width
This commit is contained in:
Nick Cameron 2017-10-05 17:30:45 +08:00 committed by GitHub
commit 61043e64e0
6 changed files with 17 additions and 5 deletions

View File

@ -2882,7 +2882,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)
@ -2895,7 +2895,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.

View File

@ -25,3 +25,6 @@ fn break_meee() {
};
}
}
// #2018
pub const EXPLAIN_UNSIZED_TUPLE_COERCION: &'static str = "Unsized tuple coercion is not stable enough for use and is subject to change";

View File

@ -30,3 +30,7 @@ fn break_meee() {
};
}
}
// #2018
pub const EXPLAIN_UNSIZED_TUPLE_COERCION: &'static str =
"Unsized tuple coercion is not stable enough for use and is subject to change";

View File

@ -5,5 +5,6 @@
// Force format strings
fn main() {
let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
let lorem =
"ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
}

View File

@ -4,5 +4,6 @@
// Force format strings
fn main() {
let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
let lorem =
"ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
}

View File

@ -19,7 +19,8 @@ fn main() {
fn foo(a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32) {
}
let str = "AAAAAAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAa";
let str =
"AAAAAAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAa";
if let (
some_very_large,