From a5043a81be1b6288e96b8320cf69f397e4be7159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Campinas?= Date: Wed, 7 Nov 2018 16:48:39 +0100 Subject: [PATCH] do not wrap comments in doctest to avoid failing doctest runs --- src/comment.rs | 13 +++---------- .../issue-3182.rs} | 0 tests/target/wrapped_hidden_code_block.rs | 13 ------------- 3 files changed, 3 insertions(+), 23 deletions(-) rename tests/{source/wrapped_hidden_code_block.rs => target/issue-3182.rs} (100%) delete mode 100644 tests/target/wrapped_hidden_code_block.rs diff --git a/src/comment.rs b/src/comment.rs index 4ba95bda053..8b2a4eefa9a 100644 --- a/src/comment.rs +++ b/src/comment.rs @@ -618,7 +618,7 @@ impl<'a> CommentRewrite<'a> { _ if self.code_block_buffer.is_empty() => String::new(), _ => { let mut config = self.fmt.config.clone(); - config.set().format_doc_comments(false); + config.set().wrap_comments(false); match ::format_code_block(&self.code_block_buffer, &config) { Some(ref s) => trim_custom_comment_prefix(&s.snippet), None => trim_custom_comment_prefix(&self.code_block_buffer), @@ -790,16 +790,9 @@ fn trim_custom_comment_prefix(s: &str) -> String { .map(|line| { let left_trimmed = line.trim_left(); if left_trimmed.starts_with(RUSTFMT_CUSTOM_COMMENT_PREFIX) { - let orig = left_trimmed.trim_left_matches(RUSTFMT_CUSTOM_COMMENT_PREFIX); - // due to comment wrapping, a line that was originally behind `#` is split over - // multiple lines, which needs then to be prefixed with a `#` - if !orig.trim_left().starts_with("# ") { - Cow::from(format!("# {}", orig)) - } else { - Cow::from(orig) - } + left_trimmed.trim_left_matches(RUSTFMT_CUSTOM_COMMENT_PREFIX) } else { - Cow::from(line) + line } }) .collect::>() diff --git a/tests/source/wrapped_hidden_code_block.rs b/tests/target/issue-3182.rs similarity index 100% rename from tests/source/wrapped_hidden_code_block.rs rename to tests/target/issue-3182.rs diff --git a/tests/target/wrapped_hidden_code_block.rs b/tests/target/wrapped_hidden_code_block.rs deleted file mode 100644 index 572f448c4e7..00000000000 --- a/tests/target/wrapped_hidden_code_block.rs +++ /dev/null @@ -1,13 +0,0 @@ -// rustfmt-max_width: 79 -// rustfmt-wrap_comments: true - -/// ```rust -/// # #![cfg_attr(not(dox), feature(cfg_target_feature, target_feature, -/// # stdsimd)not(dox), feature(cfg_target_feature, target_feature, -/// # stdsimd))] -/// -/// // Est lectus hendrerit lorem, eget dignissim orci nisl sit amet massa. -/// // Etiam volutpat lobortis eros. -/// let x = 42; -/// ``` -fn func() {}