-
Notifications
You must be signed in to change notification settings - Fork 888
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 issues with formatting imports with comments #5853
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use a::{item /* comment */}; | ||
use b::{ | ||
a, | ||
// comment | ||
item, | ||
}; | ||
use c::item /* comment */; | ||
use d::item; // really long comment (with `use` exactly 100 characters) ____________________________ | ||
|
||
use std::e::{/* it's a comment! */ bar /* and another */}; | ||
use std::f::{/* it's a comment! */ bar}; | ||
use std::g::{bar /* and another */}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
use std::{ | ||
fs, | ||
// (temporarily commented, we'll need this again in a second) io, | ||
}; | ||
|
||
use foo::{ | ||
self // this is important | ||
}; | ||
|
||
use foo :: bar | ||
; | ||
|
||
use foo::{bar}; | ||
|
||
use foo::{ | ||
bar | ||
// abc | ||
}; | ||
|
||
use foo::{ | ||
bar, | ||
// abc | ||
}; | ||
|
||
use foo::{ | ||
// 345 | ||
bar | ||
}; | ||
|
||
use foo::{ | ||
self | ||
// abc | ||
}; | ||
|
||
use foo::{ | ||
self, | ||
// abc | ||
}; | ||
|
||
use foo::{ | ||
// 345 | ||
self | ||
}; | ||
|
||
use foo::{ | ||
self // a | ||
, | ||
}; | ||
|
||
use foo::{ self /* a */ }; | ||
|
||
use foo::{ self /* a */, }; | ||
|
||
use foo::{ | ||
// abc | ||
abc::{ | ||
xyz | ||
// 123 | ||
} | ||
}; | ||
|
||
use foo::{ | ||
// abc | ||
bar, | ||
abc | ||
}; | ||
|
||
use foo::{ | ||
bar, | ||
// abc | ||
abc | ||
}; | ||
|
||
use foo::{ | ||
bar, | ||
abc | ||
// abc | ||
}; | ||
|
||
use foo::{ | ||
bar, | ||
abc, | ||
// abc | ||
}; | ||
|
||
use foo::{ | ||
self, | ||
// abc | ||
abc::{ | ||
xyz | ||
// 123 | ||
} | ||
}; | ||
|
||
use foo::{ | ||
self, | ||
// abc | ||
abc::{ | ||
// 123 | ||
xyz | ||
} | ||
}; | ||
|
||
use path::{self /*comment*/,}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// rustfmt-imports_layout: Horizontal | ||
|
||
use std::{ | ||
fs, | ||
// (temporarily commented, we'll need this again in a second) io, | ||
}; | ||
|
||
use foo::{ | ||
self // this is important | ||
}; | ||
|
||
use foo :: bar | ||
; | ||
|
||
use foo::{bar}; | ||
|
||
use foo::{ | ||
bar | ||
// abc | ||
}; | ||
|
||
use foo::{ | ||
bar, | ||
// abc | ||
}; | ||
|
||
use foo::{ | ||
// 345 | ||
bar | ||
}; | ||
|
||
use foo::{ | ||
self | ||
// abc | ||
}; | ||
|
||
use foo::{ | ||
self, | ||
// abc | ||
}; | ||
|
||
use foo::{ | ||
// 345 | ||
self | ||
}; | ||
|
||
use foo::{ | ||
self // a | ||
, | ||
}; | ||
|
||
use foo::{ self /* a */ }; | ||
|
||
use foo::{ self /* a */, }; | ||
|
||
use foo::{ | ||
// abc | ||
abc::{ | ||
xyz | ||
// 123 | ||
} | ||
}; | ||
|
||
use foo::{ | ||
// abc | ||
bar, | ||
abc | ||
}; | ||
|
||
use foo::{ | ||
bar, | ||
// abc | ||
abc | ||
}; | ||
|
||
use foo::{ | ||
bar, | ||
abc | ||
// abc | ||
}; | ||
|
||
use foo::{ | ||
bar, | ||
abc, | ||
// abc | ||
}; | ||
|
||
use foo::{ | ||
self, | ||
// abc | ||
abc::{ | ||
xyz | ||
// 123 | ||
} | ||
}; | ||
|
||
use foo::{ | ||
self, | ||
// abc | ||
abc::{ | ||
// 123 | ||
xyz | ||
} | ||
}; | ||
|
||
use path::{self /*comment*/,}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// rustfmt-imports_layout: HorizontalVertical | ||
|
||
use std::{ | ||
fs, | ||
// (temporarily commented, we'll need this again in a second) io, | ||
}; | ||
|
||
use foo::{ | ||
self // this is important | ||
}; | ||
|
||
use foo :: bar | ||
; | ||
|
||
use foo::{bar}; | ||
|
||
use foo::{ | ||
bar | ||
// abc | ||
}; | ||
|
||
use foo::{ | ||
bar, | ||
// abc | ||
}; | ||
|
||
use foo::{ | ||
// 345 | ||
bar | ||
}; | ||
|
||
use foo::{ | ||
self | ||
// abc | ||
}; | ||
|
||
use foo::{ | ||
self, | ||
// abc | ||
}; | ||
|
||
use foo::{ | ||
// 345 | ||
self | ||
}; | ||
|
||
use foo::{ | ||
self // a | ||
, | ||
}; | ||
|
||
use foo::{ self /* a */ }; | ||
|
||
use foo::{ self /* a */, }; | ||
|
||
use foo::{ | ||
// abc | ||
abc::{ | ||
xyz | ||
// 123 | ||
} | ||
}; | ||
|
||
use foo::{ | ||
// abc | ||
bar, | ||
abc | ||
}; | ||
|
||
use foo::{ | ||
bar, | ||
// abc | ||
abc | ||
}; | ||
|
||
use foo::{ | ||
bar, | ||
abc | ||
// abc | ||
}; | ||
|
||
use foo::{ | ||
bar, | ||
abc, | ||
// abc | ||
}; | ||
|
||
use foo::{ | ||
self, | ||
// abc | ||
abc::{ | ||
xyz | ||
// 123 | ||
} | ||
}; | ||
|
||
use foo::{ | ||
self, | ||
// abc | ||
abc::{ | ||
// 123 | ||
xyz | ||
} | ||
}; | ||
|
||
use path::{self /*comment*/,}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use std::{ | ||
fs, | ||
// (temporarily commented, we'll need this again in a second) io, | ||
}; | ||
|
||
use foo::{ | ||
self // this is important | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
When you get a chance can you explain why we need to add the
tactic == DefinitiveListTactic::Vertical)
check.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.
This is to resolve the second problem shown in the issue. The problem is that it will try to put in on one line because the list doesn't contain a newline (because there is only one actual item, and the newlines are only between items).
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.
Got it. It looks like
tactic
is somewhat influenced by the user's specified value forimports_layout
. Out of an abundance of caution can you make sure that this fix holds for all values ofimports_layout
. Probably best to create aissue-5852
directory and add a test case for eachimports_layout
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.
@ytmimi sorry for the delayed response, but it should be fixed now