Skip to content

Commit b3f0af6

Browse files
committed
fix attempt
Made this first fix attempt with the hint at [1] [1] rust-lang#5662 (comment)
1 parent 0c1df42 commit b3f0af6

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Diff for: src/items.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,24 @@ impl<'a> FmtVisitor<'a> {
644644

645645
// If one of the variants use multiple lines, use multi-lined formatting for all variants.
646646
let has_multiline_variant = items.iter().any(|item| item.inner_as_ref().contains('\n'));
647-
let has_single_line_variant = items.iter().any(|item| !item.inner_as_ref().contains('\n'));
647+
let has_single_line_variant = items.iter().any(|item| {
648+
let variant_str = item.inner_as_ref();
649+
let mut first_line_is_read = false;
650+
for line in variant_str.split('\n') {
651+
if first_line_is_read {
652+
return false;
653+
}
654+
655+
// skip rustdoc comments and macro attributes
656+
if line.starts_with("///") || line.starts_with("#") {
657+
continue;
658+
} else {
659+
first_line_is_read = true;
660+
}
661+
}
662+
663+
true
664+
});
648665
if has_multiline_variant && has_single_line_variant {
649666
items = itemize_list_with(0);
650667
}

0 commit comments

Comments
 (0)