@@ -35,7 +35,6 @@ use triomphe::Arc;
35
35
use vfs:: { AbsPath , AbsPathBuf , FileId , VfsPath } ;
36
36
37
37
use crate :: {
38
- cargo_target_spec:: CargoTargetSpec ,
39
38
config:: { Config , RustfmtConfig , WorkspaceSymbolConfig } ,
40
39
diff:: diff,
41
40
global_state:: { GlobalState , GlobalStateSnapshot } ,
@@ -50,6 +49,7 @@ use crate::{
50
49
self , CrateInfoResult , ExternalDocsPair , ExternalDocsResponse , FetchDependencyListParams ,
51
50
FetchDependencyListResult , PositionOrRange , ViewCrateGraphParams , WorkspaceSymbolParams ,
52
51
} ,
52
+ target_spec:: TargetSpec ,
53
53
} ;
54
54
55
55
pub ( crate ) fn handle_workspace_reload ( state : & mut GlobalState , _: ( ) ) -> anyhow:: Result < ( ) > {
@@ -771,8 +771,8 @@ pub(crate) fn handle_parent_module(
771
771
Some ( & crate_id) => crate_id,
772
772
None => return Ok ( None ) ,
773
773
} ;
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,
776
776
None => return Ok ( None ) ,
777
777
} ;
778
778
@@ -804,7 +804,7 @@ pub(crate) fn handle_runnables(
804
804
let file_id = from_proto:: file_id ( & snap, & params. text_document . uri ) ?;
805
805
let line_index = snap. file_line_index ( file_id) ?;
806
806
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) ?;
808
808
809
809
let expect_test = match offset {
810
810
Some ( offset) => {
@@ -821,7 +821,7 @@ pub(crate) fn handle_runnables(
821
821
if should_skip_for_offset ( & runnable, offset) {
822
822
continue ;
823
823
}
824
- if should_skip_target ( & runnable, cargo_spec . as_ref ( ) ) {
824
+ if should_skip_target ( & runnable, target_spec . as_ref ( ) ) {
825
825
continue ;
826
826
}
827
827
let mut runnable = to_proto:: runnable ( & snap, runnable) ?;
@@ -834,8 +834,8 @@ pub(crate) fn handle_runnables(
834
834
835
835
// Add `cargo check` and `cargo test` for all targets of the whole package
836
836
let config = snap. config . runnables ( ) ;
837
- match cargo_spec {
838
- Some ( spec) => {
837
+ match target_spec {
838
+ Some ( TargetSpec :: Cargo ( spec) ) => {
839
839
let all_targets = !snap. analysis . is_crate_no_std ( spec. crate_id ) ?;
840
840
for cmd in [ "check" , "test" ] {
841
841
let mut cargo_args =
@@ -1351,14 +1351,14 @@ pub(crate) fn handle_code_lens(
1351
1351
}
1352
1352
1353
1353
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) ?;
1355
1355
1356
1356
let annotations = snap. analysis . annotations (
1357
1357
& AnnotationConfig {
1358
- binary_target : cargo_target_spec
1358
+ binary_target : target_spec
1359
1359
. map ( |spec| {
1360
1360
matches ! (
1361
- spec. target_kind,
1361
+ spec. target_kind( ) ,
1362
1362
TargetKind :: Bin | TargetKind :: Example | TargetKind :: Test
1363
1363
)
1364
1364
} )
@@ -1764,8 +1764,8 @@ pub(crate) fn handle_open_cargo_toml(
1764
1764
let _p = tracing:: span!( tracing:: Level :: INFO , "handle_open_cargo_toml" ) . entered ( ) ;
1765
1765
let file_id = from_proto:: file_id ( & snap, & params. text_document . uri ) ?;
1766
1766
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,
1769
1769
None => return Ok ( None ) ,
1770
1770
} ;
1771
1771
@@ -1894,8 +1894,8 @@ fn runnable_action_links(
1894
1894
return None ;
1895
1895
}
1896
1896
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 ( ) ) {
1899
1899
return None ;
1900
1900
}
1901
1901
@@ -1960,13 +1960,13 @@ fn prepare_hover_actions(
1960
1960
. collect ( )
1961
1961
}
1962
1962
1963
- fn should_skip_target ( runnable : & Runnable , cargo_spec : Option < & CargoTargetSpec > ) -> bool {
1963
+ fn should_skip_target ( runnable : & Runnable , cargo_spec : Option < & TargetSpec > ) -> bool {
1964
1964
match runnable. kind {
1965
1965
RunnableKind :: Bin => {
1966
1966
// Do not suggest binary run on other target than binary
1967
1967
match & cargo_spec {
1968
1968
Some ( spec) => !matches ! (
1969
- spec. target_kind,
1969
+ spec. target_kind( ) ,
1970
1970
TargetKind :: Bin | TargetKind :: Example | TargetKind :: Test
1971
1971
) ,
1972
1972
None => true ,
@@ -2043,9 +2043,9 @@ fn run_rustfmt(
2043
2043
}
2044
2044
RustfmtConfig :: CustomCommand { command, args } => {
2045
2045
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) ) => {
2049
2049
// approach: if the command name contains a path separator, join it with the workspace root.
2050
2050
// however, if the path is absolute, joining will result in the absolute path being preserved.
2051
2051
// as a fallback, rely on $PATH-based discovery.
0 commit comments