File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
crates/linter/src/rule/best_practices Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -136,14 +136,15 @@ impl LintRule for PreferArrowFunctionRule {
136136 . with_help ( "Consider rewriting this as an arrow function to improve readability." ) ;
137137
138138 ctx. collector . propose ( issue, |edits| {
139- let to_replace_with_fn = closure. function . span ;
139+ let function_span = closure. function . span ;
140+ let to_replace_with_n = function_span. from_start ( function_span. start . forward ( 1 ) ) ;
140141 let to_replace_with_arrow = match & closure. use_clause {
141142 Some ( use_clause) => use_clause. span ( ) . join ( keyword. span ) ,
142143 None => closure. body . left_brace . join ( keyword. span ) ,
143144 } ;
144145 let to_remove = terminator. span ( ) . join ( closure. body . right_brace ) ;
145146
146- edits. push ( TextEdit :: replace ( to_replace_with_fn , "fn " ) . with_safety ( Safety :: PotentiallyUnsafe ) ) ;
147+ edits. push ( TextEdit :: replace ( to_replace_with_n , "n " ) . with_safety ( Safety :: PotentiallyUnsafe ) ) ;
147148 edits. push ( TextEdit :: replace ( to_replace_with_arrow, "=>" ) . with_safety ( Safety :: PotentiallyUnsafe ) ) ;
148149 edits. push ( TextEdit :: delete ( to_remove) . with_safety ( Safety :: PotentiallyUnsafe ) ) ;
149150 } ) ;
You can’t perform that action at this time.
0 commit comments