-
Notifications
You must be signed in to change notification settings - Fork 996
Fix misidentification of indented comments #6617
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
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. Question [IDEMPOTENCE 2/2]: ditto on the "format as expected" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // rustfmt-format_code_in_doc_comments: true | ||
| // rustfmt-edition: 2024 | ||
|
|
||
| /// ``` | ||
| /// println!("1"); // comment | ||
| /// # println!("2") | ||
| /// ``` | ||
| struct S; |
|
Member
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. Question [IDEMPOTENCE 1/2]: is this a "rustfmt doesn't change stable formatting" test? If so, can you remove the
Contributor
Author
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. 👍 thanks, I wasn't aware of a standalone file in
Member
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. I did some more trial and error myself, I missed that there is specifically a case where you would want both a When there's only a (IOW, leaving the source copies as-is is probably good, because other stuff might have strange interations with these examples.) I'll update the contributing docs because this wasn't super obvious to me at first, but became obvious on hindsight |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // rustfmt-edition: 2024 | ||
|
|
||
| fn wat1() { | ||
| println!("1"); // double slash comment | ||
| /* another comment type */ | ||
| } | ||
|
|
||
| fn wat1() { | ||
| println!("1"); // double slash comment | ||
| /* another comment type */ | ||
| //# yet another type | ||
| } |
|
Member
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. Suggestion: can you also add coverage for:
/// println!("1"); // comment
/// # println!("2")
struct S;
/// ```
/// println!("1"); // comment
///# println!("2")
/// ```
struct S;/// ```
/// println!("1"); // comment
///#println!("2")
/// ```
struct S; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // rustfmt-format_code_in_doc_comments: true | ||
| // rustfmt-edition: 2024 | ||
|
|
||
| /// ``` | ||
| /// println!("1"); // comment | ||
| /// # println!("2") | ||
| /// ``` | ||
| struct S; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // rustfmt-edition: 2024 | ||
|
|
||
| fn wat1() { | ||
| println!("1"); // double slash comment | ||
| /* another comment type */ | ||
| } | ||
|
|
||
| fn wat1() { | ||
| println!("1"); // double slash comment | ||
| /* another comment type */ | ||
| //# yet another type | ||
| } |
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.
Suggestion: can you leave a brief comment here with an example, i.e.
// Account for leading whitespace, e.g. ` //#`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.
🤔 let me actually think over this change a bit more: I'm wondering if this is too naive and comments with different indentation levels are now accidentally match on the same style.