Skip to content

Automatic grouping of imports #951

Open
Open

Description

@KoHcoJlb

While working on my previous PR I noticed that there's no rustfmt configuration regarding import grouping. (Or maybe there's another tool that I've missed?)

So I want to ask if it may be possible to adopt following rustfmt settings into rama:

group_imports = "StdExternalCrate"
imports_granularity = "Crate"

In my PR I ended up reformatting key files with these settings to keep convenience of automatic import formatting and in the others I was editing them by hand to avoid unnecessary diffs, which was quite a chore.
Maybe I'm just lazy but still it's nice to offload such routine work to a tool 😄

I'm not advocating here for this specific style, but for a way to do it automatically/deterministically.

Activity

  1. GlenDC commented on Jun 2, 2026

    @GlenDC
    Member

    @soundofspace can you follow-up with @KoHcoJlb on this one. I have no strong opinion on it, but I seem to recall that you had a similar request not so long ago. I am fine with it as long as it doesn't make the life of new contributors harder for the little benefit it gives and as long as it is consistent, is auto fixed by running cargo fmt --workspace and fixes all import grouping at once I am ok with it... As I seem to recall it didn't go all the way? Perhaps these rules do? No clue.

  2. added
    easyAn easy issue to pick up for anyone.
    mentor availableA mentor is available to help you through the issue.
    on Jun 2, 2026
  3. added theissue type on Jun 2, 2026
  4. soundofspace commented on Jun 2, 2026

    @soundofspace
    Collaborator

    @KoHcoJlb dont think any of these are on stable yet? @GlenDC I guess we ruled out nightly for formatting or could we consider that?

  5. GlenDC commented on Jun 2, 2026

    @GlenDC
    Member

    Ah is that still nightly only? can you confirm? If so than yes this is ruled out and I will make it a blocker so someone can follow up once it is stable.

  6. soundofspace commented on Jun 2, 2026

    @soundofspace
    Collaborator

    imports_granularity

    Controls how imports are structured in use statements. Imports will be merged or split to the configured level of granularity.

    Similar to other import related configuration options, this option operates within the bounds of user-defined groups of imports. See group_imports for more information on import groups.

    Note that rustfmt will not modify the granularity of imports containing comments if doing so could potentially lose or misplace said comments.

    Default value: Preserve
    Possible values: Preserve, Crate, Module, Item, One
    Stable: No (tracking issue: #4991)

  7. added
    low prioLow priority item.
    blockedTasks which are blocked on other work.
    and removed
    mentor availableA mentor is available to help you through the issue.
    on Jun 2, 2026
  8. GlenDC commented on Jun 2, 2026

    @GlenDC
    Member

    Ok that seals it.

    @KoHcoJlb gonna close this until tracking issues are resolved on Rust's side.

  9. KoHcoJlb commented on Jun 2, 2026

    @KoHcoJlb
    ContributorAuthor

    Sure, I understand @GlenDC.
    Just want to clarify, is it a final ruling or is there some compromise that may be done?
    Seems to me that rustfmt is moving rather slowly and these features can remain unstable for some time still.

  10. GlenDC commented on Jun 2, 2026

    @GlenDC
    Member

    no there is no compromise that can be done on this. I do not want to start getting into Go/Js land where people need to run custom tooling (I consider nightly custom) to run/contribute to rama. Especially for something like this.

    Often things move slowly because no one cares enough to push it. As such do feel free to help get it pushed through and have it land in stable soon. They might not have anyone right now that cares enough to do so...

  11. added
    CICI, build tooling, lints, releases and test infrastructure
    on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

CICI, build tooling, lints, releases and test infrastructureblockedTasks which are blocked on other work.easyAn easy issue to pick up for anyone.low prioLow priority item.needs input

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions