diff options
author | uHOOCCOOHu <[email protected]> | 2019-09-29 23:52:15 +0100 |
---|---|---|
committer | uHOOCCOOHu <[email protected]> | 2019-10-02 19:28:02 +0100 |
commit | b1ed887d813bf5775a16624694939fdf836f97b1 (patch) | |
tree | b69daa2ca7d29a3362e9608ad0596de18caffa18 /crates/ra_db/src | |
parent | ffe179a73663b111e4b3ee8a3f525fb3e461c78e (diff) |
Introduce ra_cfg to parse and evaluate CfgExpr
Diffstat (limited to 'crates/ra_db/src')
-rw-r--r-- | crates/ra_db/src/input.rs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs index 52f892891..5fd6edd78 100644 --- a/crates/ra_db/src/input.rs +++ b/crates/ra_db/src/input.rs | |||
@@ -9,6 +9,7 @@ | |||
9 | use relative_path::{RelativePath, RelativePathBuf}; | 9 | use relative_path::{RelativePath, RelativePathBuf}; |
10 | use rustc_hash::FxHashMap; | 10 | use rustc_hash::FxHashMap; |
11 | 11 | ||
12 | use ra_cfg::CfgOptions; | ||
12 | use ra_syntax::SmolStr; | 13 | use ra_syntax::SmolStr; |
13 | use rustc_hash::FxHashSet; | 14 | use rustc_hash::FxHashSet; |
14 | 15 | ||
@@ -109,11 +110,13 @@ struct CrateData { | |||
109 | file_id: FileId, | 110 | file_id: FileId, |
110 | edition: Edition, | 111 | edition: Edition, |
111 | dependencies: Vec<Dependency>, | 112 | dependencies: Vec<Dependency>, |
113 | cfg_options: CfgOptions, | ||
112 | } | 114 | } |
113 | 115 | ||
114 | impl CrateData { | 116 | impl CrateData { |
115 | fn new(file_id: FileId, edition: Edition) -> CrateData { | 117 | fn new(file_id: FileId, edition: Edition) -> CrateData { |
116 | CrateData { file_id, edition, dependencies: Vec::new() } | 118 | // FIXME: cfg options |
119 | CrateData { file_id, edition, dependencies: Vec::new(), cfg_options: CfgOptions::default() } | ||
117 | } | 120 | } |
118 | 121 | ||
119 | fn add_dep(&mut self, name: SmolStr, crate_id: CrateId) { | 122 | fn add_dep(&mut self, name: SmolStr, crate_id: CrateId) { |
@@ -141,6 +144,10 @@ impl CrateGraph { | |||
141 | crate_id | 144 | crate_id |
142 | } | 145 | } |
143 | 146 | ||
147 | pub fn cfg_options(&self, crate_id: CrateId) -> &CfgOptions { | ||
148 | &self.arena[&crate_id].cfg_options | ||
149 | } | ||
150 | |||
144 | pub fn add_dep( | 151 | pub fn add_dep( |
145 | &mut self, | 152 | &mut self, |
146 | from: CrateId, | 153 | from: CrateId, |