aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/body.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/body.rs')
-rw-r--r--crates/ra_hir_def/src/body.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs
index ff0758da0..48b797dd6 100644
--- a/crates/ra_hir_def/src/body.rs
+++ b/crates/ra_hir_def/src/body.rs
@@ -24,9 +24,11 @@ use crate::{
24 src::HasSource, 24 src::HasSource,
25 AsMacroCall, DefWithBodyId, HasModule, Lookup, ModuleId, 25 AsMacroCall, DefWithBodyId, HasModule, Lookup, ModuleId,
26}; 26};
27use ra_cfg::CfgOptions;
27 28
28pub(crate) struct Expander { 29pub(crate) struct Expander {
29 crate_def_map: Arc<CrateDefMap>, 30 crate_def_map: Arc<CrateDefMap>,
31 cfg_options: CfgOptions,
30 current_file_id: HirFileId, 32 current_file_id: HirFileId,
31 hygiene: Hygiene, 33 hygiene: Hygiene,
32 ast_id_map: Arc<AstIdMap>, 34 ast_id_map: Arc<AstIdMap>,
@@ -43,7 +45,16 @@ impl Expander {
43 let crate_def_map = db.crate_def_map(module.krate); 45 let crate_def_map = db.crate_def_map(module.krate);
44 let hygiene = Hygiene::new(db.upcast(), current_file_id); 46 let hygiene = Hygiene::new(db.upcast(), current_file_id);
45 let ast_id_map = db.ast_id_map(current_file_id); 47 let ast_id_map = db.ast_id_map(current_file_id);
46 Expander { crate_def_map, current_file_id, hygiene, ast_id_map, module, recursive_limit: 0 } 48 let cfg_options = db.crate_graph()[module.krate].cfg_options.clone();
49 Expander {
50 crate_def_map,
51 cfg_options,
52 current_file_id,
53 hygiene,
54 ast_id_map,
55 module,
56 recursive_limit: 0,
57 }
47 } 58 }
48 59
49 pub(crate) fn enter_expand<T: ast::AstNode>( 60 pub(crate) fn enter_expand<T: ast::AstNode>(
@@ -107,6 +118,10 @@ impl Expander {
107 Attrs::new(owner, &self.hygiene) 118 Attrs::new(owner, &self.hygiene)
108 } 119 }
109 120
121 pub(crate) fn check_cfg(&self, attrs: &Attrs) -> bool {
122 attrs.is_cfg_enabled(&self.cfg_options)
123 }
124
110 fn parse_path(&mut self, path: ast::Path) -> Option<Path> { 125 fn parse_path(&mut self, path: ast::Path) -> Option<Path> {
111 Path::from_src(path, &self.hygiene) 126 Path::from_src(path, &self.hygiene)
112 } 127 }