-
Notifications
You must be signed in to change notification settings - Fork 928
imports_granularity = "Module"
with path contains self
#4716
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use crate::lexer; | ||
use crate::lexer::tokens::TokenData; | ||
use crate::lexer::{tokens::TokenData}; | ||
use crate::lexer::self; | ||
use crate::lexer::{self}; | ||
use crate::lexer::{self, tokens::TokenData}; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,8 @@ | ||||||
// rustfmt-imports_granularity: Item | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is wrong, although it kinda turned out well that you did this as it highlights a lack of dedupe we have with the
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops! Fixed. (Probably was a last minute change as I did most of the tests by setting the configuration in the .toml file) Note the test file changes, as with |
||||||
|
||||||
use crate::lexer; | ||||||
use crate::lexer::tokens::TokenData; | ||||||
use crate::lexer::{tokens::TokenData}; | ||||||
use crate::lexer::self; | ||||||
use crate::lexer::{self}; | ||||||
use crate::lexer::{self, tokens::TokenData}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use crate::lexer; | ||
use crate::lexer; | ||
use crate::lexer::tokens::TokenData; | ||
use crate::lexer::tokens::TokenData; | ||
use crate::lexer::{self}; | ||
use crate::lexer::{self, tokens::TokenData}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// rustfmt-imports_granularity: Item | ||
|
||
use crate::lexer; | ||
use crate::lexer; | ||
use crate::lexer::tokens::TokenData; | ||
use crate::lexer::tokens::TokenData; | ||
use crate::lexer::tokens::TokenData; | ||
use crate::lexer::{self}; | ||
use crate::lexer::{self}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any ideas why this isn't needed for the
Crate
variant?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand, the following code transforms ahead
foo::self
tofoo
:rustfmt/src/formatting/imports.rs
Lines 474 to 477 in 0e90855
Therefore, the only reason
foo::self
can be present in the code you asked about, is thatflatten()
createdfoo::self
fromfoo::{self, bar}
, in addition to creatingfoo::bar
. ForSharedPrefix::Module
these too imports will remain separate, so{}
should be added toself
. However forSharedPrefix::Crate
they will be merged again. This is because howshare_prefix()
identify shared prefix:rustfmt/src/formatting/imports.rs
Lines 570 to 573 in 0e90855
When checking this I found two examples of imports formatting which I am not sure are correct. The first is when using
imports_granularity = "Crate"
:is formatted as:
Is that o.k. or it should have been
use foo::{self}
?The second possible formatting issue is when using
imports_granularity = "Module"
:is formatted as:
Is this o.k.?