Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ fn identify_comment(
config: &Config,
is_doc_comment: bool,
) -> RewriteResult {
let style = comment_style(orig, false);
let style = comment_style(orig.trim_start(), false);

// Computes the byte length of line taking into account a newline if the line is part of a
// paragraph.
Expand Down
8 changes: 8 additions & 0 deletions tests/source/issue-6612/hidden_code_in_doc_comment.rs
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;
12 changes: 12 additions & 0 deletions tests/source/issue-6612/mixed_comment_types.rs
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
}
8 changes: 8 additions & 0 deletions tests/target/issue-6612/hidden_code_in_doc_comment.rs
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;
12 changes: 12 additions & 0 deletions tests/target/issue-6612/mixed_comment_types.rs
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
}
Loading