Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't merge crates when imports_granularity="Module" #6192

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

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
3 participants