@@ -404,7 +404,7 @@ pub fn handle_runnables(
404404 continue ;
405405 }
406406 }
407- if is_lib_target ( & runnable, cargo_spec. as_ref ( ) ) {
407+ if should_skip_target ( & runnable, cargo_spec. as_ref ( ) ) {
408408 continue ;
409409 }
410410
@@ -812,7 +812,7 @@ pub fn handle_code_lens(
812812 if snap. config . lens . runnable ( ) {
813813 // Gather runnables
814814 for runnable in snap. analysis ( ) . runnables ( file_id) ? {
815- if is_lib_target ( & runnable, cargo_spec. as_ref ( ) ) {
815+ if should_skip_target ( & runnable, cargo_spec. as_ref ( ) ) {
816816 continue ;
817817 }
818818
@@ -1185,6 +1185,11 @@ fn to_runnable_action(
11851185 file_id : FileId ,
11861186 runnable : & Runnable ,
11871187) -> Option < lsp_ext:: CommandLinkGroup > {
1188+ let cargo_spec = CargoTargetSpec :: for_file ( & snap, file_id) . ok ( ) ?;
1189+ if should_skip_target ( runnable, cargo_spec. as_ref ( ) ) {
1190+ return None ;
1191+ }
1192+
11881193 to_proto:: runnable ( snap, file_id, runnable) . ok ( ) . map ( |r| {
11891194 let mut group = lsp_ext:: CommandLinkGroup :: default ( ) ;
11901195
@@ -1222,16 +1227,18 @@ fn prepare_hover_actions(
12221227 . collect ( )
12231228}
12241229
1225- fn is_lib_target ( runnable : & Runnable , cargo_spec : Option < & CargoTargetSpec > ) -> bool {
1226- // Do not suggest binary run on other target than binary
1227- if let RunnableKind :: Bin = runnable. kind {
1228- if let Some ( spec) = cargo_spec {
1229- match spec. target_kind {
1230- TargetKind :: Bin => return true ,
1231- _ => ( ) ,
1230+ fn should_skip_target ( runnable : & Runnable , cargo_spec : Option < & CargoTargetSpec > ) -> bool {
1231+ match runnable. kind {
1232+ RunnableKind :: Bin => {
1233+ // Do not suggest binary run on other target than binary
1234+ match & cargo_spec {
1235+ Some ( spec) => match spec. target_kind {
1236+ TargetKind :: Bin => false ,
1237+ _ => true ,
1238+ } ,
1239+ None => true ,
12321240 }
12331241 }
1242+ _ => false ,
12341243 }
1235-
1236- false
12371244}
0 commit comments