mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
Merge #10005
10005: Extend `CargoConfig.unset_test_crates` r=matklad a=regexident This is to allow for efficiently disabling `#[cfg(test)]` on all crates (by passing `unset_test_crates: UnsetTestCrates::All`) without having to first load the crate graph, when using rust-analyzer as a library. (FYI: The change doesn't seem to be covered by any existing tests.) Co-authored-by: Vincent Esche <regexident@gmail.com>
This commit is contained in:
commit
1636f61a15
5 changed files with 972 additions and 15 deletions
|
@ -57,6 +57,20 @@ pub enum RustcSource {
|
||||||
Discover,
|
Discover,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Crates to disable `#[cfg(test)]` on.
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
|
pub enum UnsetTestCrates {
|
||||||
|
None,
|
||||||
|
Only(Vec<String>),
|
||||||
|
All,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for UnsetTestCrates {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default, Clone, Debug, PartialEq, Eq)]
|
#[derive(Default, Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct CargoConfig {
|
pub struct CargoConfig {
|
||||||
/// Do not activate the `default` feature.
|
/// Do not activate the `default` feature.
|
||||||
|
@ -80,20 +94,29 @@ pub struct CargoConfig {
|
||||||
pub rustc_source: Option<RustcSource>,
|
pub rustc_source: Option<RustcSource>,
|
||||||
|
|
||||||
/// crates to disable `#[cfg(test)]` on
|
/// crates to disable `#[cfg(test)]` on
|
||||||
pub unset_test_crates: Vec<String>,
|
pub unset_test_crates: UnsetTestCrates,
|
||||||
|
|
||||||
pub wrap_rustc_in_build_scripts: bool,
|
pub wrap_rustc_in_build_scripts: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CargoConfig {
|
impl CargoConfig {
|
||||||
pub fn cfg_overrides(&self) -> CfgOverrides {
|
pub fn cfg_overrides(&self) -> CfgOverrides {
|
||||||
self.unset_test_crates
|
match &self.unset_test_crates {
|
||||||
.iter()
|
UnsetTestCrates::None => CfgOverrides::Selective(iter::empty().collect()),
|
||||||
.cloned()
|
UnsetTestCrates::Only(unset_test_crates) => CfgOverrides::Selective(
|
||||||
.zip(iter::repeat_with(|| {
|
unset_test_crates
|
||||||
cfg::CfgDiff::new(Vec::new(), vec![cfg::CfgAtom::Flag("test".into())]).unwrap()
|
.iter()
|
||||||
}))
|
.map(|name| name.clone())
|
||||||
.collect()
|
.zip(iter::repeat_with(|| {
|
||||||
|
cfg::CfgDiff::new(Vec::new(), vec![cfg::CfgAtom::Flag("test".into())])
|
||||||
|
.unwrap()
|
||||||
|
}))
|
||||||
|
.collect(),
|
||||||
|
),
|
||||||
|
UnsetTestCrates::All => CfgOverrides::Wildcard(
|
||||||
|
cfg::CfgDiff::new(Vec::new(), vec![cfg::CfgAtom::Flag("test".into())]).unwrap(),
|
||||||
|
),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub use crate::{
|
||||||
build_scripts::WorkspaceBuildScripts,
|
build_scripts::WorkspaceBuildScripts,
|
||||||
cargo_workspace::{
|
cargo_workspace::{
|
||||||
CargoConfig, CargoWorkspace, Package, PackageData, PackageDependency, RustcSource, Target,
|
CargoConfig, CargoWorkspace, Package, PackageData, PackageDependency, RustcSource, Target,
|
||||||
TargetData, TargetKind,
|
TargetData, TargetKind, UnsetTestCrates,
|
||||||
},
|
},
|
||||||
manifest_path::ManifestPath,
|
manifest_path::ManifestPath,
|
||||||
project_json::{ProjectJson, ProjectJsonData},
|
project_json::{ProjectJson, ProjectJsonData},
|
||||||
|
|
|
@ -4,6 +4,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use base_db::{CrateGraph, FileId};
|
use base_db::{CrateGraph, FileId};
|
||||||
|
use cfg::{CfgAtom, CfgDiff};
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::{expect, Expect};
|
||||||
use paths::{AbsPath, AbsPathBuf};
|
use paths::{AbsPath, AbsPathBuf};
|
||||||
use serde::de::DeserializeOwned;
|
use serde::de::DeserializeOwned;
|
||||||
|
@ -14,6 +15,10 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
fn load_cargo(file: &str) -> CrateGraph {
|
fn load_cargo(file: &str) -> CrateGraph {
|
||||||
|
load_cargo_with_overrides(file, CfgOverrides::default())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn load_cargo_with_overrides(file: &str, cfg_overrides: CfgOverrides) -> CrateGraph {
|
||||||
let meta = get_test_json_file(file);
|
let meta = get_test_json_file(file);
|
||||||
let cargo_workspace = CargoWorkspace::new(meta);
|
let cargo_workspace = CargoWorkspace::new(meta);
|
||||||
let project_workspace = ProjectWorkspace::Cargo {
|
let project_workspace = ProjectWorkspace::Cargo {
|
||||||
|
@ -22,7 +27,7 @@ fn load_cargo(file: &str) -> CrateGraph {
|
||||||
sysroot: None,
|
sysroot: None,
|
||||||
rustc: None,
|
rustc: None,
|
||||||
rustc_cfg: Vec::new(),
|
rustc_cfg: Vec::new(),
|
||||||
cfg_overrides: CfgOverrides::default(),
|
cfg_overrides,
|
||||||
};
|
};
|
||||||
to_crate_graph(project_workspace)
|
to_crate_graph(project_workspace)
|
||||||
}
|
}
|
||||||
|
@ -99,6 +104,902 @@ fn check_crate_graph(crate_graph: CrateGraph, expect: Expect) {
|
||||||
expect.assert_eq(&crate_graph);
|
expect.assert_eq(&crate_graph);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn cargo_hello_world_project_model_with_wildcard_overrides() {
|
||||||
|
let cfg_overrides = CfgOverrides::Wildcard(
|
||||||
|
CfgDiff::new(Vec::new(), vec![CfgAtom::Flag("test".into())]).unwrap(),
|
||||||
|
);
|
||||||
|
let crate_graph = load_cargo_with_overrides("hello-world-metadata.json", cfg_overrides);
|
||||||
|
check_crate_graph(
|
||||||
|
crate_graph,
|
||||||
|
expect![[r#"
|
||||||
|
CrateGraph {
|
||||||
|
arena: {
|
||||||
|
CrateId(
|
||||||
|
0,
|
||||||
|
): CrateData {
|
||||||
|
root_file_id: FileId(
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
edition: Edition2018,
|
||||||
|
display_name: Some(
|
||||||
|
CrateDisplayName {
|
||||||
|
crate_name: CrateName(
|
||||||
|
"hello_world",
|
||||||
|
),
|
||||||
|
canonical_name: "hello-world",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
potential_cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
env: Env {
|
||||||
|
entries: {
|
||||||
|
"CARGO_PKG_LICENSE": "",
|
||||||
|
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||||
|
"CARGO_MANIFEST_DIR": "$ROOT$hello-world",
|
||||||
|
"CARGO_PKG_VERSION": "0.1.0",
|
||||||
|
"CARGO_PKG_AUTHORS": "",
|
||||||
|
"CARGO_CRATE_NAME": "hello_world",
|
||||||
|
"CARGO_PKG_LICENSE_FILE": "",
|
||||||
|
"CARGO_PKG_HOMEPAGE": "",
|
||||||
|
"CARGO_PKG_DESCRIPTION": "",
|
||||||
|
"CARGO_PKG_NAME": "hello-world",
|
||||||
|
"CARGO_PKG_VERSION_PATCH": "0",
|
||||||
|
"CARGO": "cargo",
|
||||||
|
"CARGO_PKG_REPOSITORY": "",
|
||||||
|
"CARGO_PKG_VERSION_MINOR": "1",
|
||||||
|
"CARGO_PKG_VERSION_PRE": "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dependencies: [
|
||||||
|
Dependency {
|
||||||
|
crate_id: CrateId(
|
||||||
|
4,
|
||||||
|
),
|
||||||
|
name: CrateName(
|
||||||
|
"libc",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
proc_macro: [],
|
||||||
|
},
|
||||||
|
CrateId(
|
||||||
|
5,
|
||||||
|
): CrateData {
|
||||||
|
root_file_id: FileId(
|
||||||
|
6,
|
||||||
|
),
|
||||||
|
edition: Edition2015,
|
||||||
|
display_name: Some(
|
||||||
|
CrateDisplayName {
|
||||||
|
crate_name: CrateName(
|
||||||
|
"const_fn",
|
||||||
|
),
|
||||||
|
canonical_name: "const_fn",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"feature=default",
|
||||||
|
"feature=std",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
potential_cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"feature=align",
|
||||||
|
"feature=const-extern-fn",
|
||||||
|
"feature=default",
|
||||||
|
"feature=extra_traits",
|
||||||
|
"feature=rustc-dep-of-std",
|
||||||
|
"feature=std",
|
||||||
|
"feature=use_std",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
env: Env {
|
||||||
|
entries: {
|
||||||
|
"CARGO_PKG_LICENSE": "",
|
||||||
|
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||||
|
"CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98",
|
||||||
|
"CARGO_PKG_VERSION": "0.2.98",
|
||||||
|
"CARGO_PKG_AUTHORS": "",
|
||||||
|
"CARGO_CRATE_NAME": "libc",
|
||||||
|
"CARGO_PKG_LICENSE_FILE": "",
|
||||||
|
"CARGO_PKG_HOMEPAGE": "",
|
||||||
|
"CARGO_PKG_DESCRIPTION": "",
|
||||||
|
"CARGO_PKG_NAME": "libc",
|
||||||
|
"CARGO_PKG_VERSION_PATCH": "98",
|
||||||
|
"CARGO": "cargo",
|
||||||
|
"CARGO_PKG_REPOSITORY": "",
|
||||||
|
"CARGO_PKG_VERSION_MINOR": "2",
|
||||||
|
"CARGO_PKG_VERSION_PRE": "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dependencies: [
|
||||||
|
Dependency {
|
||||||
|
crate_id: CrateId(
|
||||||
|
4,
|
||||||
|
),
|
||||||
|
name: CrateName(
|
||||||
|
"libc",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
proc_macro: [],
|
||||||
|
},
|
||||||
|
CrateId(
|
||||||
|
2,
|
||||||
|
): CrateData {
|
||||||
|
root_file_id: FileId(
|
||||||
|
3,
|
||||||
|
),
|
||||||
|
edition: Edition2018,
|
||||||
|
display_name: Some(
|
||||||
|
CrateDisplayName {
|
||||||
|
crate_name: CrateName(
|
||||||
|
"an_example",
|
||||||
|
),
|
||||||
|
canonical_name: "an-example",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
potential_cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
env: Env {
|
||||||
|
entries: {
|
||||||
|
"CARGO_PKG_LICENSE": "",
|
||||||
|
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||||
|
"CARGO_MANIFEST_DIR": "$ROOT$hello-world",
|
||||||
|
"CARGO_PKG_VERSION": "0.1.0",
|
||||||
|
"CARGO_PKG_AUTHORS": "",
|
||||||
|
"CARGO_CRATE_NAME": "hello_world",
|
||||||
|
"CARGO_PKG_LICENSE_FILE": "",
|
||||||
|
"CARGO_PKG_HOMEPAGE": "",
|
||||||
|
"CARGO_PKG_DESCRIPTION": "",
|
||||||
|
"CARGO_PKG_NAME": "hello-world",
|
||||||
|
"CARGO_PKG_VERSION_PATCH": "0",
|
||||||
|
"CARGO": "cargo",
|
||||||
|
"CARGO_PKG_REPOSITORY": "",
|
||||||
|
"CARGO_PKG_VERSION_MINOR": "1",
|
||||||
|
"CARGO_PKG_VERSION_PRE": "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dependencies: [
|
||||||
|
Dependency {
|
||||||
|
crate_id: CrateId(
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
name: CrateName(
|
||||||
|
"hello_world",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
Dependency {
|
||||||
|
crate_id: CrateId(
|
||||||
|
4,
|
||||||
|
),
|
||||||
|
name: CrateName(
|
||||||
|
"libc",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
proc_macro: [],
|
||||||
|
},
|
||||||
|
CrateId(
|
||||||
|
4,
|
||||||
|
): CrateData {
|
||||||
|
root_file_id: FileId(
|
||||||
|
5,
|
||||||
|
),
|
||||||
|
edition: Edition2015,
|
||||||
|
display_name: Some(
|
||||||
|
CrateDisplayName {
|
||||||
|
crate_name: CrateName(
|
||||||
|
"libc",
|
||||||
|
),
|
||||||
|
canonical_name: "libc",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"feature=default",
|
||||||
|
"feature=std",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
potential_cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"feature=align",
|
||||||
|
"feature=const-extern-fn",
|
||||||
|
"feature=default",
|
||||||
|
"feature=extra_traits",
|
||||||
|
"feature=rustc-dep-of-std",
|
||||||
|
"feature=std",
|
||||||
|
"feature=use_std",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
env: Env {
|
||||||
|
entries: {
|
||||||
|
"CARGO_PKG_LICENSE": "",
|
||||||
|
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||||
|
"CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98",
|
||||||
|
"CARGO_PKG_VERSION": "0.2.98",
|
||||||
|
"CARGO_PKG_AUTHORS": "",
|
||||||
|
"CARGO_CRATE_NAME": "libc",
|
||||||
|
"CARGO_PKG_LICENSE_FILE": "",
|
||||||
|
"CARGO_PKG_HOMEPAGE": "",
|
||||||
|
"CARGO_PKG_DESCRIPTION": "",
|
||||||
|
"CARGO_PKG_NAME": "libc",
|
||||||
|
"CARGO_PKG_VERSION_PATCH": "98",
|
||||||
|
"CARGO": "cargo",
|
||||||
|
"CARGO_PKG_REPOSITORY": "",
|
||||||
|
"CARGO_PKG_VERSION_MINOR": "2",
|
||||||
|
"CARGO_PKG_VERSION_PRE": "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dependencies: [],
|
||||||
|
proc_macro: [],
|
||||||
|
},
|
||||||
|
CrateId(
|
||||||
|
1,
|
||||||
|
): CrateData {
|
||||||
|
root_file_id: FileId(
|
||||||
|
2,
|
||||||
|
),
|
||||||
|
edition: Edition2018,
|
||||||
|
display_name: Some(
|
||||||
|
CrateDisplayName {
|
||||||
|
crate_name: CrateName(
|
||||||
|
"hello_world",
|
||||||
|
),
|
||||||
|
canonical_name: "hello-world",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
potential_cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
env: Env {
|
||||||
|
entries: {
|
||||||
|
"CARGO_PKG_LICENSE": "",
|
||||||
|
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||||
|
"CARGO_MANIFEST_DIR": "$ROOT$hello-world",
|
||||||
|
"CARGO_PKG_VERSION": "0.1.0",
|
||||||
|
"CARGO_PKG_AUTHORS": "",
|
||||||
|
"CARGO_CRATE_NAME": "hello_world",
|
||||||
|
"CARGO_PKG_LICENSE_FILE": "",
|
||||||
|
"CARGO_PKG_HOMEPAGE": "",
|
||||||
|
"CARGO_PKG_DESCRIPTION": "",
|
||||||
|
"CARGO_PKG_NAME": "hello-world",
|
||||||
|
"CARGO_PKG_VERSION_PATCH": "0",
|
||||||
|
"CARGO": "cargo",
|
||||||
|
"CARGO_PKG_REPOSITORY": "",
|
||||||
|
"CARGO_PKG_VERSION_MINOR": "1",
|
||||||
|
"CARGO_PKG_VERSION_PRE": "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dependencies: [
|
||||||
|
Dependency {
|
||||||
|
crate_id: CrateId(
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
name: CrateName(
|
||||||
|
"hello_world",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
Dependency {
|
||||||
|
crate_id: CrateId(
|
||||||
|
4,
|
||||||
|
),
|
||||||
|
name: CrateName(
|
||||||
|
"libc",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
proc_macro: [],
|
||||||
|
},
|
||||||
|
CrateId(
|
||||||
|
6,
|
||||||
|
): CrateData {
|
||||||
|
root_file_id: FileId(
|
||||||
|
7,
|
||||||
|
),
|
||||||
|
edition: Edition2015,
|
||||||
|
display_name: Some(
|
||||||
|
CrateDisplayName {
|
||||||
|
crate_name: CrateName(
|
||||||
|
"build_script_build",
|
||||||
|
),
|
||||||
|
canonical_name: "build-script-build",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"feature=default",
|
||||||
|
"feature=std",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
potential_cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"feature=align",
|
||||||
|
"feature=const-extern-fn",
|
||||||
|
"feature=default",
|
||||||
|
"feature=extra_traits",
|
||||||
|
"feature=rustc-dep-of-std",
|
||||||
|
"feature=std",
|
||||||
|
"feature=use_std",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
env: Env {
|
||||||
|
entries: {
|
||||||
|
"CARGO_PKG_LICENSE": "",
|
||||||
|
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||||
|
"CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98",
|
||||||
|
"CARGO_PKG_VERSION": "0.2.98",
|
||||||
|
"CARGO_PKG_AUTHORS": "",
|
||||||
|
"CARGO_CRATE_NAME": "libc",
|
||||||
|
"CARGO_PKG_LICENSE_FILE": "",
|
||||||
|
"CARGO_PKG_HOMEPAGE": "",
|
||||||
|
"CARGO_PKG_DESCRIPTION": "",
|
||||||
|
"CARGO_PKG_NAME": "libc",
|
||||||
|
"CARGO_PKG_VERSION_PATCH": "98",
|
||||||
|
"CARGO": "cargo",
|
||||||
|
"CARGO_PKG_REPOSITORY": "",
|
||||||
|
"CARGO_PKG_VERSION_MINOR": "2",
|
||||||
|
"CARGO_PKG_VERSION_PRE": "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dependencies: [],
|
||||||
|
proc_macro: [],
|
||||||
|
},
|
||||||
|
CrateId(
|
||||||
|
3,
|
||||||
|
): CrateData {
|
||||||
|
root_file_id: FileId(
|
||||||
|
4,
|
||||||
|
),
|
||||||
|
edition: Edition2018,
|
||||||
|
display_name: Some(
|
||||||
|
CrateDisplayName {
|
||||||
|
crate_name: CrateName(
|
||||||
|
"it",
|
||||||
|
),
|
||||||
|
canonical_name: "it",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
potential_cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
env: Env {
|
||||||
|
entries: {
|
||||||
|
"CARGO_PKG_LICENSE": "",
|
||||||
|
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||||
|
"CARGO_MANIFEST_DIR": "$ROOT$hello-world",
|
||||||
|
"CARGO_PKG_VERSION": "0.1.0",
|
||||||
|
"CARGO_PKG_AUTHORS": "",
|
||||||
|
"CARGO_CRATE_NAME": "hello_world",
|
||||||
|
"CARGO_PKG_LICENSE_FILE": "",
|
||||||
|
"CARGO_PKG_HOMEPAGE": "",
|
||||||
|
"CARGO_PKG_DESCRIPTION": "",
|
||||||
|
"CARGO_PKG_NAME": "hello-world",
|
||||||
|
"CARGO_PKG_VERSION_PATCH": "0",
|
||||||
|
"CARGO": "cargo",
|
||||||
|
"CARGO_PKG_REPOSITORY": "",
|
||||||
|
"CARGO_PKG_VERSION_MINOR": "1",
|
||||||
|
"CARGO_PKG_VERSION_PRE": "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dependencies: [
|
||||||
|
Dependency {
|
||||||
|
crate_id: CrateId(
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
name: CrateName(
|
||||||
|
"hello_world",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
Dependency {
|
||||||
|
crate_id: CrateId(
|
||||||
|
4,
|
||||||
|
),
|
||||||
|
name: CrateName(
|
||||||
|
"libc",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
proc_macro: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}"#]],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn cargo_hello_world_project_model_with_selective_overrides() {
|
||||||
|
let cfg_overrides = {
|
||||||
|
CfgOverrides::Selective(
|
||||||
|
std::iter::once((
|
||||||
|
"libc".to_owned(),
|
||||||
|
CfgDiff::new(Vec::new(), vec![CfgAtom::Flag("test".into())]).unwrap(),
|
||||||
|
))
|
||||||
|
.collect(),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
let crate_graph = load_cargo_with_overrides("hello-world-metadata.json", cfg_overrides);
|
||||||
|
check_crate_graph(
|
||||||
|
crate_graph,
|
||||||
|
expect![[r#"
|
||||||
|
CrateGraph {
|
||||||
|
arena: {
|
||||||
|
CrateId(
|
||||||
|
0,
|
||||||
|
): CrateData {
|
||||||
|
root_file_id: FileId(
|
||||||
|
1,
|
||||||
|
),
|
||||||
|
edition: Edition2018,
|
||||||
|
display_name: Some(
|
||||||
|
CrateDisplayName {
|
||||||
|
crate_name: CrateName(
|
||||||
|
"hello_world",
|
||||||
|
),
|
||||||
|
canonical_name: "hello-world",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"test",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
potential_cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"test",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
env: Env {
|
||||||
|
entries: {
|
||||||
|
"CARGO_PKG_LICENSE": "",
|
||||||
|
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||||
|
"CARGO_MANIFEST_DIR": "$ROOT$hello-world",
|
||||||
|
"CARGO_PKG_VERSION": "0.1.0",
|
||||||
|
"CARGO_PKG_AUTHORS": "",
|
||||||
|
"CARGO_CRATE_NAME": "hello_world",
|
||||||
|
"CARGO_PKG_LICENSE_FILE": "",
|
||||||
|
"CARGO_PKG_HOMEPAGE": "",
|
||||||
|
"CARGO_PKG_DESCRIPTION": "",
|
||||||
|
"CARGO_PKG_NAME": "hello-world",
|
||||||
|
"CARGO_PKG_VERSION_PATCH": "0",
|
||||||
|
"CARGO": "cargo",
|
||||||
|
"CARGO_PKG_REPOSITORY": "",
|
||||||
|
"CARGO_PKG_VERSION_MINOR": "1",
|
||||||
|
"CARGO_PKG_VERSION_PRE": "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dependencies: [
|
||||||
|
Dependency {
|
||||||
|
crate_id: CrateId(
|
||||||
|
4,
|
||||||
|
),
|
||||||
|
name: CrateName(
|
||||||
|
"libc",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
proc_macro: [],
|
||||||
|
},
|
||||||
|
CrateId(
|
||||||
|
5,
|
||||||
|
): CrateData {
|
||||||
|
root_file_id: FileId(
|
||||||
|
6,
|
||||||
|
),
|
||||||
|
edition: Edition2015,
|
||||||
|
display_name: Some(
|
||||||
|
CrateDisplayName {
|
||||||
|
crate_name: CrateName(
|
||||||
|
"const_fn",
|
||||||
|
),
|
||||||
|
canonical_name: "const_fn",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"feature=default",
|
||||||
|
"feature=std",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
potential_cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"feature=align",
|
||||||
|
"feature=const-extern-fn",
|
||||||
|
"feature=default",
|
||||||
|
"feature=extra_traits",
|
||||||
|
"feature=rustc-dep-of-std",
|
||||||
|
"feature=std",
|
||||||
|
"feature=use_std",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
env: Env {
|
||||||
|
entries: {
|
||||||
|
"CARGO_PKG_LICENSE": "",
|
||||||
|
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||||
|
"CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98",
|
||||||
|
"CARGO_PKG_VERSION": "0.2.98",
|
||||||
|
"CARGO_PKG_AUTHORS": "",
|
||||||
|
"CARGO_CRATE_NAME": "libc",
|
||||||
|
"CARGO_PKG_LICENSE_FILE": "",
|
||||||
|
"CARGO_PKG_HOMEPAGE": "",
|
||||||
|
"CARGO_PKG_DESCRIPTION": "",
|
||||||
|
"CARGO_PKG_NAME": "libc",
|
||||||
|
"CARGO_PKG_VERSION_PATCH": "98",
|
||||||
|
"CARGO": "cargo",
|
||||||
|
"CARGO_PKG_REPOSITORY": "",
|
||||||
|
"CARGO_PKG_VERSION_MINOR": "2",
|
||||||
|
"CARGO_PKG_VERSION_PRE": "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dependencies: [
|
||||||
|
Dependency {
|
||||||
|
crate_id: CrateId(
|
||||||
|
4,
|
||||||
|
),
|
||||||
|
name: CrateName(
|
||||||
|
"libc",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
proc_macro: [],
|
||||||
|
},
|
||||||
|
CrateId(
|
||||||
|
2,
|
||||||
|
): CrateData {
|
||||||
|
root_file_id: FileId(
|
||||||
|
3,
|
||||||
|
),
|
||||||
|
edition: Edition2018,
|
||||||
|
display_name: Some(
|
||||||
|
CrateDisplayName {
|
||||||
|
crate_name: CrateName(
|
||||||
|
"an_example",
|
||||||
|
),
|
||||||
|
canonical_name: "an-example",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"test",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
potential_cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"test",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
env: Env {
|
||||||
|
entries: {
|
||||||
|
"CARGO_PKG_LICENSE": "",
|
||||||
|
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||||
|
"CARGO_MANIFEST_DIR": "$ROOT$hello-world",
|
||||||
|
"CARGO_PKG_VERSION": "0.1.0",
|
||||||
|
"CARGO_PKG_AUTHORS": "",
|
||||||
|
"CARGO_CRATE_NAME": "hello_world",
|
||||||
|
"CARGO_PKG_LICENSE_FILE": "",
|
||||||
|
"CARGO_PKG_HOMEPAGE": "",
|
||||||
|
"CARGO_PKG_DESCRIPTION": "",
|
||||||
|
"CARGO_PKG_NAME": "hello-world",
|
||||||
|
"CARGO_PKG_VERSION_PATCH": "0",
|
||||||
|
"CARGO": "cargo",
|
||||||
|
"CARGO_PKG_REPOSITORY": "",
|
||||||
|
"CARGO_PKG_VERSION_MINOR": "1",
|
||||||
|
"CARGO_PKG_VERSION_PRE": "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dependencies: [
|
||||||
|
Dependency {
|
||||||
|
crate_id: CrateId(
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
name: CrateName(
|
||||||
|
"hello_world",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
Dependency {
|
||||||
|
crate_id: CrateId(
|
||||||
|
4,
|
||||||
|
),
|
||||||
|
name: CrateName(
|
||||||
|
"libc",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
proc_macro: [],
|
||||||
|
},
|
||||||
|
CrateId(
|
||||||
|
4,
|
||||||
|
): CrateData {
|
||||||
|
root_file_id: FileId(
|
||||||
|
5,
|
||||||
|
),
|
||||||
|
edition: Edition2015,
|
||||||
|
display_name: Some(
|
||||||
|
CrateDisplayName {
|
||||||
|
crate_name: CrateName(
|
||||||
|
"libc",
|
||||||
|
),
|
||||||
|
canonical_name: "libc",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"feature=default",
|
||||||
|
"feature=std",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
potential_cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"feature=align",
|
||||||
|
"feature=const-extern-fn",
|
||||||
|
"feature=default",
|
||||||
|
"feature=extra_traits",
|
||||||
|
"feature=rustc-dep-of-std",
|
||||||
|
"feature=std",
|
||||||
|
"feature=use_std",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
env: Env {
|
||||||
|
entries: {
|
||||||
|
"CARGO_PKG_LICENSE": "",
|
||||||
|
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||||
|
"CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98",
|
||||||
|
"CARGO_PKG_VERSION": "0.2.98",
|
||||||
|
"CARGO_PKG_AUTHORS": "",
|
||||||
|
"CARGO_CRATE_NAME": "libc",
|
||||||
|
"CARGO_PKG_LICENSE_FILE": "",
|
||||||
|
"CARGO_PKG_HOMEPAGE": "",
|
||||||
|
"CARGO_PKG_DESCRIPTION": "",
|
||||||
|
"CARGO_PKG_NAME": "libc",
|
||||||
|
"CARGO_PKG_VERSION_PATCH": "98",
|
||||||
|
"CARGO": "cargo",
|
||||||
|
"CARGO_PKG_REPOSITORY": "",
|
||||||
|
"CARGO_PKG_VERSION_MINOR": "2",
|
||||||
|
"CARGO_PKG_VERSION_PRE": "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dependencies: [],
|
||||||
|
proc_macro: [],
|
||||||
|
},
|
||||||
|
CrateId(
|
||||||
|
1,
|
||||||
|
): CrateData {
|
||||||
|
root_file_id: FileId(
|
||||||
|
2,
|
||||||
|
),
|
||||||
|
edition: Edition2018,
|
||||||
|
display_name: Some(
|
||||||
|
CrateDisplayName {
|
||||||
|
crate_name: CrateName(
|
||||||
|
"hello_world",
|
||||||
|
),
|
||||||
|
canonical_name: "hello-world",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"test",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
potential_cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"test",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
env: Env {
|
||||||
|
entries: {
|
||||||
|
"CARGO_PKG_LICENSE": "",
|
||||||
|
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||||
|
"CARGO_MANIFEST_DIR": "$ROOT$hello-world",
|
||||||
|
"CARGO_PKG_VERSION": "0.1.0",
|
||||||
|
"CARGO_PKG_AUTHORS": "",
|
||||||
|
"CARGO_CRATE_NAME": "hello_world",
|
||||||
|
"CARGO_PKG_LICENSE_FILE": "",
|
||||||
|
"CARGO_PKG_HOMEPAGE": "",
|
||||||
|
"CARGO_PKG_DESCRIPTION": "",
|
||||||
|
"CARGO_PKG_NAME": "hello-world",
|
||||||
|
"CARGO_PKG_VERSION_PATCH": "0",
|
||||||
|
"CARGO": "cargo",
|
||||||
|
"CARGO_PKG_REPOSITORY": "",
|
||||||
|
"CARGO_PKG_VERSION_MINOR": "1",
|
||||||
|
"CARGO_PKG_VERSION_PRE": "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dependencies: [
|
||||||
|
Dependency {
|
||||||
|
crate_id: CrateId(
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
name: CrateName(
|
||||||
|
"hello_world",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
Dependency {
|
||||||
|
crate_id: CrateId(
|
||||||
|
4,
|
||||||
|
),
|
||||||
|
name: CrateName(
|
||||||
|
"libc",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
proc_macro: [],
|
||||||
|
},
|
||||||
|
CrateId(
|
||||||
|
6,
|
||||||
|
): CrateData {
|
||||||
|
root_file_id: FileId(
|
||||||
|
7,
|
||||||
|
),
|
||||||
|
edition: Edition2015,
|
||||||
|
display_name: Some(
|
||||||
|
CrateDisplayName {
|
||||||
|
crate_name: CrateName(
|
||||||
|
"build_script_build",
|
||||||
|
),
|
||||||
|
canonical_name: "build-script-build",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"feature=default",
|
||||||
|
"feature=std",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
potential_cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"feature=align",
|
||||||
|
"feature=const-extern-fn",
|
||||||
|
"feature=default",
|
||||||
|
"feature=extra_traits",
|
||||||
|
"feature=rustc-dep-of-std",
|
||||||
|
"feature=std",
|
||||||
|
"feature=use_std",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
env: Env {
|
||||||
|
entries: {
|
||||||
|
"CARGO_PKG_LICENSE": "",
|
||||||
|
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||||
|
"CARGO_MANIFEST_DIR": "$ROOT$.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.98",
|
||||||
|
"CARGO_PKG_VERSION": "0.2.98",
|
||||||
|
"CARGO_PKG_AUTHORS": "",
|
||||||
|
"CARGO_CRATE_NAME": "libc",
|
||||||
|
"CARGO_PKG_LICENSE_FILE": "",
|
||||||
|
"CARGO_PKG_HOMEPAGE": "",
|
||||||
|
"CARGO_PKG_DESCRIPTION": "",
|
||||||
|
"CARGO_PKG_NAME": "libc",
|
||||||
|
"CARGO_PKG_VERSION_PATCH": "98",
|
||||||
|
"CARGO": "cargo",
|
||||||
|
"CARGO_PKG_REPOSITORY": "",
|
||||||
|
"CARGO_PKG_VERSION_MINOR": "2",
|
||||||
|
"CARGO_PKG_VERSION_PRE": "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dependencies: [],
|
||||||
|
proc_macro: [],
|
||||||
|
},
|
||||||
|
CrateId(
|
||||||
|
3,
|
||||||
|
): CrateData {
|
||||||
|
root_file_id: FileId(
|
||||||
|
4,
|
||||||
|
),
|
||||||
|
edition: Edition2018,
|
||||||
|
display_name: Some(
|
||||||
|
CrateDisplayName {
|
||||||
|
crate_name: CrateName(
|
||||||
|
"it",
|
||||||
|
),
|
||||||
|
canonical_name: "it",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"test",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
potential_cfg_options: CfgOptions(
|
||||||
|
[
|
||||||
|
"debug_assertions",
|
||||||
|
"test",
|
||||||
|
],
|
||||||
|
),
|
||||||
|
env: Env {
|
||||||
|
entries: {
|
||||||
|
"CARGO_PKG_LICENSE": "",
|
||||||
|
"CARGO_PKG_VERSION_MAJOR": "0",
|
||||||
|
"CARGO_MANIFEST_DIR": "$ROOT$hello-world",
|
||||||
|
"CARGO_PKG_VERSION": "0.1.0",
|
||||||
|
"CARGO_PKG_AUTHORS": "",
|
||||||
|
"CARGO_CRATE_NAME": "hello_world",
|
||||||
|
"CARGO_PKG_LICENSE_FILE": "",
|
||||||
|
"CARGO_PKG_HOMEPAGE": "",
|
||||||
|
"CARGO_PKG_DESCRIPTION": "",
|
||||||
|
"CARGO_PKG_NAME": "hello-world",
|
||||||
|
"CARGO_PKG_VERSION_PATCH": "0",
|
||||||
|
"CARGO": "cargo",
|
||||||
|
"CARGO_PKG_REPOSITORY": "",
|
||||||
|
"CARGO_PKG_VERSION_MINOR": "1",
|
||||||
|
"CARGO_PKG_VERSION_PRE": "",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dependencies: [
|
||||||
|
Dependency {
|
||||||
|
crate_id: CrateId(
|
||||||
|
0,
|
||||||
|
),
|
||||||
|
name: CrateName(
|
||||||
|
"hello_world",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
Dependency {
|
||||||
|
crate_id: CrateId(
|
||||||
|
4,
|
||||||
|
),
|
||||||
|
name: CrateName(
|
||||||
|
"libc",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
proc_macro: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}"#]],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cargo_hello_world_project_model() {
|
fn cargo_hello_world_project_model() {
|
||||||
let crate_graph = load_cargo("hello-world-metadata.json");
|
let crate_graph = load_cargo("hello-world-metadata.json");
|
||||||
|
|
|
@ -21,7 +21,32 @@ use crate::{
|
||||||
TargetKind, WorkspaceBuildScripts,
|
TargetKind, WorkspaceBuildScripts,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub type CfgOverrides = FxHashMap<String, CfgDiff>;
|
/// A set of cfg-overrides per crate.
|
||||||
|
///
|
||||||
|
/// `Wildcard(..)` is useful e.g. disabling `#[cfg(test)]` on all crates,
|
||||||
|
/// without having to first obtain a list of all crates.
|
||||||
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
|
pub enum CfgOverrides {
|
||||||
|
/// A single global set of overrides matching all crates.
|
||||||
|
Wildcard(CfgDiff),
|
||||||
|
/// A set of overrides matching specific crates.
|
||||||
|
Selective(FxHashMap<String, CfgDiff>),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for CfgOverrides {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::Selective(FxHashMap::default())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl CfgOverrides {
|
||||||
|
pub fn len(&self) -> usize {
|
||||||
|
match self {
|
||||||
|
CfgOverrides::Wildcard(_) => 1,
|
||||||
|
CfgOverrides::Selective(hash_map) => hash_map.len(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// `PackageRoot` describes a package root folder.
|
/// `PackageRoot` describes a package root folder.
|
||||||
/// Which may be an external dependency, or a member of
|
/// Which may be an external dependency, or a member of
|
||||||
|
@ -501,7 +526,13 @@ fn cargo_to_crate_graph(
|
||||||
for pkg in cargo.packages() {
|
for pkg in cargo.packages() {
|
||||||
let mut cfg_options = &cfg_options;
|
let mut cfg_options = &cfg_options;
|
||||||
let mut replaced_cfg_options;
|
let mut replaced_cfg_options;
|
||||||
if let Some(overrides) = override_cfg.get(&cargo[pkg].name) {
|
|
||||||
|
let overrides = match override_cfg {
|
||||||
|
CfgOverrides::Wildcard(cfg_diff) => Some(cfg_diff),
|
||||||
|
CfgOverrides::Selective(cfg_overrides) => cfg_overrides.get(&cargo[pkg].name),
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(overrides) = overrides {
|
||||||
// FIXME: this is sort of a hack to deal with #![cfg(not(test))] vanishing such as seen
|
// FIXME: this is sort of a hack to deal with #![cfg(not(test))] vanishing such as seen
|
||||||
// in ed25519_dalek (#7243), and libcore (#9203) (although you only hit that one while
|
// in ed25519_dalek (#7243), and libcore (#9203) (although you only hit that one while
|
||||||
// working on rust-lang/rust as that's the only time it appears outside sysroot).
|
// working on rust-lang/rust as that's the only time it appears outside sysroot).
|
||||||
|
|
|
@ -19,7 +19,9 @@ use ide_db::helpers::{
|
||||||
SnippetCap,
|
SnippetCap,
|
||||||
};
|
};
|
||||||
use lsp_types::{ClientCapabilities, MarkupKind};
|
use lsp_types::{ClientCapabilities, MarkupKind};
|
||||||
use project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest, RustcSource};
|
use project_model::{
|
||||||
|
CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest, RustcSource, UnsetTestCrates,
|
||||||
|
};
|
||||||
use rustc_hash::{FxHashMap, FxHashSet};
|
use rustc_hash::{FxHashMap, FxHashSet};
|
||||||
use serde::{de::DeserializeOwned, Deserialize};
|
use serde::{de::DeserializeOwned, Deserialize};
|
||||||
use vfs::AbsPathBuf;
|
use vfs::AbsPathBuf;
|
||||||
|
@ -668,9 +670,9 @@ impl Config {
|
||||||
all_features: self.data.cargo_allFeatures,
|
all_features: self.data.cargo_allFeatures,
|
||||||
features: self.data.cargo_features.clone(),
|
features: self.data.cargo_features.clone(),
|
||||||
target: self.data.cargo_target.clone(),
|
target: self.data.cargo_target.clone(),
|
||||||
rustc_source,
|
|
||||||
no_sysroot: self.data.cargo_noSysroot,
|
no_sysroot: self.data.cargo_noSysroot,
|
||||||
unset_test_crates: self.data.cargo_unsetTest.clone(),
|
rustc_source,
|
||||||
|
unset_test_crates: UnsetTestCrates::Only(self.data.cargo_unsetTest.clone()),
|
||||||
wrap_rustc_in_build_scripts: self.data.cargo_useRustcWrapperForBuildScripts,
|
wrap_rustc_in_build_scripts: self.data.cargo_useRustcWrapperForBuildScripts,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue