-
Notifications
You must be signed in to change notification settings - Fork 898
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue with extra semicolon when import comment preceeds semicolon
- Loading branch information
1 parent
4620723
commit e10d2d7
Showing
9 changed files
with
241 additions
and
2 deletions.
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
32 changes: 32 additions & 0 deletions
32
tests/source/imports/imports_granularity_crate-with-comments.rs
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,32 @@ | ||
// rustfmt-imports_granularity: Crate | ||
|
||
// With one comment per item - after the the `;` | ||
use foo1 ; /* 2nd foo1 - comment after ; */ | ||
use crate::foo2::bar ; /* 1st foo1::bar - comment after ; */ | ||
use crate::foo2::bar ; | ||
|
||
// With one comment per item - before the the `;` | ||
use foo3 /* 2nd foo3 - comment before ; */ ; | ||
use crate::foo4::bar /* 1st foo4::bar - comment before ; */ ; | ||
use crate::foo4::bar ; | ||
|
||
// With multiline comments or multi comments - after the `;` | ||
use crate::foo5; /* foo5 - Multiline comment before ; line 1 | ||
* foo5 - Multiline comment before ; line 2 */ | ||
use crate::foo5; | ||
use crate::foo6; // foo6- mixed comments before ; - 1st line comment ; | ||
/* foo6- mixed comments before ; - 2nd block comment */ | ||
use crate::foo6; | ||
|
||
// With multiline comments or multi comments - before the `;` | ||
use crate::foo7 /* foo7 - Multiline comment before ; line 1 | ||
* foo7 - Multiline comment before ; line 2 */ ; | ||
use crate::foo7; | ||
use crate::foo8 // foo8- mixed comments before ; - 1st line comment ; | ||
/* foo8- mixed comments before ; - 2nd block comment */ ; | ||
use crate::foo8; | ||
|
||
// With one comment for a module | ||
use crate::foo21::{self} ; /* external comment for foo21 {self} */ | ||
use crate::foo21::{foo} ; | ||
use crate::foo21::{bar} ; |
38 changes: 38 additions & 0 deletions
38
tests/source/imports/imports_granularity_default-with-comments.rs
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,38 @@ | ||
// With one comment per item - after the the `;` | ||
use crate::foo1 ; | ||
use crate::foo1 ; /* 2nd foo1 - comment after ; */ | ||
use crate::foo2::bar ; /* 1st foo1::bar - comment after ; */ | ||
use crate::foo2::bar ; | ||
|
||
// With one comment per item - before the the `;` | ||
use crate::foo3 ; | ||
use crate::foo3 /* 2nd foo3 - comment before ; */ ; | ||
use crate::foo4::bar /* 1st foo4::bar - comment before ; */ ; | ||
use crate::foo4::bar ; | ||
|
||
// With multiline comments or multi comments - after the `;` | ||
use crate::foo5; /* foo5 - Multiline comment before ; line 1 | ||
* foo5 - Multiline comment before ; line 2 */ | ||
use crate::foo5; | ||
use crate::foo6; // foo6- mixed comments before ; - 1st line comment ; | ||
/* foo6- mixed comments before ; - 2nd block comment */ | ||
use crate::foo6; | ||
|
||
// With multiline comments or multi comments - before the `;` | ||
use crate::foo8 // foo8- mixed comments before ; - 1st line comment ; | ||
/* foo8- mixed comments before ; - 2nd block comment */ ; | ||
use crate::foo8; | ||
|
||
// With two comments per item | ||
use crate::foo11 ; /* 1st foo11 - comment */ | ||
use crate::foo11 ; /* 2nd foo11 - comment */ | ||
|
||
// With one comment for a module | ||
use crate::foo21::{self} ; /* external comment for foo21 {self} */ | ||
use crate::foo21::{foo} ; /* external comment for foo21 {foo} */ | ||
use crate::foo21::{bar} ; | ||
|
||
// With internal and external comment for a module | ||
use crate::foo22::{self} ; /* external comment for foo22 {self} */ | ||
use crate::foo22::{foo /* internal comment for foo22 {foo} */} ; | ||
use crate::foo22::{bar /* internal comment for foo22 {bar} */} ; |
24 changes: 24 additions & 0 deletions
24
tests/source/imports/imports_granularity_item-with-comments.rs
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,24 @@ | ||
// rustfmt-imports_granularity: Item | ||
|
||
// With one comment per item - after the the `;` | ||
use crate::foo2::bar ; /* 1st foo1::bar - comment after ; */ | ||
use crate::foo2::bar ; | ||
|
||
// With one comment per item - before the the `;` | ||
use crate::foo4::bar /* 1st foo4::bar - comment before ; */ ; | ||
use crate::foo4::bar ; | ||
|
||
// With multiline comments or multi comments - after the `;` | ||
use crate::foo5; /* foo5 - Multiline comment before ; line 1 | ||
* foo5 - Multiline comment before ; line 2 */ | ||
use crate::foo6; // foo6- mixed comments before ; - 1st line comment ; | ||
/* foo6- mixed comments before ; - 2nd block comment */ | ||
|
||
// With multiline comments or multi comments - before the `;` | ||
use crate::foo8 // foo8- mixed comments before ; - 1st line comment ; | ||
/* foo8- mixed comments before ; - 2nd block comment */ ; | ||
|
||
// With one comment for a module | ||
use crate::foo21::{self} ; /* external comment for foo21 {self} */ | ||
use crate::foo21::{foo} ; /* external comment for foo21 {foo} */ | ||
use crate::foo21::{bar} ; |
34 changes: 34 additions & 0 deletions
34
tests/source/imports/imports_granularity_module-with-comments.rs
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,34 @@ | ||
// rustfmt-imports_granularity: Module | ||
|
||
// With one comment per item - after the the `;` | ||
use crate::foo1 ; | ||
use crate::foo1 ; /* 2nd foo1 - comment after ; */ | ||
use crate::foo2::bar ; /* 1st foo1::bar - comment after ; */ | ||
use crate::foo2::bar ; | ||
|
||
// With one comment per item - before the the `;` | ||
use crate::foo3 ; | ||
use crate::foo3 /* 2nd foo3 - comment before ; */ ; | ||
use crate::foo4::bar /* 1st foo4::bar - comment before ; */ ; | ||
use crate::foo4::bar ; | ||
|
||
// With multiline comments or multi comments - after the `;` | ||
use crate::foo5; /* foo5 - Multiline comment before ; line 1 | ||
* foo5 - Multiline comment before ; line 2 */ | ||
use crate::foo5; | ||
use crate::foo6; // foo6- mixed comments before ; - 1st line comment ; | ||
/* foo6- mixed comments before ; - 2nd block comment */ | ||
use crate::foo6; | ||
|
||
// With multiline comments or multi comments - before the `;` | ||
use crate::foo7 /* foo7 - Multiline comment before ; line 1 | ||
* foo7 - Multiline comment before ; line 2 */ ; | ||
use crate::foo7; | ||
use crate::foo8 // foo8- mixed comments before ; - 1st line comment ; | ||
/* foo8- mixed comments before ; - 2nd block comment */ ; | ||
use crate::foo8; | ||
|
||
// With one comment for a module | ||
use crate::foo21::{self} ; /* external comment for foo21 {self} */ | ||
use crate::foo21::{foo} ; | ||
use crate::foo21::{bar} ; |
25 changes: 25 additions & 0 deletions
25
tests/target/imports/imports_granularity_crate-with-comments.rs
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,25 @@ | ||
// rustfmt-imports_granularity: Crate | ||
|
||
// With one comment per item - after the the `;` | ||
use crate::foo2::bar; /* 1st foo1::bar - comment after ; */ | ||
use foo1; /* 2nd foo1 - comment after ; */ | ||
|
||
// With one comment per item - before the the `;` | ||
use crate::foo4::bar; /* 1st foo4::bar - comment before ; */ | ||
use foo3; /* 2nd foo3 - comment before ; */ | ||
|
||
// With multiline comments or multi comments - after the `;` | ||
use crate::foo5; /* foo5 - Multiline comment before ; line 1 | ||
* foo5 - Multiline comment before ; line 2 */ | ||
use crate::{foo5, foo6}; // foo6- mixed comments before ; - 1st line comment ; | ||
/* foo6- mixed comments before ; - 2nd block comment */ | ||
use crate::foo6; | ||
|
||
// With multiline comments or multi comments - before the `;` | ||
use crate::foo8; // foo8- mixed comments before ; - 1st line comment ; | ||
/* foo8- mixed comments before ; - 2nd block comment */ | ||
use crate::{foo7, foo8}; /* foo7 - Multiline comment before ; line 1 | ||
* foo7 - Multiline comment before ; line 2 */ | ||
|
||
// With one comment for a module | ||
use crate::foo21::{self, bar, foo}; /* external comment for foo21 {self} */ |
38 changes: 38 additions & 0 deletions
38
tests/target/imports/imports_granularity_default-with-comments.rs
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,38 @@ | ||
// With one comment per item - after the the `;` | ||
use crate::foo1; | ||
use crate::foo1; /* 2nd foo1 - comment after ; */ | ||
use crate::foo2::bar; /* 1st foo1::bar - comment after ; */ | ||
use crate::foo2::bar; | ||
|
||
// With one comment per item - before the the `;` | ||
use crate::foo3; | ||
use crate::foo3; /* 2nd foo3 - comment before ; */ | ||
use crate::foo4::bar; /* 1st foo4::bar - comment before ; */ | ||
use crate::foo4::bar; | ||
|
||
// With multiline comments or multi comments - after the `;` | ||
use crate::foo5; /* foo5 - Multiline comment before ; line 1 | ||
* foo5 - Multiline comment before ; line 2 */ | ||
use crate::foo5; | ||
use crate::foo6; // foo6- mixed comments before ; - 1st line comment ; | ||
/* foo6- mixed comments before ; - 2nd block comment */ | ||
use crate::foo6; | ||
|
||
// With multiline comments or multi comments - before the `;` | ||
use crate::foo8; // foo8- mixed comments before ; - 1st line comment ; | ||
/* foo8- mixed comments before ; - 2nd block comment */ | ||
use crate::foo8; | ||
|
||
// With two comments per item | ||
use crate::foo11; /* 1st foo11 - comment */ | ||
use crate::foo11; /* 2nd foo11 - comment */ | ||
|
||
// With one comment for a module | ||
use crate::foo21::bar; | ||
use crate::foo21::foo; /* external comment for foo21 {foo} */ | ||
use crate::foo21::{self}; /* external comment for foo21 {self} */ | ||
|
||
// With internal and external comment for a module | ||
use crate::foo22::{self}; /* external comment for foo22 {self} */ | ||
use crate::foo22::{bar /* internal comment for foo22 {bar} */}; | ||
use crate::foo22::{foo /* internal comment for foo22 {foo} */}; |
21 changes: 21 additions & 0 deletions
21
tests/target/imports/imports_granularity_item-with-comments.rs
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,21 @@ | ||
// rustfmt-imports_granularity: Item | ||
|
||
// With one comment per item - after the the `;` | ||
use crate::foo2::bar; /* 1st foo1::bar - comment after ; */ | ||
|
||
// With one comment per item - before the the `;` | ||
use crate::foo4::bar; /* 1st foo4::bar - comment before ; */ | ||
|
||
// With multiline comments or multi comments - after the `;` | ||
use crate::foo5; /* foo5 - Multiline comment before ; line 1 | ||
* foo5 - Multiline comment before ; line 2 */ | ||
use crate::foo6; // foo6- mixed comments before ; - 1st line comment ; | ||
/* foo6- mixed comments before ; - 2nd block comment */ | ||
|
||
// With multiline comments or multi comments - before the `;` | ||
use crate::foo8; | ||
|
||
// With one comment for a module | ||
use crate::foo21::bar; | ||
use crate::foo21::foo; /* external comment for foo21 {foo} */ | ||
use crate::foo21::{self}; /* external comment for foo21 {self} */ |
27 changes: 27 additions & 0 deletions
27
tests/target/imports/imports_granularity_module-with-comments.rs
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,27 @@ | ||
// rustfmt-imports_granularity: Module | ||
|
||
// With one comment per item - after the the `;` | ||
use crate::foo1; | ||
use crate::foo1; /* 2nd foo1 - comment after ; */ | ||
use crate::foo2::bar; /* 1st foo1::bar - comment after ; */ | ||
|
||
// With one comment per item - before the the `;` | ||
use crate::foo3; | ||
use crate::foo3; /* 2nd foo3 - comment before ; */ | ||
use crate::foo4::bar; /* 1st foo4::bar - comment before ; */ | ||
|
||
// With multiline comments or multi comments - after the `;` | ||
use crate::foo5; /* foo5 - Multiline comment before ; line 1 | ||
* foo5 - Multiline comment before ; line 2 */ | ||
use crate::{foo5, foo6}; // foo6- mixed comments before ; - 1st line comment ; | ||
/* foo6- mixed comments before ; - 2nd block comment */ | ||
use crate::foo6; | ||
|
||
// With multiline comments or multi comments - before the `;` | ||
use crate::foo8; // foo8- mixed comments before ; - 1st line comment ; | ||
/* foo8- mixed comments before ; - 2nd block comment */ | ||
use crate::{foo7, foo8}; /* foo7 - Multiline comment before ; line 1 | ||
* foo7 - Multiline comment before ; line 2 */ | ||
|
||
// With one comment for a module | ||
use crate::foo21::{self, bar, foo}; /* external comment for foo21 {self} */ |