diff options
Diffstat (limited to 'crates/ra_project_model')
-rw-r--r-- | crates/ra_project_model/Cargo.toml | 1 | ||||
-rw-r--r-- | crates/ra_project_model/src/lib.rs | 21 |
2 files changed, 19 insertions, 3 deletions
diff --git a/crates/ra_project_model/Cargo.toml b/crates/ra_project_model/Cargo.toml index ae6b91aa6..a65100031 100644 --- a/crates/ra_project_model/Cargo.toml +++ b/crates/ra_project_model/Cargo.toml | |||
@@ -12,6 +12,7 @@ cargo_metadata = "0.8.2" | |||
12 | 12 | ||
13 | ra_arena = { path = "../ra_arena" } | 13 | ra_arena = { path = "../ra_arena" } |
14 | ra_db = { path = "../ra_db" } | 14 | ra_db = { path = "../ra_db" } |
15 | ra_cfg = { path = "../ra_cfg" } | ||
15 | 16 | ||
16 | serde = { version = "1.0.89", features = ["derive"] } | 17 | serde = { version = "1.0.89", features = ["derive"] } |
17 | serde_json = "1.0.39" | 18 | serde_json = "1.0.39" |
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index 5d3078598..5ff3971e0 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs | |||
@@ -11,6 +11,7 @@ use std::{ | |||
11 | path::{Path, PathBuf}, | 11 | path::{Path, PathBuf}, |
12 | }; | 12 | }; |
13 | 13 | ||
14 | use ra_cfg::CfgOptions; | ||
14 | use ra_db::{CrateGraph, CrateId, Edition, FileId}; | 15 | use ra_db::{CrateGraph, CrateId, Edition, FileId}; |
15 | use rustc_hash::FxHashMap; | 16 | use rustc_hash::FxHashMap; |
16 | use serde_json::from_reader; | 17 | use serde_json::from_reader; |
@@ -131,7 +132,13 @@ impl ProjectWorkspace { | |||
131 | json_project::Edition::Edition2015 => Edition::Edition2015, | 132 | json_project::Edition::Edition2015 => Edition::Edition2015, |
132 | json_project::Edition::Edition2018 => Edition::Edition2018, | 133 | json_project::Edition::Edition2018 => Edition::Edition2018, |
133 | }; | 134 | }; |
134 | crates.insert(crate_id, crate_graph.add_crate_root(file_id, edition)); | 135 | // FIXME: cfg options |
136 | // Default to enable test for workspace crates. | ||
137 | let cfg_options = CfgOptions::default().atom("test".into()); | ||
138 | crates.insert( | ||
139 | crate_id, | ||
140 | crate_graph.add_crate_root(file_id, edition, cfg_options), | ||
141 | ); | ||
135 | } | 142 | } |
136 | } | 143 | } |
137 | 144 | ||
@@ -157,7 +164,11 @@ impl ProjectWorkspace { | |||
157 | let mut sysroot_crates = FxHashMap::default(); | 164 | let mut sysroot_crates = FxHashMap::default(); |
158 | for krate in sysroot.crates() { | 165 | for krate in sysroot.crates() { |
159 | if let Some(file_id) = load(krate.root(&sysroot)) { | 166 | if let Some(file_id) = load(krate.root(&sysroot)) { |
160 | let crate_id = crate_graph.add_crate_root(file_id, Edition::Edition2018); | 167 | // FIXME: cfg options |
168 | // Crates from sysroot have `cfg(test)` disabled | ||
169 | let cfg_options = CfgOptions::default(); | ||
170 | let crate_id = | ||
171 | crate_graph.add_crate_root(file_id, Edition::Edition2018, cfg_options); | ||
161 | sysroot_crates.insert(krate, crate_id); | 172 | sysroot_crates.insert(krate, crate_id); |
162 | names.insert(crate_id, krate.name(&sysroot).to_string()); | 173 | names.insert(crate_id, krate.name(&sysroot).to_string()); |
163 | } | 174 | } |
@@ -186,7 +197,11 @@ impl ProjectWorkspace { | |||
186 | let root = tgt.root(&cargo); | 197 | let root = tgt.root(&cargo); |
187 | if let Some(file_id) = load(root) { | 198 | if let Some(file_id) = load(root) { |
188 | let edition = pkg.edition(&cargo); | 199 | let edition = pkg.edition(&cargo); |
189 | let crate_id = crate_graph.add_crate_root(file_id, edition); | 200 | // FIXME: cfg options |
201 | // Default to enable test for workspace crates. | ||
202 | let cfg_options = CfgOptions::default().atom("test".into()); | ||
203 | let crate_id = | ||
204 | crate_graph.add_crate_root(file_id, edition, cfg_options); | ||
190 | names.insert(crate_id, pkg.name(&cargo).to_string()); | 205 | names.insert(crate_id, pkg.name(&cargo).to_string()); |
191 | if tgt.kind(&cargo) == TargetKind::Lib { | 206 | if tgt.kind(&cargo) == TargetKind::Lib { |
192 | lib_tgt = Some(crate_id); | 207 | lib_tgt = Some(crate_id); |