Skip to content

Commit

Permalink
Merge pull request rust-lang#3183 from scampi/issue3182
Browse files Browse the repository at this point in the history
do not wrap comments in doctest to avoid failing doctest runs
  • Loading branch information
nrc authored Nov 9, 2018
2 parents 9534dfc + a5043a8 commit c4cc479
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 23 deletions.
13 changes: 3 additions & 10 deletions src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,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),
Expand Down Expand Up @@ -798,16 +798,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::<Vec<_>>()
Expand Down
File renamed without changes.
13 changes: 0 additions & 13 deletions tests/target/wrapped_hidden_code_block.rs

This file was deleted.

0 comments on commit c4cc479

Please sign in to comment.