rust-lang / rust-lang/rustfmt

More advanced `group_imports` with 4 groups and adaptable "std-like" crates

Open
#5,550 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-feature-request P-low
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

In code i write i have taken to group the import statements into 4 groups:

  1. "std-like" crates which include all the normal std crates (std, alloc, core) and large crates like tokio or frameworks like axum or bevy pretty much everything which fundamentaly controls how my code will look like.
  2. Other external crates
  3. Workspace internal crates
  4. Crate internal imports

I have thought about trying to implement this in rustfmt, but i don't know how doable this is.
I guess making crates in 1. optionally configurable shouldn't be that hard, but does rustfmt get any workspace information? Is it feasible to optionally implement retrieving workspace information for such a feature, or would this require some larger architectural/conceptual change?

Thanks in advance :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining rustfmt's existing import-grouping configuration and determine whether it has access to workspace information. Then assess how configurable "std-like" crates and four import groups would fit the formatter's architecture. Done means establishing whether the feature is feasible and defining its required configuration and workspace behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.