@@ -408,7 +408,7 @@ pub fn handle_runnables(
408
408
continue ;
409
409
}
410
410
411
- res. push ( to_proto:: runnable ( & snap, file_id, & runnable) ?) ;
411
+ res. push ( to_proto:: runnable ( & snap, file_id, runnable) ?) ;
412
412
}
413
413
414
414
// Add `cargo check` and `cargo test` for the whole package
@@ -818,7 +818,7 @@ pub fn handle_code_lens(
818
818
819
819
let action = runnable. action ( ) ;
820
820
let range = to_proto:: range ( & line_index, runnable. nav . range ( ) ) ;
821
- let r = to_proto:: runnable ( & snap, file_id, & runnable) ?;
821
+ let r = to_proto:: runnable ( & snap, file_id, runnable) ?;
822
822
if snap. config . lens . run {
823
823
let lens = CodeLens {
824
824
range,
@@ -830,7 +830,7 @@ pub fn handle_code_lens(
830
830
831
831
if action. debugee && snap. config . lens . debug {
832
832
let debug_lens =
833
- CodeLens { range, command : Some ( debug_single_command ( r) ) , data : None } ;
833
+ CodeLens { range, command : Some ( debug_single_command ( & r) ) , data : None } ;
834
834
lenses. push ( debug_lens) ;
835
835
}
836
836
}
@@ -1142,7 +1142,7 @@ fn run_single_command(runnable: &lsp_ext::Runnable, title: &str) -> Command {
1142
1142
}
1143
1143
}
1144
1144
1145
- fn debug_single_command ( runnable : lsp_ext:: Runnable ) -> Command {
1145
+ fn debug_single_command ( runnable : & lsp_ext:: Runnable ) -> Command {
1146
1146
Command {
1147
1147
title : "Debug" . into ( ) ,
1148
1148
command : "rust-analyzer.debugSingle" . into ( ) ,
@@ -1183,26 +1183,25 @@ fn show_impl_command_link(
1183
1183
fn to_runnable_action (
1184
1184
snap : & GlobalStateSnapshot ,
1185
1185
file_id : FileId ,
1186
- runnable : & Runnable ,
1186
+ runnable : Runnable ,
1187
1187
) -> Option < lsp_ext:: CommandLinkGroup > {
1188
1188
let cargo_spec = CargoTargetSpec :: for_file ( & snap, file_id) . ok ( ) ?;
1189
- if should_skip_target ( runnable, cargo_spec. as_ref ( ) ) {
1189
+ if should_skip_target ( & runnable, cargo_spec. as_ref ( ) ) {
1190
1190
return None ;
1191
1191
}
1192
1192
1193
+ let action: & ' static _ = runnable. action ( ) ;
1193
1194
to_proto:: runnable ( snap, file_id, runnable) . ok ( ) . map ( |r| {
1194
1195
let mut group = lsp_ext:: CommandLinkGroup :: default ( ) ;
1195
1196
1196
- let action = runnable. action ( ) ;
1197
1197
if snap. config . hover . run {
1198
1198
let run_command = run_single_command ( & r, action. run_title ) ;
1199
1199
group. commands . push ( to_command_link ( run_command, r. label . clone ( ) ) ) ;
1200
1200
}
1201
1201
1202
1202
if snap. config . hover . debug {
1203
- let hint = r. label . clone ( ) ;
1204
- let dbg_command = debug_single_command ( r) ;
1205
- group. commands . push ( to_command_link ( dbg_command, hint) ) ;
1203
+ let dbg_command = debug_single_command ( & r) ;
1204
+ group. commands . push ( to_command_link ( dbg_command, r. label ) ) ;
1206
1205
}
1207
1206
1208
1207
group
@@ -1222,7 +1221,7 @@ fn prepare_hover_actions(
1222
1221
. iter ( )
1223
1222
. filter_map ( |it| match it {
1224
1223
HoverAction :: Implementaion ( position) => show_impl_command_link ( snap, position) ,
1225
- HoverAction :: Runnable ( r) => to_runnable_action ( snap, file_id, r) ,
1224
+ HoverAction :: Runnable ( r) => to_runnable_action ( snap, file_id, r. clone ( ) ) ,
1226
1225
} )
1227
1226
. collect ( )
1228
1227
}
@@ -1232,10 +1231,7 @@ fn should_skip_target(runnable: &Runnable, cargo_spec: Option<&CargoTargetSpec>)
1232
1231
RunnableKind :: Bin => {
1233
1232
// Do not suggest binary run on other target than binary
1234
1233
match & cargo_spec {
1235
- Some ( spec) => match spec. target_kind {
1236
- TargetKind :: Bin => false ,
1237
- _ => true ,
1238
- } ,
1234
+ Some ( spec) => spec. target_kind != TargetKind :: Bin ,
1239
1235
None => true ,
1240
1236
}
1241
1237
}
0 commit comments