File tree 1 file changed +18
-1
lines changed
1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -644,7 +644,24 @@ impl<'a> FmtVisitor<'a> {
644
644
645
645
// If one of the variants use multiple lines, use multi-lined formatting for all variants.
646
646
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
+ } ) ;
648
665
if has_multiline_variant && has_single_line_variant {
649
666
items = itemize_list_with ( 0 ) ;
650
667
}
You can’t perform that action at this time.
0 commit comments