Skip to content

Commit

Permalink
Auto merge of rust-lang#14239 - Veykril:sysroot-cli, r=Veykril
Browse files Browse the repository at this point in the history
fix: Load the sysroot in all CLI commands
  • Loading branch information
bors committed Mar 3, 2023
2 parents c229a83 + 80ddfb8 commit a8d3c46
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
4 changes: 3 additions & 1 deletion crates/rust-analyzer/src/cli/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Analyze all modules in a project for diagnostics. Exits with a non-zero
//! status code if any errors are found.
use project_model::{CargoConfig, RustcSource};
use rustc_hash::FxHashSet;

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

impl flags::Diagnostics {
pub fn run(self) -> anyhow::Result<()> {
let cargo_config = Default::default();
let mut cargo_config = CargoConfig::default();
cargo_config.sysroot = Some(RustcSource::Discover);
let load_cargo_config = LoadCargoConfig {
load_out_dirs_from_check: !self.disable_build_scripts,
with_proc_macro_server: ProcMacroServerChoice::Sysroot,
Expand Down
5 changes: 3 additions & 2 deletions crates/rust-analyzer/src/cli/lsif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use ide_db::LineIndexDatabase;
use ide_db::base_db::salsa::{self, ParallelDatabase};
use ide_db::line_index::WideEncoding;
use lsp_types::{self, lsif};
use project_model::{CargoConfig, ProjectManifest, ProjectWorkspace};
use project_model::{CargoConfig, ProjectManifest, ProjectWorkspace, RustcSource};
use vfs::{AbsPathBuf, Vfs};

use crate::cli::load_cargo::ProcMacroServerChoice;
Expand Down Expand Up @@ -289,7 +289,8 @@ impl flags::Lsif {
pub fn run(self) -> Result<()> {
eprintln!("Generating LSIF started...");
let now = Instant::now();
let cargo_config = CargoConfig::default();
let mut cargo_config = CargoConfig::default();
cargo_config.sysroot = Some(RustcSource::Discover);
let no_progress = &|_| ();
let load_cargo_config = LoadCargoConfig {
load_out_dirs_from_check: true,
Expand Down
5 changes: 3 additions & 2 deletions crates/rust-analyzer/src/cli/scip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use ide::{
TokenStaticData,
};
use ide_db::LineIndexDatabase;
use project_model::{CargoConfig, ProjectManifest, ProjectWorkspace};
use project_model::{CargoConfig, ProjectManifest, ProjectWorkspace, RustcSource};
use scip::types as scip_types;
use std::env;

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

let no_progress = &|s| (eprintln!("rust-analyzer: Loading {s}"));
let load_cargo_config = LoadCargoConfig {
Expand Down
5 changes: 3 additions & 2 deletions crates/rust-analyzer/src/cli/ssr.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Applies structured search replace rules from the command line.
use ide_ssr::MatchFinder;
use project_model::CargoConfig;
use project_model::{CargoConfig, RustcSource};

use crate::cli::{
flags,
Expand All @@ -12,7 +12,8 @@ use crate::cli::{
impl flags::Ssr {
pub fn run(self) -> Result<()> {
use ide_db::base_db::SourceDatabaseExt;
let cargo_config = CargoConfig::default();
let mut cargo_config = CargoConfig::default();
cargo_config.sysroot = Some(RustcSource::Discover);
let load_cargo_config = LoadCargoConfig {
load_out_dirs_from_check: true,
with_proc_macro_server: ProcMacroServerChoice::Sysroot,
Expand Down

0 comments on commit a8d3c46

Please sign in to comment.