Merge pull request #2599 from topecongiro/issue-2596

Use multiple lines for imports list which exceeds max width
This commit is contained in:
Nick Cameron 2018-04-06 11:12:53 +12:00 committed by GitHub
commit 4b2160e1b2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 6 deletions

View file

@ -497,7 +497,8 @@ fn rewrite_nested_use_tree(
let list_str = write_list(&list_items, &fmt)?;
let result = if list_str.contains('\n') && context.config.imports_indent() == IndentStyle::Block
let result = if (list_str.contains('\n') || list_str.len() > remaining_width)
&& context.config.imports_indent() == IndentStyle::Block
{
format!(
"{{\n{}{}\n{}}}",

View file

@ -172,11 +172,10 @@ where
let limit = match tactic {
_ if pre_line_comments => return DefinitiveListTactic::Vertical,
ListTactic::Mixed => return DefinitiveListTactic::Mixed,
ListTactic::Horizontal => return DefinitiveListTactic::Horizontal,
ListTactic::Vertical => return DefinitiveListTactic::Vertical,
ListTactic::LimitedHorizontalVertical(limit) => ::std::cmp::min(width, limit),
ListTactic::HorizontalVertical => width,
ListTactic::Mixed | ListTactic::HorizontalVertical => width,
};
let (sep_count, total_width) = calculate_width(items.clone());
@ -188,7 +187,10 @@ where
{
DefinitiveListTactic::Horizontal
} else {
DefinitiveListTactic::Vertical
match tactic {
ListTactic::Mixed => DefinitiveListTactic::Mixed,
_ => DefinitiveListTactic::Vertical,
}
}
}
@ -278,8 +280,7 @@ where
if last && formatting.ends_with_newline {
match formatting.trailing_separator {
SeparatorTactic::Always => separate = true,
SeparatorTactic::Vertical if result.contains('\n') => separate = true,
SeparatorTactic::Always | SeparatorTactic::Vertical => separate = true,
_ => (),
}
}

View file

@ -0,0 +1,4 @@
// rustfmt-imports_indent: Block
// #2569
use apns2::request::notification::{Notificatio, NotificationBuilder, Priority, SilentNotificationBuilder};

View file

@ -0,0 +1,6 @@
// rustfmt-imports_indent: Block
// #2569
use apns2::request::notification::{
Notificatio, NotificationBuilder, Priority, SilentNotificationBuilder,
};