Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/expander.rs')
| -rw-r--r-- | crates/hir-def/src/expander.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/hir-def/src/expander.rs b/crates/hir-def/src/expander.rs index b0872fcdc0..73ce942c58 100644 --- a/crates/hir-def/src/expander.rs +++ b/crates/hir-def/src/expander.rs @@ -11,6 +11,7 @@ use hir_expand::{ }; use limit::Limit; use syntax::{ast, Parse}; +use triomphe::Arc; use crate::{ attr::Attrs, db::DefDatabase, lower::LowerCtx, path::Path, AsMacroCall, MacroId, ModuleId, @@ -19,9 +20,8 @@ use crate::{ #[derive(Debug)] pub struct Expander { - cfg_options: CfgOptions, + cfg_options: Arc<CfgOptions>, span_map: OnceCell<SpanMap>, - krate: CrateId, current_file_id: HirFileId, pub(crate) module: ModuleId, /// `recursion_depth == usize::MAX` indicates that the recursion limit has been reached. @@ -45,10 +45,13 @@ impl Expander { recursion_limit, cfg_options: db.crate_graph()[module.krate].cfg_options.clone(), span_map: OnceCell::new(), - krate: module.krate, } } + pub fn krate(&self) -> CrateId { + self.module.krate + } + pub fn enter_expand<T: ast::AstNode>( &mut self, db: &dyn DefDatabase, @@ -112,7 +115,7 @@ impl Expander { pub(crate) fn parse_attrs(&self, db: &dyn DefDatabase, owner: &dyn ast::HasAttrs) -> Attrs { Attrs::filter( db, - self.krate, + self.krate(), RawAttrs::new( db.upcast(), owner, |