@@ -27,10 +27,7 @@ use super::remove_unused_param::is_trait_impl;
2727pub ( crate ) fn bind_unused_param ( acc : & mut Assists , ctx : & AssistContext < ' _ > ) -> Option < ( ) > {
2828 let param: ast:: Param = ctx. find_node_at_offset ( ) ?;
2929
30- let ident_pat = match param. pat ( ) ? {
31- ast:: Pat :: IdentPat ( it) => it,
32- _ => return None ,
33- } ;
30+ let Some ( ast:: Pat :: IdentPat ( ident_pat) ) = param. pat ( ) else { return None } ;
3431
3532 let func = param. syntax ( ) . ancestors ( ) . find_map ( ast:: Fn :: cast) ?;
3633 if is_trait_impl ( & func) {
@@ -47,28 +44,29 @@ pub(crate) fn bind_unused_param(acc: &mut Assists, ctx: &AssistContext<'_>) -> O
4744 return None ;
4845 }
4946
50- let line_index = ctx. db ( ) . line_index ( ctx. file_id ( ) ) ;
51-
52- let mut indent = func. indent_level ( ) ;
53- indent. 0 += 1 ;
54- let mut text = format ! ( "\n {indent}let _ = {ident_pat};" ) ;
55-
5647 let stmt_list = func. body ( ) ?. stmt_list ( ) ?;
5748 let l_curly_range = stmt_list. l_curly_token ( ) ?. text_range ( ) ;
5849 let r_curly_range = stmt_list. r_curly_token ( ) ?. text_range ( ) ;
59- let left_line = line_index. line_col ( l_curly_range. end ( ) ) . line ;
60- let right_line = line_index. line_col ( r_curly_range. start ( ) ) . line ;
61-
62- if left_line == right_line {
63- cov_mark:: hit!( single_line) ;
64- text. push ( '\n' ) ;
65- }
6650
6751 acc. add (
68- AssistId ( "bind_unused_param" , AssistKind :: Refactor ) ,
52+ AssistId ( "bind_unused_param" , AssistKind :: QuickFix ) ,
6953 & format ! ( "Bind as `let _ = {};`" , & ident_pat) ,
7054 param. syntax ( ) . text_range ( ) ,
7155 |builder| {
56+ let line_index = ctx. db ( ) . line_index ( ctx. file_id ( ) ) ;
57+
58+ let mut indent = func. indent_level ( ) ;
59+ indent. 0 += 1 ;
60+ let mut text = format ! ( "\n {indent}let _ = {ident_pat};" ) ;
61+
62+ let left_line = line_index. line_col ( l_curly_range. end ( ) ) . line ;
63+ let right_line = line_index. line_col ( r_curly_range. start ( ) ) . line ;
64+
65+ if left_line == right_line {
66+ cov_mark:: hit!( single_line) ;
67+ text. push ( '\n' ) ;
68+ }
69+
7270 builder. insert ( l_curly_range. end ( ) , text) ;
7371 } ,
7472 )
0 commit comments