Introduce ra_cfg to parse and evaluate CfgExpr

This commit is contained in:
uHOOCCOOHu 2019-09-30 06:52:15 +08:00
parent ffe179a736
commit b1ed887d81
No known key found for this signature in database
GPG key ID: CED392DE0C483D00
11 changed files with 315 additions and 27 deletions

View file

@ -9,6 +9,7 @@
use relative_path::{RelativePath, RelativePathBuf};
use rustc_hash::FxHashMap;
use ra_cfg::CfgOptions;
use ra_syntax::SmolStr;
use rustc_hash::FxHashSet;
@ -109,11 +110,13 @@ struct CrateData {
file_id: FileId,
edition: Edition,
dependencies: Vec<Dependency>,
cfg_options: CfgOptions,
}
impl CrateData {
fn new(file_id: FileId, edition: Edition) -> CrateData {
CrateData { file_id, edition, dependencies: Vec::new() }
// FIXME: cfg options
CrateData { file_id, edition, dependencies: Vec::new(), cfg_options: CfgOptions::default() }
}
fn add_dep(&mut self, name: SmolStr, crate_id: CrateId) {
@ -141,6 +144,10 @@ impl CrateGraph {
crate_id
}
pub fn cfg_options(&self, crate_id: CrateId) -> &CfgOptions {
&self.arena[&crate_id].cfg_options
}
pub fn add_dep(
&mut self,
from: CrateId,