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

fix: imports_granularity module with path containing self #5253

Conversation

tommilligan
Copy link
Contributor

Closes #4681

(unintentionally) ports #4716 from rustfmt-2.0.0-rc.2 to master, with some additional refactoring.

It looks like this issue was already fixed, but was then lost in the rustfmt-2.0.0-rc.2 branch on this commit: 0e90855

I implemented this separately but came up with a satisfyingly similar implementation - I've read the review comments on the original PR, so I don't think there should be much to add, but do let me know if anything needs changing!

@tommilligan
Copy link
Contributor Author

Moves towards stabilising imports_granularity #4991

@calebcartwright
Copy link
Member

Thanks so much! Will try to get to this shortly

Copy link
Member

@calebcartwright calebcartwright left a comment

Choose a reason for hiding this comment

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

Thank you! LGTM overall, with one inline question for you

src/imports.rs Outdated
if merge_by == SharedPrefix::Module {
flattened = flattened.nest_trailing_self();
}
result.push(flattened.nest_trailing_self());
Copy link
Member

Choose a reason for hiding this comment

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

Is it necessary to make this nest call in the non-module case, and twice for the module case?

If so could you add or point to a test case that demonstrates why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, that's definitely unnecessary, good spot. I added the conditional merge_by check later, I just forgot to remove the unconditional case.

Squashed and updated, ready for review again.

@calebcartwright
Copy link
Member

Excellent, thank you!

@calebcartwright calebcartwright merged commit b4de150 into rust-lang:master Mar 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

imports_granularity = "Module" causes compile error when path contains self
2 participants