Skip to content

reorder-imports should have option to preserve import groups #1205

Closed
@fuine

Description

@fuine

Currently (version 0.6.2) rustfmt will change this:

use a;
use x;
use b;

use std::io;

to

use a;
use b;

use std::io;
use x;

By group i mean consecutive lines of imports. Groups are divided by empty newlines. I write my imports such that imports from the crate i'm working on are in one group and imports from other crates/std get put in different group. Rustfmt mixes them, which defeats the purpose of grouping. On the other hand i would like to have both groups sorted within themselves. Is there a way to achieve that with current version of rustfmt and if not could this be considered?
For the example above i'd like rustfmt to change it like so:

use a;
use b;
use x;

use std::io;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions