Skip to content

Commit c4cc479

Browse files
authored
Merge pull request #3183 from scampi/issue3182
do not wrap comments in doctest to avoid failing doctest runs
2 parents 9534dfc + a5043a8 commit c4cc479

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
@@ -626,7 +626,7 @@ impl<'a> CommentRewrite<'a> {
626626
_ if self.code_block_buffer.is_empty() => String::new(),
627627
_ => {
628628
let mut config = self.fmt.config.clone();
629-
config.set().format_doc_comments(false);
629+
config.set().wrap_comments(false);
630630
match ::format_code_block(&self.code_block_buffer, &config) {
631631
Some(ref s) => trim_custom_comment_prefix(&s.snippet),
632632
None => trim_custom_comment_prefix(&self.code_block_buffer),
@@ -798,16 +798,9 @@ fn trim_custom_comment_prefix(s: &str) -> String {
798798
.map(|line| {
799799
let left_trimmed = line.trim_left();
800800
if left_trimmed.starts_with(RUSTFMT_CUSTOM_COMMENT_PREFIX) {
801-
let orig = left_trimmed.trim_left_matches(RUSTFMT_CUSTOM_COMMENT_PREFIX);
802-
// due to comment wrapping, a line that was originally behind `#` is split over
803-
// multiple lines, which needs then to be prefixed with a `#`
804-
if !orig.trim_left().starts_with("# ") {
805-
Cow::from(format!("# {}", orig))
806-
} else {
807-
Cow::from(orig)
808-
}
801+
left_trimmed.trim_left_matches(RUSTFMT_CUSTOM_COMMENT_PREFIX)
809802
} else {
810-
Cow::from(line)
803+
line
811804
}
812805
})
813806
.collect::<Vec<_>>()

tests/target/wrapped_hidden_code_block.rs

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

0 commit comments

Comments
 (0)