Skip to content

Conversation

mnkhouri
Copy link

When merging imports using imports_granularity="Module", individual crate imports should get their own use statement on a new line.

// Before this commit:
use {library1, library2 as lib2, library3};

// After this commit:
use library1;
use library2 as lib2;
use library3;

Fixes: #6191

When merging imports using `imports_granularity="Module"`, individual
crate imports should get their own `use` statement on a new line.

```
// Before this commit:
use {library1, library2 as lib2, library3};

// After this commit:
use library1;
use library2 as lib2;
use library3;
```

Fixes: rust-lang#6191
@ytmimi
Copy link
Contributor

ytmimi commented Jul 6, 2024

I haven't really reviewed this, but I quickly tested out this branch on this input:

use library1;
use library1::one;
use library1::two;
use library2 as lib2;
use library3;

which produced this output:

use library1;
use library1::{one, two};
use library2 as lib2;
use library3;

It seems reasonable to me, but I'm wondering if it would be expected to produce the following instead:

use library1::{self, one, two};
use library2 as lib2;
use library3;

@mnkhouri
Copy link
Author

mnkhouri commented Jul 6, 2024

Thanks for trying it out!

but I'm wondering if it would be expected to produce the following instead

I personally would also prefer the second output rather than the first, but I think this is out of scope for this PR because I think aliasing module to module::self is a separate issue -- there's some discussion in #6028 (comment) which suggests that use library1 and use library1::{self} are semantically different, and that we shouldn't convert between the two forms

@zerny
Copy link

zerny commented Mar 10, 2025

Hi, hoping we could bump this.

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

Successfully merging this pull request may close these issues.

imports_granularity = "Module" merges top-level modules into a single use statement
4 participants