Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Load the sysroot in all CLI commands #14239

Merged
merged 1 commit into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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