Skip to content
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

Conversation

goffrie
Copy link
Contributor

@goffrie goffrie commented Jan 10, 2021

Backport of #4600 to 1.x. I presume that a rustfmt-1.4.32 branch needs to be created, though.

…tion.

This renames the existing `true`/`false` options to `Crate`/`Never`, then adds a
new `Module` option which causes imports to be grouped together by their
originating module.
Copy link
Member

@calebcartwright calebcartwright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! Always nice to not have to cherry-pick these myself 😄 Couple suggested config text tweaks that I missed on the other PR, but otherwise good to go.

As an FYI, I changed the target release milestone as an unrelated bug has surfaced and I want to get a fix out for that bug with as few other changes as possible in case we need to expedite the release of the fix.

Shouldn't impact the overall timeline on getting this landed on nightly (can release this shortly after), but just wanted to explain the reasoning for the milestone change

@@ -1615,13 +1615,56 @@ pub enum Foo {}
pub enum Foo {}
```

## `imports_granularity`

Merge together related imports based on their paths.
Copy link
Member

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


#### `Preserve` (default):

Do not perform any merging and preserve the original structure written by the developer.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same theme here, maybe something more like:

Suggested change
Do not perform any merging and preserve the original structure written by the developer.
Do not change the granularity of any imports and preserve the original structure written by the developer.

@calebcartwright calebcartwright changed the base branch from rustfmt-1.4.31 to rustfmt-1.4.33 January 17, 2021 17:48
@calebcartwright calebcartwright merged commit 17bad2b into rust-lang:rustfmt-1.4.33 Jan 17, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jan 30, 2021
…anxiyn

update rustfmt to v1.4.34

Short summary: Various formatting fixes (several const generic related) and introduction of `imports_granularity` config option

Long summary copied from changelog:

#### Changed
- `merge_imports` configuration has been deprecated in favor of the new `imports_granularity` option. Any existing usage of `merge_imports` will be automatically mapped to the corresponding value on `imports_granularity` with a warning message printed to encourage users to update their config files.

#### Added
- New `imports_granularity` option has been added which succeeds `merge_imports`. This new option supports several additional variants which allow users to merge imports at different levels (crate or module), and even flatten imports to have a single use statement per item. ([PR rust-lang/rustfmt#4634](rust-lang/rustfmt#4634), [PR rust-lang/rustfmt#4639](rust-lang/rustfmt#4639))

See the section on the configuration site for more information
https://rust-lang.github.io/rustfmt/?version=v1.4.33&search=#imports_granularity

#### Fixed
- Fix erroneous removal of `const` keyword on const trait impl ([rust-lang/rustfmt#4084](rust-lang/rustfmt#4084))
- Fix incorrect span usage wit const generics in supertraits ([rust-lang/rustfmt#4204](rust-lang/rustfmt#4204))
- Use correct span for const generic params ([rust-lang/rustfmt#4263](rust-lang/rustfmt#4263))
- Correct span on const generics to include type bounds ([rust-lang/rustfmt#4310](rust-lang/rustfmt#4310))
- Idempotence issue on blocks containing only empty statements ([rust-lang/rustfmt#4627](rust-lang/rustfmt#4627) and [rust-lang#3868](rust-lang/rustfmt#3868))
- Fix issue with semicolon placement on required functions that have a trailing comment that ends in a line-style comment before the semicolon ([rust-lang/rustfmt#4646](rust-lang/rustfmt#4646))
- Avoid shared interned cfg_if symbol since rustfmt can re-initialize the rustc_ast globals on multiple inputs ([rust-lang/rustfmt#4656](rust-lang/rustfmt#4656))
- Don't insert trailing comma on (base-less) rest in struct literals within macros ([rust-lang/rustfmt#4675](rust-lang/rustfmt#4675))
NiklasEi added a commit to NiklasEi/bevy that referenced this pull request Feb 19, 2021
NiklasEi added a commit to NiklasEi/bevy that referenced this pull request Feb 19, 2021
cart pushed a commit to bevyengine/bevy that referenced this pull request Feb 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants