Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,10 @@ fn dolor() -> usize {}
fn adipiscing() -> usize {}
```

## `imported_names_layout`

XXX TBD.

## `reorder_imported_names`

Reorder lists of names in import statements alphabetically
Expand Down
2 changes: 2 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,8 @@ create_config! {
reorder_imports_in_group: bool, false, "Reorder import statements in group";
reorder_imported_names: bool, false,
"Reorder lists of names in import statements alphabetically";
imported_names_layout: ListTactic, ListTactic::Mixed,
"Layout of lists of names in import statements";
single_line_if_else_max_width: usize, 50, "Maximum line length for single line if-else \
expressions. A value of zero means always break \
if-else expressions.";
Expand Down
2 changes: 1 addition & 1 deletion src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ pub fn rewrite_use_list(

let tactic = definitive_tactic(
&items[first_index..],
::lists::ListTactic::Mixed,
context.config.imported_names_layout(),
remaining_width,
);

Expand Down
6 changes: 6 additions & 0 deletions tests/source/configs-imported_names_layout-default.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Default rustfmt-imported_names_layout
// Layout of imported names

use super::{foo, foooooo, foooooooooo, foooooooooooooo};

use super::{bar, baaaaar, baaaaaaaaar, baaaaaaaaaaaaar, baaaaaaaaaaaaaaaaar, baaaaaaaaaaaaaaaaaaaaar, baaaaaaaaaaaaaaaaaaaaaaaaar};
6 changes: 6 additions & 0 deletions tests/source/configs-imported_names_layout-horizontal.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// rustfmt-imported_names_layout: Horizontal
// Layout of imported names

use super::{foo, foooooo, foooooooooo, foooooooooooooo};
// Horizontal mode should not exceed length of 100
use super::{bar, baaaaar, baaaaaaaaar, baaaaaaaaaaaaar, baaaaaaaaaaaaaaaaar, baaaaaaaaaaaaaaaaaaar};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// rustfmt-imported_names_layout: HorizontalVertical
// Layout of imported names

use super::{foo, foooooo, foooooooooo, foooooooooooooo};

use super::{bar, baaaaar, baaaaaaaaar, baaaaaaaaaaaaar, baaaaaaaaaaaaaaaaar, baaaaaaaaaaaaaaaaaaaaar, baaaaaaaaaaaaaaaaaaaaaaaaar};
6 changes: 6 additions & 0 deletions tests/source/configs-imported_names_layout-mixed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// rustfmt-imported_names_layout: Mixed
// Layout of imported names

use super::{foo, foooooo, foooooooooo, foooooooooooooo};

use super::{bar, baaaaar, baaaaaaaaar, baaaaaaaaaaaaar, baaaaaaaaaaaaaaaaar, baaaaaaaaaaaaaaaaaaaaar, baaaaaaaaaaaaaaaaaaaaaaaaar};
6 changes: 6 additions & 0 deletions tests/source/configs-imported_names_layout-vertical.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// rustfmt-imported_names_layout: Vertical
// Layout of imported names

use super::{foo, foooooo, foooooooooo, foooooooooooooo};

use super::{bar, baaaaar, baaaaaaaaar, baaaaaaaaaaaaar, baaaaaaaaaaaaaaaaar, baaaaaaaaaaaaaaaaaaaaar, baaaaaaaaaaaaaaaaaaaaaaaaar};
7 changes: 7 additions & 0 deletions tests/target/configs-imported_names_layout-default.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Default rustfmt-imported_names_layout
// Layout of imported names

use super::{foo, foooooo, foooooooooo, foooooooooooooo};

use super::{bar, baaaaar, baaaaaaaaar, baaaaaaaaaaaaar, baaaaaaaaaaaaaaaaar,
baaaaaaaaaaaaaaaaaaaaar, baaaaaaaaaaaaaaaaaaaaaaaaar};
6 changes: 6 additions & 0 deletions tests/target/configs-imported_names_layout-horizontal.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// rustfmt-imported_names_layout: Horizontal
// Layout of imported names

use super::{foo, foooooo, foooooooooo, foooooooooooooo};
// Horizontal mode should not exceed length of 100
use super::{bar, baaaaar, baaaaaaaaar, baaaaaaaaaaaaar, baaaaaaaaaaaaaaaaar, baaaaaaaaaaaaaaaaaaar};
12 changes: 12 additions & 0 deletions tests/target/configs-imported_names_layout-horizontal_vertical.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// rustfmt-imported_names_layout: HorizontalVertical
// Layout of imported names

use super::{foo, foooooo, foooooooooo, foooooooooooooo};

use super::{bar,
baaaaar,
baaaaaaaaar,
baaaaaaaaaaaaar,
baaaaaaaaaaaaaaaaar,
baaaaaaaaaaaaaaaaaaaaar,
baaaaaaaaaaaaaaaaaaaaaaaaar};
7 changes: 7 additions & 0 deletions tests/target/configs-imported_names_layout-mixed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// rustfmt-imported_names_layout: Mixed
// Layout of imported names

use super::{foo, foooooo, foooooooooo, foooooooooooooo};

use super::{bar, baaaaar, baaaaaaaaar, baaaaaaaaaaaaar, baaaaaaaaaaaaaaaaar,
baaaaaaaaaaaaaaaaaaaaar, baaaaaaaaaaaaaaaaaaaaaaaaar};
15 changes: 15 additions & 0 deletions tests/target/configs-imported_names_layout-vertical.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// rustfmt-imported_names_layout: Vertical
// Layout of imported names

use super::{foo,
foooooo,
foooooooooo,
foooooooooooooo};

use super::{bar,
baaaaar,
baaaaaaaaar,
baaaaaaaaaaaaar,
baaaaaaaaaaaaaaaaar,
baaaaaaaaaaaaaaaaaaaaar,
baaaaaaaaaaaaaaaaaaaaaaaaar};