Merge pull request #20148 from ShoyuVanilla/sysroot-no-deps

fix: Honor `rust-analyzer.cargo.noDeps` option when fetching sysroot metadata
This commit is contained in:
Lukas Wirth 2025-07-04 08:03:25 +00:00 committed by GitHub
commit 4183bcdcde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 4 deletions

View file

@ -209,6 +209,7 @@ impl Sysroot {
pub fn load_workspace(
&self,
sysroot_source_config: &RustSourceWorkspaceConfig,
no_deps: bool,
current_dir: &AbsPath,
progress: &dyn Fn(String),
) -> Option<RustLibSrcWorkspace> {
@ -224,6 +225,7 @@ impl Sysroot {
&library_manifest,
current_dir,
cargo_config,
no_deps,
progress,
) {
Ok(loaded) => return Some(loaded),
@ -318,6 +320,7 @@ impl Sysroot {
library_manifest: &ManifestPath,
current_dir: &AbsPath,
cargo_config: &CargoMetadataConfig,
no_deps: bool,
progress: &dyn Fn(String),
) -> Result<RustLibSrcWorkspace> {
tracing::debug!("Loading library metadata: {library_manifest}");
@ -333,7 +336,7 @@ impl Sysroot {
current_dir,
&cargo_config,
self,
false,
no_deps,
// Make sure we never attempt to write to the sysroot
true,
progress,

View file

@ -240,7 +240,7 @@ fn smoke_test_real_sysroot_cargo() {
let cwd = AbsPathBuf::assert_utf8(temp_dir().join("smoke_test_real_sysroot_cargo"));
std::fs::create_dir_all(&cwd).unwrap();
let loaded_sysroot =
sysroot.load_workspace(&RustSourceWorkspaceConfig::default_cargo(), &cwd, &|_| ());
sysroot.load_workspace(&RustSourceWorkspaceConfig::default_cargo(), false, &cwd, &|_| ());
if let Some(loaded_sysroot) = loaded_sysroot {
sysroot.set_workspace(loaded_sysroot);
}

View file

@ -391,6 +391,7 @@ impl ProjectWorkspace {
toolchain.clone(),
target_dir.clone(),
)),
config.no_deps,
workspace_dir,
progress,
)
@ -499,6 +500,7 @@ impl ProjectWorkspace {
if let Some(sysroot_project) = sysroot_project {
sysroot.load_workspace(
&RustSourceWorkspaceConfig::Json(*sysroot_project),
config.no_deps,
project_root,
progress,
)
@ -510,6 +512,7 @@ impl ProjectWorkspace {
toolchain.clone(),
target_dir,
)),
config.no_deps,
project_root,
progress,
)
@ -570,6 +573,7 @@ impl ProjectWorkspace {
toolchain.clone(),
target_dir.clone(),
)),
config.no_deps,
dir,
&|_| (),
);