-
Notifications
You must be signed in to change notification settings - Fork 926
imports_granularity: implement One/Single variant #4669
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Labels
1x-backport:completed
a-imports
`use` syntax
feature-request
good first issue
Issues up for grabs, also good candidates for new rustfmt contributors
help wanted
Comments
I'm interested in this issue. Can I work on it? |
Absolutely! Let us know if you have any questions |
magurotuna
added a commit
to magurotuna/rustfmt
that referenced
this issue
Jan 31, 2021
This option merges all imports into a single `use` statement as long as they have the same visibility.
magurotuna
added a commit
to magurotuna/rustfmt
that referenced
this issue
Jan 31, 2021
This option merges all imports into a single `use` statement as long as they have the same visibility.
magurotuna
added a commit
to magurotuna/rustfmt
that referenced
this issue
Jan 31, 2021
This option merges all imports into a single `use` statement as long as they have the same visibility.
magurotuna
added a commit
to magurotuna/rustfmt
that referenced
this issue
Mar 20, 2021
This option merges all imports into a single `use` statement as long as they have the same visibility.
magurotuna
added a commit
to magurotuna/rustfmt
that referenced
this issue
Mar 20, 2021
This option merges all imports into a single `use` statement as long as they have the same visibility.
magurotuna
added a commit
to magurotuna/rustfmt
that referenced
this issue
Mar 24, 2021
This option merges all imports into a single `use` statement as long as they have the same visibility.
magurotuna
added a commit
to magurotuna/rustfmt
that referenced
this issue
Mar 24, 2021
This option merges all imports into a single `use` statement as long as they have the same visibility.
calebcartwright
pushed a commit
that referenced
this issue
Mar 25, 2021
irh
pushed a commit
to irh/rustfmt
that referenced
this issue
Aug 31, 2021
This option merges all imports into a single `use` statement as long as they have the same visibility.
calebcartwright
pushed a commit
that referenced
this issue
Aug 31, 2021
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
1x-backport:completed
a-imports
`use` syntax
feature-request
good first issue
Issues up for grabs, also good candidates for new rustfmt contributors
help wanted
Add a new variant and associated formatting to
imports_granularity
that reformats all imports into a single use statement. The variant name should beOne
orSingle
, withOne
being the leading contender (refer here for One and here for Single for respective community votes/feedback)Background
imports_granularity
is a configuration option that allows users to control the granularity of their use declarations (https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#imports_granularity)By default rustfmt will not modify the granularity and will preserve the developers original structure, but the
imports_granularity
option provides several different variants that users can leverage to instruct rustfmt to reformat their use statements with a specific level of granularity.Several different styles/granularity levels have been identified (summarized here, and already implemented, with the exception of the one/single granularity variant.
Implementation
There will be 3 high level tasks required here
For the configuration side:
For implementation, refer to relevant sections in
src/formatting/imports.rs
andsrc/formatting/reorder.rs
, some suggested starting points:rustfmt/src/formatting/imports.rs
Lines 872 to 875 in 79c3696
rustfmt/src/formatting/imports.rs
Lines 550 to 565 in 79c3696
rustfmt/src/formatting/reorder.rs
Lines 231 to 238 in 79c3696
For tests (more information on writing tests here):
Some unit tests for the other variants can be found here
https://github.com/rust-lang/rustfmt/blob/master/src/formatting/imports.rs#L1032-L1087
Additional files for the system/idempotence tests can be found under
tests/{src,target}/imports_granularity_{crate,item,module}.rs
for referenceThe text was updated successfully, but these errors were encountered: