File tree 3 files changed +19
-1
lines changed
3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -379,7 +379,9 @@ fn rewrite_match_body(
379
379
// Look for comments between `=>` and the start of the body.
380
380
let arrow_comment = {
381
381
let arrow_snippet = context. snippet ( arrow_span) . trim ( ) ;
382
- let arrow_index = arrow_snippet. find ( "=>" ) . unwrap ( ) ;
382
+ // search for the arrow starting from the end of the snippet since there may be a match
383
+ // expression within the guard
384
+ let arrow_index = arrow_snippet. rfind ( "=>" ) . unwrap ( ) ;
383
385
// 2 = `=>`
384
386
let comment_str = arrow_snippet[ arrow_index + 2 ..] . trim ( ) ;
385
387
if comment_str. is_empty ( ) {
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ match 3 {
3
+ t if match t {
4
+ _ => true ,
5
+ } => { } ,
6
+ _ => { }
7
+ }
8
+ }
Original file line number Diff line number Diff line change
1
+ fn main ( ) {
2
+ match 3 {
3
+ t if match t {
4
+ _ => true ,
5
+ } => { }
6
+ _ => { }
7
+ }
8
+ }
You can’t perform that action at this time.
0 commit comments