Skip to content

Commit 224b84f

Browse files
committed
fix: Honor rust-analyzer.cargo.noDeps option when fetching sysroot metadata
1 parent 11d45c8 commit 224b84f

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

crates/project-model/src/sysroot.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ impl Sysroot {
209209
pub fn load_workspace(
210210
&self,
211211
sysroot_source_config: &RustSourceWorkspaceConfig,
212+
no_deps: bool,
212213
current_dir: &AbsPath,
213214
progress: &dyn Fn(String),
214215
) -> Option<RustLibSrcWorkspace> {
@@ -224,6 +225,7 @@ impl Sysroot {
224225
&library_manifest,
225226
current_dir,
226227
cargo_config,
228+
no_deps,
227229
progress,
228230
) {
229231
Ok(loaded) => return Some(loaded),
@@ -318,6 +320,7 @@ impl Sysroot {
318320
library_manifest: &ManifestPath,
319321
current_dir: &AbsPath,
320322
cargo_config: &CargoMetadataConfig,
323+
no_deps: bool,
321324
progress: &dyn Fn(String),
322325
) -> Result<RustLibSrcWorkspace> {
323326
tracing::debug!("Loading library metadata: {library_manifest}");
@@ -333,7 +336,7 @@ impl Sysroot {
333336
current_dir,
334337
&cargo_config,
335338
self,
336-
false,
339+
no_deps,
337340
// Make sure we never attempt to write to the sysroot
338341
true,
339342
progress,

crates/project-model/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ fn smoke_test_real_sysroot_cargo() {
240240
let cwd = AbsPathBuf::assert_utf8(temp_dir().join("smoke_test_real_sysroot_cargo"));
241241
std::fs::create_dir_all(&cwd).unwrap();
242242
let loaded_sysroot =
243-
sysroot.load_workspace(&RustSourceWorkspaceConfig::default_cargo(), &cwd, &|_| ());
243+
sysroot.load_workspace(&RustSourceWorkspaceConfig::default_cargo(), false, &cwd, &|_| ());
244244
if let Some(loaded_sysroot) = loaded_sysroot {
245245
sysroot.set_workspace(loaded_sysroot);
246246
}

crates/project-model/src/workspace.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ impl ProjectWorkspace {
391391
toolchain.clone(),
392392
target_dir.clone(),
393393
)),
394+
config.no_deps,
394395
workspace_dir,
395396
progress,
396397
)
@@ -499,6 +500,7 @@ impl ProjectWorkspace {
499500
if let Some(sysroot_project) = sysroot_project {
500501
sysroot.load_workspace(
501502
&RustSourceWorkspaceConfig::Json(*sysroot_project),
503+
config.no_deps,
502504
project_root,
503505
progress,
504506
)
@@ -510,6 +512,7 @@ impl ProjectWorkspace {
510512
toolchain.clone(),
511513
target_dir,
512514
)),
515+
config.no_deps,
513516
project_root,
514517
progress,
515518
)
@@ -570,6 +573,7 @@ impl ProjectWorkspace {
570573
toolchain.clone(),
571574
target_dir.clone(),
572575
)),
576+
config.no_deps,
573577
dir,
574578
&|_| (),
575579
);

crates/rust-analyzer/src/cli/rustc_tests.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,12 @@ impl Tester {
7575
};
7676

7777
let mut sysroot = Sysroot::discover(tmp_file.parent().unwrap(), &cargo_config.extra_env);
78-
let loaded_sysroot =
79-
sysroot.load_workspace(&RustSourceWorkspaceConfig::default_cargo(), &path, &|_| ());
78+
let loaded_sysroot = sysroot.load_workspace(
79+
&RustSourceWorkspaceConfig::default_cargo(),
80+
false,
81+
&path,
82+
&|_| (),
83+
);
8084
if let Some(loaded_sysroot) = loaded_sysroot {
8185
sysroot.set_workspace(loaded_sysroot);
8286
}

0 commit comments

Comments
 (0)