Skip to content
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ fn format_code_block(
let block_len = formatted
.snippet
.rfind('}')
.map(|i| formatted.snippet[..i].strip_suffix(' ').map_or(i, str::len))
Comment thread
utakotoba marked this conversation as resolved.
Outdated
Comment thread
utakotoba marked this conversation as resolved.
Outdated
.unwrap_or_else(|| formatted.snippet.len());

// It's possible that `block_len < FN_MAIN_PREFIX.len()`. This can happen if the code block was
Expand Down
7 changes: 7 additions & 0 deletions tests/target/issue-6832.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// rustfmt-format_code_in_doc_comments: true
// rustfmt-fn_single_line: true

/// ```rust
/// let font = String::from("hello");
/// ```
fn main() {}
Comment thread
utakotoba marked this conversation as resolved.
Outdated
Loading