@@ -5,7 +5,7 @@ use std::iter::repeat;
5
5
use rustc_ast:: { ast, ptr} ;
6
6
use rustc_span:: { BytePos , Span } ;
7
7
8
- use crate :: comment:: { combine_strs_with_missing_comments, rewrite_comment} ;
8
+ use crate :: comment:: { combine_strs_with_missing_comments, rewrite_comment, FindUncommented } ;
9
9
use crate :: config:: lists:: * ;
10
10
use crate :: config:: { Config , ControlBraceStyle , IndentStyle , MatchArmLeadingPipe , Version } ;
11
11
use crate :: expr:: {
@@ -402,16 +402,7 @@ fn rewrite_match_body(
402
402
let arrow_snippet = context. snippet ( arrow_span) . trim ( ) ;
403
403
// search for the arrow starting from the end of the snippet since there may be a match
404
404
// expression within the guard
405
- let mut arrow_index = arrow_snippet. rfind ( "=>" ) . unwrap ( ) ;
406
- // check whether `=>` is included in the comment
407
- if arrow_index != 0 {
408
- let prev_arrow = arrow_snippet[ ..arrow_index] . trim ( ) ;
409
- let single_line_comment_index = prev_arrow. rfind ( "//" ) . unwrap_or ( 0 ) ;
410
- let new_line_index = prev_arrow. rfind ( "\n " ) . unwrap_or ( 0 ) ;
411
- if single_line_comment_index > new_line_index {
412
- arrow_index = 0 ;
413
- }
414
- }
405
+ let arrow_index = arrow_snippet. find_last_uncommented ( "=>" ) . unwrap ( ) ;
415
406
// 2 = `=>`
416
407
let comment_str = arrow_snippet[ arrow_index + 2 ..] . trim ( ) ;
417
408
if comment_str. is_empty ( ) {
0 commit comments