Skip to content

Use unstable rustfmt features to ensure import style #5065

Closed

Description

@rami3l

In rustls we enforce format style in CI by using nightly clippy:

https://github.com/rustls/rustls/blob/main/.github/workflows/build.yml#L392

Maybe that could make sense for rustup?

Originally posted by @djc in #5064 (comment)

Activity

  1. self-assigned this
    on Sep 8, 2026
  2. rami3l commented on Sep 9, 2026

    @rami3l
    MemberAuthor
    group_imports = "StdExternalCrate"
    imports_granularity = "Crate"

    Yes, these have been very stable IME.

    (I don't think you need unstable_features if you run nightly with these?)

    Originally posted by @djc in #5064 (comment)

    According to the docs:

    To enable unstable options, set unstable_features = true in rustfmt.toml or pass --unstable-features to rustfmt.

    So this looks like the semantics was about to change in rust-lang/rustfmt#4353 (comment) but the migration never landed.

    OTOH to facilitate use in IDEs so that we can never worry about reorganizing imports, I'm discovering the feasibility of adding a recommended rust-analyzer config that looks like so:

    rustfmt = { extraArgs = { "+nightly", "--config-path=.rustfmt.unstable.toml" } },
  3. rami3l commented on Sep 9, 2026

    @rami3l
    MemberAuthor

    OTOH to facilitate use in IDEs so that we can never worry about reorganizing imports, I'm discovering the feasibility of adding a recommended rust-analyzer config that looks like so:

    rustfmt = { extraArgs = { "+nightly", "--config-path=.rustfmt.unstable.toml" } },

    Interesting, I cannot use that yet because rust-analyzer is calling rustfmt at the source file's basedir so .rustfmt.unstable-toml will be "not found":

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions