-
Notifications
You must be signed in to change notification settings - Fork 898
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.x: Rename merge_imports
to imports_granularity
and add a Module
option.
#4634
Merged
calebcartwright
merged 3 commits into
rust-lang:rustfmt-1.4.33
from
goffrie:merge-imports-module-1.x
Jan 17, 2021
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1615,13 +1615,56 @@ pub enum Foo {} | |||||
pub enum Foo {} | ||||||
``` | ||||||
|
||||||
## `imports_granularity` | ||||||
|
||||||
Merge together related imports based on their paths. | ||||||
|
||||||
- **Default value**: `Preserve` | ||||||
- **Possible values**: `Preserve`, `Crate`, `Module` | ||||||
- **Stable**: No | ||||||
|
||||||
#### `Preserve` (default): | ||||||
|
||||||
Do not perform any merging and preserve the original structure written by the developer. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same theme here, maybe something more like:
Suggested change
|
||||||
|
||||||
```rust | ||||||
use foo::b; | ||||||
use foo::b::{f, g}; | ||||||
use foo::{a, c, d::e}; | ||||||
use qux::{h, i}; | ||||||
``` | ||||||
|
||||||
#### `Crate`: | ||||||
|
||||||
Merge imports from the same crate into a single `use` statement. Conversely, imports from different crates are split into separate statements. | ||||||
|
||||||
```rust | ||||||
use foo::{ | ||||||
a, b, | ||||||
b::{f, g}, | ||||||
c, | ||||||
d::e, | ||||||
}; | ||||||
use qux::{h, i}; | ||||||
``` | ||||||
|
||||||
#### `Module`: | ||||||
|
||||||
Merge imports from the same module into a single `use` statement. Conversely, imports from different modules are split into separate statements. | ||||||
|
||||||
```rust | ||||||
use foo::b::{f, g}; | ||||||
use foo::d::e; | ||||||
use foo::{a, b, c}; | ||||||
use qux::{h, i}; | ||||||
``` | ||||||
|
||||||
## `merge_imports` | ||||||
|
||||||
Merge multiple imports into a single nested import. | ||||||
This option is deprecated. Use `imports_granularity = "Crate"` instead. | ||||||
|
||||||
- **Default value**: `false` | ||||||
- **Possible values**: `true`, `false` | ||||||
- **Stable**: No (tracking issue: #3362) | ||||||
|
||||||
#### `false` (default): | ||||||
|
||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, think we missed updating this text in the other PR. Should tweak this to better reflect that the option isn't strictly a merge