Skip to content

inconsistent imports sorting when merging imports #6830

@antonilol

Description

@antonilol

Summary

I had this code:

use super::Enum;
use super::Struct;
use super::module::Trait;

Then I merged the imports on the first two lines into this:

use super::{Enum, Struct};
use super::module::Trait;

rustfmt then swapped the lines:

use super::module::Trait;
use super::{Enum, Struct};

Expected behavior

I expected to see this happen: imports of items from super stay at the top

Actual behavior

Instead, this happened: imports from super::module get sorted above items from super

Configuration

rustfmt cli options used (if applicable):

$ rustfmt main.rs --edition 2024

rustfmt configuration file (e.g. rustfmt.toml, if applicable): n/a

Reproduction Steps

See summary

Meta

rustfmt --version:

rustfmt 1.8.0-stable (4a4ef493e3 2026-03-02)

It can be more cleary seen with this code:

use super::CONSTANT;
use super::module::Trait;
use super::{Enum, Struct};

The merged imports are put below use super::module ..., normal imports like use super::CONSTANT here is correctly put at the top.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICEF-impacts-stable-default-formatExpected formatting impact: affects stable default format configuration (caution)F-impacts-stable-formatted-codeExpected formatting impact: affects stable formatted code (caution)F-impacts-stable-optionsExpected formatting impact: impacts stable options (caution)I-unexpected-motionIssue: unexpected motion of code or commentsS-has-mcveStatus: a Minimal Complete and Verifiable Example has been found for this issueSO-reorder_importsStable option: reorder_imports

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions