.map(|line| {
let left_trimmed = line.trim_left();
if left_trimmed.starts_with(RUSTFMT_CUSTOM_COMMENT_PREFIX) {
- left_trimmed.trim_left_matches(RUSTFMT_CUSTOM_COMMENT_PREFIX)
+ let orig = left_trimmed.trim_left_matches(RUSTFMT_CUSTOM_COMMENT_PREFIX);
+ // due to comment wrapping, a line that was originaly behind `#` is split over
+ // multiple lines, which needs then to be prefixed with a `#`
+ if !orig.trim_left().starts_with("# ") {
+ format!("# {}", orig)
+ } else {
+ orig.to_string()
+ }
} else {
- line
+ line.to_string()
}
})
.collect::<Vec<_>>()
--- /dev/null
+// 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() {}
--- /dev/null
+// 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() {}