@@ -11,9 +11,8 @@ use crate::formatting::{
11
11
chains:: rewrite_chain,
12
12
closures,
13
13
comment:: {
14
- combine_strs_with_missing_comments, comment_style, contains_comment,
15
- recover_comment_removed, rewrite_comment, rewrite_missing_comment, CharClasses ,
16
- FindUncommented ,
14
+ combine_strs_with_missing_comments, contains_comment, recover_comment_removed,
15
+ rewrite_comment, rewrite_missing_comment, CharClasses , FindUncommented ,
17
16
} ,
18
17
lists:: {
19
18
definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape,
@@ -896,54 +895,15 @@ impl<'a> ControlFlow<'a> {
896
895
. snippet_provider
897
896
. span_after ( self . span , self . connector . trim ( ) ) ;
898
897
let comments_span = mk_sp ( comments_lo, expr. span . lo ( ) ) ;
899
-
900
- let missing_comments = match rewrite_missing_comment ( comments_span, cond_shape, context)
901
- {
902
- None => "" . to_owned ( ) ,
903
- Some ( comment) if self . connector . is_empty ( ) || comment. is_empty ( ) => comment,
904
- // Handle same-line block comments:
905
- // if let Some(foo) = /*bar*/ baz { ... }
906
- // if let Some(ref /*def*/ mut /*abc*/ state)...
907
- Some ( comment)
908
- if !comment_style ( & comment, false ) . is_line_comment ( )
909
- && !comment. contains ( '\n' ) =>
910
- {
911
- format ! ( " {}" , comment)
912
- }
913
- // Handle sequence of multiple inline comments:
914
- // if let Some(n) =
915
- // // this is a test comment
916
- // // with another
917
- // foo { .... }
918
- Some ( _) => {
919
- let newline = & cond_shape
920
- . indent
921
- . block_indent ( context. config )
922
- . to_string_with_newline ( context. config ) ;
923
- let shape = pat_shape. block_indent ( context. config . tab_spaces ( ) ) ;
924
- let comment = format ! (
925
- "{}{}" ,
926
- newline,
927
- rewrite_missing_comment( comments_span, shape, context) ?,
928
- ) ;
929
- let lhs = format ! ( "{}{}{}{}" , matcher, pat_string, self . connector, comment) ;
930
- let orig_rhs = Some ( format ! ( "{}{}" , newline, expr. rewrite( context, shape) ?) ) ;
931
- let rhs = choose_rhs (
932
- context,
933
- expr,
934
- cond_shape,
935
- orig_rhs,
936
- RhsTactics :: Default ,
937
- true ,
938
- ) ?;
939
- return Some ( format ! ( "{}{}" , lhs, rhs) ) ;
940
- }
941
- } ;
942
- let result = format ! (
943
- "{}{}{}{}" ,
944
- matcher, pat_string, self . connector, missing_comments
898
+ return rewrite_assign_rhs_with_comments (
899
+ context,
900
+ & format ! ( "{}{}{}" , matcher, pat_string, self . connector) ,
901
+ expr,
902
+ cond_shape,
903
+ RhsTactics :: Default ,
904
+ comments_span,
905
+ true ,
945
906
) ;
946
- return rewrite_assign_rhs ( context, result, expr, cond_shape) ;
947
907
}
948
908
949
909
let expr_rw = expr. rewrite ( context, cond_shape) ;
0 commit comments