mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-23 04:14:28 +00:00
address reviewer comments
This commit is contained in:
parent
7a76e5b1b4
commit
229a55248b
@ -419,7 +419,8 @@ where
|
||||
if first_line_width(&formatted_comment)
|
||||
+ last_line_width(&result)
|
||||
+ comment_alignment
|
||||
+ 1 > formatting.config.max_width()
|
||||
+ 1
|
||||
> formatting.config.max_width()
|
||||
{
|
||||
item_max_width = None;
|
||||
formatted_comment = rewrite_post_comment(&mut item_max_width)?;
|
||||
|
15
src/pairs.rs
15
src/pairs.rs
@ -69,10 +69,7 @@ fn rewrite_pairs_one_line<T: Rewrite>(
|
||||
let mut result = String::new();
|
||||
let base_shape = shape.block();
|
||||
|
||||
for (e, s) in list.list[..list.list.len()]
|
||||
.iter()
|
||||
.zip(list.separators.iter())
|
||||
{
|
||||
for (e, s) in list.list.iter().zip(list.separators.iter()) {
|
||||
let cur_shape = base_shape.offset_left(last_line_width(&result))?;
|
||||
let rewrite = e.rewrite(context, cur_shape)?;
|
||||
|
||||
@ -137,7 +134,15 @@ fn rewrite_pairs_multiline<T: Rewrite>(
|
||||
result.push_str(&rewrite);
|
||||
|
||||
for (e, s) in list.list[1..].iter().zip(list.separators.iter()) {
|
||||
if trimmed_last_line_width(&result) <= context.config.tab_spaces() {
|
||||
// The following test checks if we should keep two subexprs on the same
|
||||
// line. We do this if not doing so would create an orphan and there is
|
||||
// enough space to do so.
|
||||
let offset = if result.contains('\n') {
|
||||
0
|
||||
} else {
|
||||
shape.used_width()
|
||||
};
|
||||
if last_line_width(&result) + offset <= nested_shape.used_width() {
|
||||
// We must snuggle the next line onto the previous line to avoid an orphan.
|
||||
if let Some(line_shape) =
|
||||
shape.offset_left(s.len() + 2 + trimmed_last_line_width(&result))
|
||||
|
@ -22,7 +22,8 @@ fn foo() -> bool {
|
||||
trivial_value,
|
||||
);
|
||||
(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ a + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ a
|
||||
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
+ aaaaa);
|
||||
|
||||
{
|
||||
@ -514,5 +515,6 @@ fn issue_2802() {
|
||||
* a_very_specific_length(specific_length_arg)
|
||||
* very_specific_length(Foo {
|
||||
a: some_much_much_longer_value,
|
||||
}) * some_value
|
||||
})
|
||||
* some_value
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user