forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Retain trailing separator when extracting the last inline post comment
Fixes 5042 Previously, trailing commas were removed from the last inline comment. This lead to rustfmt refusing to format code snippets because the original comment did not match the rewritten comment. Now, when rustfmt extracts the last inline comment it leaves trailing separators alone. Rustfmt does not need to remove these separators because they are commented out.
- Loading branch information
1 parent
368a9b7
commit 606894e
Showing
9 changed files
with
149 additions
and
7 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
24 changes: 24 additions & 0 deletions
24
tests/source/issue-5042/multi-line_comment_with_trailing_comma.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 @@ | ||
fn main() { | ||
// 5042 deals with trailing commas, not the indentation issue of these comments | ||
// When a future PR fixes the inentation issues these test can be updated | ||
let _ = std::ops::Add::add(10, 20 | ||
// ... | ||
// ..., | ||
); | ||
|
||
let _ = std::ops::Add::add(10, 20 | ||
/* ... */ | ||
// ..., | ||
); | ||
|
||
let _ = std::ops::Add::add(10, 20 | ||
// ..., | ||
// ..., | ||
); | ||
|
||
let _ = std::ops::Add::add(10, 20 | ||
// ..., | ||
/* ... | ||
*/, | ||
); | ||
} |
24 changes: 24 additions & 0 deletions
24
tests/source/issue-5042/multi-line_comment_without_trailing_comma.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 @@ | ||
fn main() { | ||
// 5042 deals with trailing commas, not the indentation issue of these comments | ||
// When a future PR fixes the inentation issues these test can be updated | ||
let _ = std::ops::Add::add(10, 20 | ||
// ... | ||
// ... | ||
); | ||
|
||
let _ = std::ops::Add::add(10, 20 | ||
/* ... */ | ||
// ... | ||
); | ||
|
||
let _ = std::ops::Add::add(10, 20 | ||
// ... | ||
// ... | ||
); | ||
|
||
let _ = std::ops::Add::add(10, 20 | ||
// ... | ||
/* ... | ||
*/ | ||
); | ||
} |
9 changes: 9 additions & 0 deletions
9
tests/source/issue-5042/single-line_comment_with_trailing_comma.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,9 @@ | ||
fn main() { | ||
let _ = std::ops::Add::add(10, 20 | ||
// ..., | ||
); | ||
|
||
let _ = std::ops::Add::add(10, 20 | ||
/* ... */, | ||
); | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/source/issue-5042/single-line_comment_without_trailing_comma.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,10 @@ | ||
fn main() { | ||
let _ = std::ops::Add::add(10, 20 | ||
// ... | ||
); | ||
|
||
let _ = std::ops::Add::add(10, 20 | ||
/* ... */ | ||
); | ||
} | ||
|
24 changes: 24 additions & 0 deletions
24
tests/target/issue-5042/multi-line_comment_with_trailing_comma.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 @@ | ||
fn main() { | ||
// 5042 deals with trailing commas, not the indentation issue of these comments | ||
// When a future PR fixes the inentation issues these test can be updated | ||
let _ = std::ops::Add::add( | ||
10, 20, // ... | ||
// ..., | ||
); | ||
|
||
let _ = std::ops::Add::add( | ||
10, 20, /* ... */ | ||
// ..., | ||
); | ||
|
||
let _ = std::ops::Add::add( | ||
10, 20, // ..., | ||
// ..., | ||
); | ||
|
||
let _ = std::ops::Add::add( | ||
10, 20, // ..., | ||
/* ... | ||
*/ | ||
); | ||
} |
24 changes: 24 additions & 0 deletions
24
tests/target/issue-5042/multi-line_comment_without_trailing_comma.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 @@ | ||
fn main() { | ||
// 5042 deals with trailing commas, not the indentation issue of these comments | ||
// When a future PR fixes the inentation issues these test can be updated | ||
let _ = std::ops::Add::add( | ||
10, 20, // ... | ||
// ... | ||
); | ||
|
||
let _ = std::ops::Add::add( | ||
10, 20, /* ... */ | ||
// ... | ||
); | ||
|
||
let _ = std::ops::Add::add( | ||
10, 20, // ... | ||
// ... | ||
); | ||
|
||
let _ = std::ops::Add::add( | ||
10, 20, // ... | ||
/* ... | ||
*/ | ||
); | ||
} |
7 changes: 7 additions & 0 deletions
7
tests/target/issue-5042/single-line_comment_with_trailing_comma.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,7 @@ | ||
fn main() { | ||
let _ = std::ops::Add::add( | ||
10, 20, // ..., | ||
); | ||
|
||
let _ = std::ops::Add::add(10, 20 /* ... */); | ||
} |
7 changes: 7 additions & 0 deletions
7
tests/target/issue-5042/single-line_comment_without_trailing_comma.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,7 @@ | ||
fn main() { | ||
let _ = std::ops::Add::add( | ||
10, 20, // ... | ||
); | ||
|
||
let _ = std::ops::Add::add(10, 20 /* ... */); | ||
} |