@@ -35,7 +35,6 @@ use triomphe::Arc;
3535use vfs:: { AbsPath , AbsPathBuf , FileId , VfsPath } ;
3636
3737use crate :: {
38- cargo_target_spec:: CargoTargetSpec ,
3938 config:: { Config , RustfmtConfig , WorkspaceSymbolConfig } ,
4039 diff:: diff,
4140 global_state:: { GlobalState , GlobalStateSnapshot } ,
@@ -50,6 +49,7 @@ use crate::{
5049 self , CrateInfoResult , ExternalDocsPair , ExternalDocsResponse , FetchDependencyListParams ,
5150 FetchDependencyListResult , PositionOrRange , ViewCrateGraphParams , WorkspaceSymbolParams ,
5251 } ,
52+ target_spec:: TargetSpec ,
5353} ;
5454
5555pub ( crate ) fn handle_workspace_reload ( state : & mut GlobalState , _: ( ) ) -> anyhow:: Result < ( ) > {
@@ -771,8 +771,8 @@ pub(crate) fn handle_parent_module(
771771 Some ( & crate_id) => crate_id,
772772 None => return Ok ( None ) ,
773773 } ;
774- let cargo_spec = match CargoTargetSpec :: for_file ( & snap, file_id) ? {
775- Some ( it ) => it,
774+ let cargo_spec = match TargetSpec :: for_file ( & snap, file_id) ? {
775+ Some ( TargetSpec :: Cargo ( it ) ) => it,
776776 None => return Ok ( None ) ,
777777 } ;
778778
@@ -804,7 +804,7 @@ pub(crate) fn handle_runnables(
804804 let file_id = from_proto:: file_id ( & snap, & params. text_document . uri ) ?;
805805 let line_index = snap. file_line_index ( file_id) ?;
806806 let offset = params. position . and_then ( |it| from_proto:: offset ( & line_index, it) . ok ( ) ) ;
807- let cargo_spec = CargoTargetSpec :: for_file ( & snap, file_id) ?;
807+ let target_spec = TargetSpec :: for_file ( & snap, file_id) ?;
808808
809809 let expect_test = match offset {
810810 Some ( offset) => {
@@ -821,7 +821,7 @@ pub(crate) fn handle_runnables(
821821 if should_skip_for_offset ( & runnable, offset) {
822822 continue ;
823823 }
824- if should_skip_target ( & runnable, cargo_spec . as_ref ( ) ) {
824+ if should_skip_target ( & runnable, target_spec . as_ref ( ) ) {
825825 continue ;
826826 }
827827 let mut runnable = to_proto:: runnable ( & snap, runnable) ?;
@@ -834,8 +834,8 @@ pub(crate) fn handle_runnables(
834834
835835 // Add `cargo check` and `cargo test` for all targets of the whole package
836836 let config = snap. config . runnables ( ) ;
837- match cargo_spec {
838- Some ( spec) => {
837+ match target_spec {
838+ Some ( TargetSpec :: Cargo ( spec) ) => {
839839 let all_targets = !snap. analysis . is_crate_no_std ( spec. crate_id ) ?;
840840 for cmd in [ "check" , "test" ] {
841841 let mut cargo_args =
@@ -1351,14 +1351,14 @@ pub(crate) fn handle_code_lens(
13511351 }
13521352
13531353 let file_id = from_proto:: file_id ( & snap, & params. text_document . uri ) ?;
1354- let cargo_target_spec = CargoTargetSpec :: for_file ( & snap, file_id) ?;
1354+ let target_spec = TargetSpec :: for_file ( & snap, file_id) ?;
13551355
13561356 let annotations = snap. analysis . annotations (
13571357 & AnnotationConfig {
1358- binary_target : cargo_target_spec
1358+ binary_target : target_spec
13591359 . map ( |spec| {
13601360 matches ! (
1361- spec. target_kind,
1361+ spec. target_kind( ) ,
13621362 TargetKind :: Bin | TargetKind :: Example | TargetKind :: Test
13631363 )
13641364 } )
@@ -1764,8 +1764,8 @@ pub(crate) fn handle_open_cargo_toml(
17641764 let _p = tracing:: span!( tracing:: Level :: INFO , "handle_open_cargo_toml" ) . entered ( ) ;
17651765 let file_id = from_proto:: file_id ( & snap, & params. text_document . uri ) ?;
17661766
1767- let cargo_spec = match CargoTargetSpec :: for_file ( & snap, file_id) ? {
1768- Some ( it ) => it,
1767+ let cargo_spec = match TargetSpec :: for_file ( & snap, file_id) ? {
1768+ Some ( TargetSpec :: Cargo ( it ) ) => it,
17691769 None => return Ok ( None ) ,
17701770 } ;
17711771
@@ -1894,8 +1894,8 @@ fn runnable_action_links(
18941894 return None ;
18951895 }
18961896
1897- let cargo_spec = CargoTargetSpec :: for_file ( snap, runnable. nav . file_id ) . ok ( ) ?;
1898- if should_skip_target ( & runnable, cargo_spec . as_ref ( ) ) {
1897+ let target_spec = TargetSpec :: for_file ( snap, runnable. nav . file_id ) . ok ( ) ?;
1898+ if should_skip_target ( & runnable, target_spec . as_ref ( ) ) {
18991899 return None ;
19001900 }
19011901
@@ -1960,13 +1960,13 @@ fn prepare_hover_actions(
19601960 . collect ( )
19611961}
19621962
1963- fn should_skip_target ( runnable : & Runnable , cargo_spec : Option < & CargoTargetSpec > ) -> bool {
1963+ fn should_skip_target ( runnable : & Runnable , cargo_spec : Option < & TargetSpec > ) -> bool {
19641964 match runnable. kind {
19651965 RunnableKind :: Bin => {
19661966 // Do not suggest binary run on other target than binary
19671967 match & cargo_spec {
19681968 Some ( spec) => !matches ! (
1969- spec. target_kind,
1969+ spec. target_kind( ) ,
19701970 TargetKind :: Bin | TargetKind :: Example | TargetKind :: Test
19711971 ) ,
19721972 None => true ,
@@ -2043,9 +2043,9 @@ fn run_rustfmt(
20432043 }
20442044 RustfmtConfig :: CustomCommand { command, args } => {
20452045 let cmd = PathBuf :: from ( & command) ;
2046- let workspace = CargoTargetSpec :: for_file ( snap, file_id) ?;
2047- let mut cmd = match workspace {
2048- Some ( spec) => {
2046+ let target_spec = TargetSpec :: for_file ( snap, file_id) ?;
2047+ let mut cmd = match target_spec {
2048+ Some ( TargetSpec :: Cargo ( spec) ) => {
20492049 // approach: if the command name contains a path separator, join it with the workspace root.
20502050 // however, if the path is absolute, joining will result in the absolute path being preserved.
20512051 // as a fallback, rely on $PATH-based discovery.
0 commit comments