Skip to content

Commit a8d3c46

Browse files
committed
Auto merge of #14239 - Veykril:sysroot-cli, r=Veykril
fix: Load the sysroot in all CLI commands
2 parents c229a83 + 80ddfb8 commit a8d3c46

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Analyze all modules in a project for diagnostics. Exits with a non-zero
22
//! status code if any errors are found.
33
4+
use project_model::{CargoConfig, RustcSource};
45
use rustc_hash::FxHashSet;
56

67
use hir::{db::HirDatabase, Crate, Module};
@@ -14,7 +15,8 @@ use crate::cli::{
1415

1516
impl flags::Diagnostics {
1617
pub fn run(self) -> anyhow::Result<()> {
17-
let cargo_config = Default::default();
18+
let mut cargo_config = CargoConfig::default();
19+
cargo_config.sysroot = Some(RustcSource::Discover);
1820
let load_cargo_config = LoadCargoConfig {
1921
load_out_dirs_from_check: !self.disable_build_scripts,
2022
with_proc_macro_server: ProcMacroServerChoice::Sysroot,

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use ide_db::LineIndexDatabase;
1313
use ide_db::base_db::salsa::{self, ParallelDatabase};
1414
use ide_db::line_index::WideEncoding;
1515
use lsp_types::{self, lsif};
16-
use project_model::{CargoConfig, ProjectManifest, ProjectWorkspace};
16+
use project_model::{CargoConfig, ProjectManifest, ProjectWorkspace, RustcSource};
1717
use vfs::{AbsPathBuf, Vfs};
1818

1919
use crate::cli::load_cargo::ProcMacroServerChoice;
@@ -289,7 +289,8 @@ impl flags::Lsif {
289289
pub fn run(self) -> Result<()> {
290290
eprintln!("Generating LSIF started...");
291291
let now = Instant::now();
292-
let cargo_config = CargoConfig::default();
292+
let mut cargo_config = CargoConfig::default();
293+
cargo_config.sysroot = Some(RustcSource::Discover);
293294
let no_progress = &|_| ();
294295
let load_cargo_config = LoadCargoConfig {
295296
load_out_dirs_from_check: true,

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use ide::{
1515
TokenStaticData,
1616
};
1717
use ide_db::LineIndexDatabase;
18-
use project_model::{CargoConfig, ProjectManifest, ProjectWorkspace};
18+
use project_model::{CargoConfig, ProjectManifest, ProjectWorkspace, RustcSource};
1919
use scip::types as scip_types;
2020
use std::env;
2121

@@ -29,7 +29,8 @@ impl flags::Scip {
2929
pub fn run(self) -> Result<()> {
3030
eprintln!("Generating SCIP start...");
3131
let now = Instant::now();
32-
let cargo_config = CargoConfig::default();
32+
let mut cargo_config = CargoConfig::default();
33+
cargo_config.sysroot = Some(RustcSource::Discover);
3334

3435
let no_progress = &|s| (eprintln!("rust-analyzer: Loading {s}"));
3536
let load_cargo_config = LoadCargoConfig {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Applies structured search replace rules from the command line.
22
33
use ide_ssr::MatchFinder;
4-
use project_model::CargoConfig;
4+
use project_model::{CargoConfig, RustcSource};
55

66
use crate::cli::{
77
flags,
@@ -12,7 +12,8 @@ use crate::cli::{
1212
impl flags::Ssr {
1313
pub fn run(self) -> Result<()> {
1414
use ide_db::base_db::SourceDatabaseExt;
15-
let cargo_config = CargoConfig::default();
15+
let mut cargo_config = CargoConfig::default();
16+
cargo_config.sysroot = Some(RustcSource::Discover);
1617
let load_cargo_config = LoadCargoConfig {
1718
load_out_dirs_from_check: true,
1819
with_proc_macro_server: ProcMacroServerChoice::Sysroot,

0 commit comments

Comments
 (0)