diff options
Diffstat (limited to 'crates/project_model')
-rw-r--r-- | crates/project_model/src/workspace.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/crates/project_model/src/workspace.rs b/crates/project_model/src/workspace.rs index ef0f3c9e4..c2edb3327 100644 --- a/crates/project_model/src/workspace.rs +++ b/crates/project_model/src/workspace.rs | |||
@@ -7,7 +7,7 @@ use std::{collections::VecDeque, fmt, fs, path::Path, process::Command}; | |||
7 | use anyhow::{format_err, Context, Result}; | 7 | use anyhow::{format_err, Context, Result}; |
8 | use base_db::{CrateDisplayName, CrateGraph, CrateId, CrateName, Edition, Env, FileId, ProcMacro}; | 8 | use base_db::{CrateDisplayName, CrateGraph, CrateId, CrateName, Edition, Env, FileId, ProcMacro}; |
9 | use cargo_workspace::DepKind; | 9 | use cargo_workspace::DepKind; |
10 | use cfg::CfgOptions; | 10 | use cfg::{CfgAtom, CfgDiff, CfgOptions}; |
11 | use paths::{AbsPath, AbsPathBuf}; | 11 | use paths::{AbsPath, AbsPathBuf}; |
12 | use proc_macro_api::ProcMacroClient; | 12 | use proc_macro_api::ProcMacroClient; |
13 | use rustc_hash::{FxHashMap, FxHashSet}; | 13 | use rustc_hash::{FxHashMap, FxHashSet}; |
@@ -425,6 +425,20 @@ fn cargo_to_crate_graph( | |||
425 | let mut has_private = false; | 425 | let mut has_private = false; |
426 | // Next, create crates for each package, target pair | 426 | // Next, create crates for each package, target pair |
427 | for pkg in cargo.packages() { | 427 | for pkg in cargo.packages() { |
428 | let mut cfg_options = &cfg_options; | ||
429 | let mut replaced_cfg_options; | ||
430 | if cargo[pkg].name == "core" { | ||
431 | // FIXME: in the specific case of libcore in rust-lang/rust (i.e. it is not coming from | ||
432 | // a sysroot), there's a `#![cfg(not(test))]` at the top of it that makes its contents | ||
433 | // get ignored by r-a. We should implement a more general solution for this | ||
434 | |||
435 | replaced_cfg_options = cfg_options.clone(); | ||
436 | replaced_cfg_options.apply_diff( | ||
437 | CfgDiff::new(Default::default(), vec![CfgAtom::Flag("test".into())]).unwrap(), | ||
438 | ); | ||
439 | cfg_options = &replaced_cfg_options; | ||
440 | }; | ||
441 | |||
428 | has_private |= cargo[pkg].metadata.rustc_private; | 442 | has_private |= cargo[pkg].metadata.rustc_private; |
429 | let mut lib_tgt = None; | 443 | let mut lib_tgt = None; |
430 | for &tgt in cargo[pkg].targets.iter() { | 444 | for &tgt in cargo[pkg].targets.iter() { |