Merge pull request #2019 from topecongiro/issue-2018
Break after '=' if a single line rhs exceeds max width
This commit is contained in:
commit
61043e64e0
@ -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.
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
|
@ -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";
|
||||
}
|
||||
|
@ -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";
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user