@@ -831,33 +831,53 @@ impl<'a> ControlFlow<'a> {
831831            let  comments_lo = context
832832                . snippet_provider 
833833                . span_after ( self . span ,  self . connector . trim ( ) ) ; 
834-             let  missing_comments = if  let  Some ( comment)  =
835-                 rewrite_missing_comment ( mk_sp ( comments_lo,  expr. span . lo ( ) ) ,  cond_shape,  context) 
836-             { 
837-                 if  !self . connector . is_empty ( )  && !comment. is_empty ( )  { 
838-                     if  comment_style ( & comment,  false ) . is_line_comment ( )  || comment. contains ( '\n' )  { 
839-                         let  newline = & pat_shape
840-                             . indent 
841-                             . block_indent ( context. config ) 
842-                             . to_string_with_newline ( context. config ) ; 
843-                         // An extra space is added when the lhs and rhs are joined 
844-                         // so we need to remove one space from the end to ensure 
845-                         // the comment and rhs are aligned. 
846-                         let  mut  suffix = newline. as_ref ( ) . to_string ( ) ; 
847-                         if  !suffix. is_empty ( )  { 
848-                             suffix. truncate ( suffix. len ( )  - 1 ) ; 
849-                         } 
850-                         format ! ( "{}{}{}" ,  newline,  comment,  suffix) 
851-                     }  else  { 
852-                         format ! ( " {}" ,  comment) 
853-                     } 
854-                 }  else  { 
855-                     comment
834+             let  comments_span = mk_sp ( comments_lo,  expr. span . lo ( ) ) ; 
835+ 
836+             let  missing_comments = match  rewrite_missing_comment ( 
837+                 comments_span, 
838+                 cond_shape, 
839+                 context, 
840+             )  { 
841+                 None  => "" . to_owned ( ) , 
842+                 Some ( comment)  if  self . connector . is_empty ( )  || comment. is_empty ( )  => comment, 
843+                 // Handle same-line block comments: 
844+                 //     if let Some(foo) = /*bar*/ baz { ... } 
845+                 //     if let Some(ref /*def*/ mut /*abc*/ state)... 
846+                 Some ( comment) 
847+                     if  !comment_style ( & comment,  false ) . is_line_comment ( ) 
848+                         && !comment. contains ( '\n' )  =>
849+                 { 
850+                     format ! ( " {}" ,  comment) 
851+                 } 
852+                 // Handle sequence of multiple inline comments: 
853+                 //     if let Some(n) = 
854+                 //         // this is a test comment 
855+                 //         // with another 
856+                 //         foo { .... } 
857+                 Some ( _)  => { 
858+                     let  newline = & cond_shape
859+                         . indent 
860+                         . block_indent ( context. config ) 
861+                         . to_string_with_newline ( context. config ) ; 
862+                     let  shape = pat_shape. block_indent ( context. config . tab_spaces ( ) ) ; 
863+                     let  comment = format ! ( 
864+                         "{}{}" , 
865+                         newline, 
866+                         rewrite_missing_comment( comments_span,  shape,  context) ?, 
867+                     ) ; 
868+                     let  lhs = format ! ( "{}{}{}{}" ,  matcher,  pat_string,  self . connector,  comment) ; 
869+                     let  orig_rhs = Some ( format ! ( "{}{}" ,  newline,  expr. rewrite( context,  shape) ?) ) ; 
870+                     let  rhs = choose_rhs ( 
871+                         context, 
872+                         expr, 
873+                         cond_shape, 
874+                         orig_rhs, 
875+                         RhsTactics :: Default , 
876+                         true , 
877+                     ) ?; 
878+                     return  Some ( format ! ( "{}{}" ,  lhs,  rhs) ) ; 
856879                } 
857-             }  else  { 
858-                 "" . to_owned ( ) 
859880            } ; 
860- 
861881            let  result = format ! ( 
862882                "{}{}{}{}" , 
863883                matcher,  pat_string,  self . connector,  missing_comments
0 commit comments