Skip to content

bug: imports_granularity = "One" deletes aliases #6027

Open
@sivizius

Description

@sivizius

I would like to open issue #5131 again with:

Modified https://github.com/rust-lang/rustfmt/blob/master/tests/source/5131_one.rs:

// rustfmt-imports_granularity: One

pub use foo::x;
pub use foo::x as x2;
pub use foo::y;
use bar::a;
use bar::b;
use bar::b::f;
use bar::b::f as f2;
use bar::b::g;
use bar::c;
use bar::d::e;
use bar::d::e as e2;
use qux::h;
use qux::i;
use qux::i as j; // added this alias

And modified https://github.com/rust-lang/rustfmt/blob/master/tests/target/5131_one.rs:

// rustfmt-imports_granularity: One

pub use foo::{x, x as x2, y};
use {
    bar::{
        a,
        b::{self, f, g},
        c,
        d::{e, e as e2},
    },
    qux::{h, i, i as j}, // expected, but fails
};

I tested this with rev 6356fca675bd756d71f5c123cd053d17b16c573e. I assume, this (prefix == 0 && a.equal_except_alias(b)) || a == b needs some adjustment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-imports`use` syntaxbugPanic, non-idempotency, invalid code, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions