@@ -19,6 +19,7 @@ use serde_json;
19
19
use crate :: actions:: progress:: ProgressUpdate ;
20
20
use rls_data:: Analysis ;
21
21
use crate :: build:: { BufWriter , BuildResult , CompilationContext , Internals , PackageArg } ;
22
+ use crate :: build:: plan:: Plan ;
22
23
use crate :: build:: environment:: { self , Environment , EnvironmentLock } ;
23
24
use crate :: config:: Config ;
24
25
use rls_vfs:: Vfs ;
@@ -119,14 +120,7 @@ fn run_cargo(
119
120
120
121
let mut restore_env = Environment :: push_with_lock ( & HashMap :: new ( ) , None , lock_guard) ;
121
122
122
- let build_dir = {
123
- let mut compilation_cx = compilation_cx. lock ( ) . unwrap ( ) ;
124
- // Since Cargo build routine will try to regenerate the unit dep graph,
125
- // we need to clear the existing dep graph.
126
- compilation_cx. build_plan . clear ( ) ;
127
-
128
- compilation_cx. build_dir . as_ref ( ) . unwrap ( ) . clone ( )
129
- } ;
123
+ let build_dir = compilation_cx. lock ( ) . unwrap ( ) . build_dir . clone ( ) . unwrap ( ) ;
130
124
131
125
// Note that this may not be equal build_dir when inside a workspace member
132
126
let manifest_path = important_paths:: find_root_manifest_for_wd ( & build_dir) ?;
@@ -147,9 +141,9 @@ fn run_cargo(
147
141
enable_nightly_features ( ) ;
148
142
let ws = Workspace :: new ( & manifest_path, & config) ?;
149
143
150
- let packages = match package_arg {
151
- PackageArg :: Unknown | PackageArg :: All => vec ! [ ] ,
152
- PackageArg :: Package ( s ) => vec ! [ s ]
144
+ let ( all , packages) = match package_arg {
145
+ PackageArg :: Default => ( false , vec ! [ ] ) ,
146
+ PackageArg :: Packages ( pkgs ) => ( false , pkgs . into_iter ( ) . collect ( ) )
153
147
} ;
154
148
155
149
// TODO: It might be feasible to keep this CargoOptions structure cached and regenerate
@@ -172,7 +166,16 @@ fn run_cargo(
172
166
( opts, rustflags, rls_config. clear_env_rust_log , rls_config. cfg_test )
173
167
} ;
174
168
175
- let spec = Packages :: from_flags ( false , Vec :: new ( ) , packages) ?;
169
+ let spec = Packages :: from_flags ( all, Vec :: new ( ) , packages) ?;
170
+
171
+ let pkg_names = spec. into_package_id_specs ( & ws) ?. iter ( )
172
+ . map ( |pkg_spec| pkg_spec. name ( ) . to_owned ( ) )
173
+ . collect ( ) ;
174
+ trace ! ( "Specified packages to be built by Cargo: {:#?}" , pkg_names) ;
175
+
176
+ // Since Cargo build routine will try to regenerate the unit dep graph,
177
+ // we need to clear the existing dep graph.
178
+ compilation_cx. lock ( ) . unwrap ( ) . build_plan = Plan :: for_packages ( pkg_names) ;
176
179
177
180
let compile_opts = CompileOptions {
178
181
spec,
@@ -330,7 +333,7 @@ impl Executor for RlsExecutor {
330
333
self . is_primary_crate ( id)
331
334
}
332
335
333
- fn exec ( & self , mut cargo_cmd : ProcessBuilder , id : & PackageId , target : & Target ) -> CargoResult < ( ) > {
336
+ fn exec ( & self , mut cargo_cmd : ProcessBuilder , id : & PackageId , target : & Target , mode : CompileMode ) -> CargoResult < ( ) > {
334
337
// Use JSON output so that we can parse the rustc output.
335
338
cargo_cmd. arg ( "--error-format=json" ) ;
336
339
// Delete any stale data. We try and remove any json files with
@@ -461,7 +464,7 @@ impl Executor for RlsExecutor {
461
464
// Cache executed command for the build plan
462
465
{
463
466
let mut cx = self . compilation_cx . lock ( ) . unwrap ( ) ;
464
- cx. build_plan . cache_compiler_job ( id, target, & cmd) ;
467
+ cx. build_plan . cache_compiler_job ( id, target, mode , & cmd) ;
465
468
}
466
469
467
470
// Prepare modified cargo-generated args/envs for future rustc calls
0 commit comments