Auto-format imports using Module granularity#702
Merged
Xanewok merged 8 commits intoNomicFoundation:mainfrom Dec 13, 2023
Merged
Auto-format imports using Module granularity#702Xanewok merged 8 commits intoNomicFoundation:mainfrom
Module granularity#702Xanewok merged 8 commits intoNomicFoundation:mainfrom
Conversation
|
OmarTawfik
reviewed
Dec 11, 2023
OmarTawfik
approved these changes
Dec 13, 2023
Contributor
OmarTawfik
left a comment
There was a problem hiding this comment.
Left one suggestion about super::* imports, but not blocking.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #155
This is going to be a fun one 😆
I've pushed two preview commits: the first one imports using the
Crategranularity, the other one withModulegranularity.Disclaimer: I'm biased 😃 I've used this style since I started using Rust and it's also being used by vast majority of projects in the ecosystem that I've used or looked at; it's also used by the Rust compiler, Cargo and the tools like Rustfmt or Clippy.
Here's a summary of the possible options: rust-lang/rustfmt#3362.
Here is an RFC discussion about setting on a variant: rust-lang/style-team#140, I highly recommend reading it.
To give a brief summary, it seems that people stand behind two options:
Module- good trade-off between readability and concisenessItem- minimizes conflicts when many people edit the same files oftenTo bring back some of the arguments raised in favor of the
Moduleand explain some of my reasoning as well:Item) imports, which can often explode and take unreasonable amount of space (and we don't really benefit enough from minimized conflicts as we probably won't be a team of 50 or the like)...crate-style use import tree...greppability