Skip to content

Do not merge top-level modules with imports_granularity Module#6784

Merged
ytmimi merged 5 commits intorust-lang:mainfrom
mwlon:fix-imports-granularity-top-level-modules
Feb 2, 2026
Merged

Do not merge top-level modules with imports_granularity Module#6784
ytmimi merged 5 commits intorust-lang:mainfrom
mwlon:fix-imports-granularity-top-level-modules

Conversation

@mwlon
Copy link
Contributor

@mwlon mwlon commented Jan 30, 2026

Fixes #6191 .

@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Jan 30, 2026
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the example from #6191 as a test case:

Specifically can you show that the following:

use {library1, library2 as lib2, library3};

gets rewritten as follows since we're not merging top level imports:

use library1;
use library2 as lib2;
use library3;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what my addition to the test files does. But ok, I can make it match verbatim.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your test case shows that they're not getting merged, which I think is good, but what I want to demonstrate is that top level modules that are already merged will get unmerged.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not suggesting you remove what you've already got, just add the example from the original issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah makes sense, added it now.

Comment on lines 4 to 15
use a::{f, g::{h, i}};
use a::{j::{self, k::{self, l}, m}, n::{o::p, q}};
use a::{
f,
g::{h, i},
};
use a::{
j::{
self,
k::{self, l},
m,
},
n::{o::p, q},
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, what's going on here? Why did all this change now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think any of these changes are necessary. Let's revert all changes to tests/source/imports/imports_granularity_module.rs that aren't related to adding use {library1, library2 as lib2, library3};.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh whoa, that was not intended. It must have been my vscode messing up the formatting. Will fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed now.

@ytmimi
Copy link
Contributor

ytmimi commented Jan 31, 2026

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: awaiting review from the assignee but also interested parties. labels Jan 31, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 31, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@ytmimi
Copy link
Contributor

ytmimi commented Jan 31, 2026

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author. labels Jan 31, 2026
@ytmimi ytmimi self-assigned this Jan 31, 2026
mwlon added 5 commits February 2, 2026 09:37
Signed-off-by: mwlon <m.w.loncaric@gmail.com>
Signed-off-by: mwlon <m.w.loncaric@gmail.com>
Signed-off-by: mwlon <m.w.loncaric@gmail.com>
Signed-off-by: mwlon <m.w.loncaric@gmail.com>
@ytmimi ytmimi force-pushed the fix-imports-granularity-top-level-modules branch from cf4b73d to f89b67c Compare February 2, 2026 14:37
@rustbot
Copy link
Collaborator

rustbot commented Feb 2, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@ytmimi
Copy link
Contributor

ytmimi commented Feb 2, 2026

Thanks for fixing the tests

@ytmimi ytmimi merged commit 8eb143f into rust-lang:main Feb 2, 2026
26 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Feb 2, 2026
@ytmimi ytmimi added the release-notes Needs an associated changelog entry label Feb 2, 2026
@mwlon mwlon deleted the fix-imports-granularity-top-level-modules branch February 2, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes Needs an associated changelog entry

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