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 @@ -649,7 +649,24 @@ impl<'a> FmtVisitor<'a> {
649
649
650
650
// If one of the variants use multiple lines, use multi-lined formatting for all variants.
651
651
let has_multiline_variant = items. iter ( ) . any ( |item| item. inner_as_ref ( ) . contains ( '\n' ) ) ;
652
- let has_single_line_variant = items. iter ( ) . any ( |item| !item. inner_as_ref ( ) . contains ( '\n' ) ) ;
652
+ let has_single_line_variant = items. iter ( ) . any ( |item| {
653
+ let variant_str = item. inner_as_ref ( ) ;
654
+ let mut first_line_is_read = false ;
655
+ for line in variant_str. split ( '\n' ) {
656
+ if first_line_is_read {
657
+ return false ;
658
+ }
659
+
660
+ // skip rustdoc comments and macro attributes
661
+ if line. starts_with ( "///" ) || line. starts_with ( "#" ) {
662
+ continue ;
663
+ } else {
664
+ first_line_is_read = true ;
665
+ }
666
+ }
667
+
668
+ true
669
+ } ) ;
653
670
dbg ! ( has_multiline_variant) ;
654
671
dbg ! ( has_single_line_variant) ;
655
672
dbg ! ( & items) ;
You can’t perform that action at this time.
0 commit comments