Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit a5043a8

Browse files
committed
do not wrap comments in doctest to avoid failing doctest runs
1 parent cd8bb50 commit a5043a8

File tree

3 files changed

+3
-23
lines changed

3 files changed

+3
-23
lines changed

src/comment.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ impl<'a> CommentRewrite<'a> {
618618
_ if self.code_block_buffer.is_empty() => String::new(),
619619
_ => {
620620
let mut config = self.fmt.config.clone();
621-
config.set().format_doc_comments(false);
621+
config.set().wrap_comments(false);
622622
match ::format_code_block(&self.code_block_buffer, &config) {
623623
Some(ref s) => trim_custom_comment_prefix(&s.snippet),
624624
None => trim_custom_comment_prefix(&self.code_block_buffer),
@@ -790,16 +790,9 @@ fn trim_custom_comment_prefix(s: &str) -> String {
790790
.map(|line| {
791791
let left_trimmed = line.trim_left();
792792
if left_trimmed.starts_with(RUSTFMT_CUSTOM_COMMENT_PREFIX) {
793-
let orig = left_trimmed.trim_left_matches(RUSTFMT_CUSTOM_COMMENT_PREFIX);
794-
// due to comment wrapping, a line that was originally behind `#` is split over
795-
// multiple lines, which needs then to be prefixed with a `#`
796-
if !orig.trim_left().starts_with("# ") {
797-
Cow::from(format!("# {}", orig))
798-
} else {
799-
Cow::from(orig)
800-
}
793+
left_trimmed.trim_left_matches(RUSTFMT_CUSTOM_COMMENT_PREFIX)
801794
} else {
802-
Cow::from(line)
795+
line
803796
}
804797
})
805798
.collect::<Vec<_>>()

tests/target/wrapped_hidden_code_block.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)