Veto putting a chain with comment in a single line

This commit is contained in:
Seiichi Uchida 2018-08-05 14:34:34 +09:00
parent caefd218c9
commit 91c058a516

View file

@ -209,6 +209,13 @@ impl ChainItem {
}
}
fn is_comment(&self) -> bool {
match self.kind {
ChainItemKind::Comment => true,
_ => false,
}
}
fn rewrite_method_call(
method_name: ast::Ident,
types: &[ast::GenericArg],
@ -458,7 +465,9 @@ impl<'a> ChainFormatterShared<'a> {
}.saturating_sub(almost_total);
let all_in_one_line =
self.rewrites.iter().all(|s| !s.contains('\n')) && one_line_budget > 0;
!self.children.iter().any(ChainItem::is_comment)
&& self.rewrites.iter().all(|s| !s.contains('\n'))
&& one_line_budget > 0;
let last_shape = if all_in_one_line {
shape.sub_width(last.tries)?
} else if extendable {