aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/body.rs
diff options
context:
space:
mode:
authorcynecx <[email protected]>2021-04-18 18:56:13 +0100
committercynecx <[email protected]>2021-04-18 18:56:13 +0100
commit6ed2fd233b569d01169fc888f30c358dd289d260 (patch)
treed5ff73fef371ac596e7c98db1c39c9dd3112f571 /crates/hir_def/src/body.rs
parent3d39e77003c5fe5ed9f8f3ac00a170f3804f8337 (diff)
hir_ty: keep body::Expander in TyLoweringContext
Diffstat (limited to 'crates/hir_def/src/body.rs')
-rw-r--r--crates/hir_def/src/body.rs18
1 files changed, 8 insertions, 10 deletions
diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs
index 8a9b936ea..131f424cc 100644
--- a/crates/hir_def/src/body.rs
+++ b/crates/hir_def/src/body.rs
@@ -37,13 +37,15 @@ use crate::{
37 37
38/// A subset of Expander that only deals with cfg attributes. We only need it to 38/// A subset of Expander that only deals with cfg attributes. We only need it to
39/// avoid cyclic queries in crate def map during enum processing. 39/// avoid cyclic queries in crate def map during enum processing.
40#[derive(Debug)]
40pub(crate) struct CfgExpander { 41pub(crate) struct CfgExpander {
41 cfg_options: CfgOptions, 42 cfg_options: CfgOptions,
42 hygiene: Hygiene, 43 hygiene: Hygiene,
43 krate: CrateId, 44 krate: CrateId,
44} 45}
45 46
46pub(crate) struct Expander { 47#[derive(Debug)]
48pub struct Expander {
47 cfg_expander: CfgExpander, 49 cfg_expander: CfgExpander,
48 def_map: Arc<DefMap>, 50 def_map: Arc<DefMap>,
49 current_file_id: HirFileId, 51 current_file_id: HirFileId,
@@ -80,11 +82,7 @@ impl CfgExpander {
80} 82}
81 83
82impl Expander { 84impl Expander {
83 pub(crate) fn new( 85 pub fn new(db: &dyn DefDatabase, current_file_id: HirFileId, module: ModuleId) -> Expander {
84 db: &dyn DefDatabase,
85 current_file_id: HirFileId,
86 module: ModuleId,
87 ) -> Expander {
88 let cfg_expander = CfgExpander::new(db, current_file_id, module.krate); 86 let cfg_expander = CfgExpander::new(db, current_file_id, module.krate);
89 let def_map = module.def_map(db); 87 let def_map = module.def_map(db);
90 let ast_id_map = db.ast_id_map(current_file_id); 88 let ast_id_map = db.ast_id_map(current_file_id);
@@ -98,7 +96,7 @@ impl Expander {
98 } 96 }
99 } 97 }
100 98
101 pub(crate) fn enter_expand<T: ast::AstNode>( 99 pub fn enter_expand<T: ast::AstNode>(
102 &mut self, 100 &mut self,
103 db: &dyn DefDatabase, 101 db: &dyn DefDatabase,
104 macro_call: ast::MacroCall, 102 macro_call: ast::MacroCall,
@@ -170,7 +168,7 @@ impl Expander {
170 Ok(ExpandResult { value: Some((mark, node)), err }) 168 Ok(ExpandResult { value: Some((mark, node)), err })
171 } 169 }
172 170
173 pub(crate) fn exit(&mut self, db: &dyn DefDatabase, mut mark: Mark) { 171 pub fn exit(&mut self, db: &dyn DefDatabase, mut mark: Mark) {
174 self.cfg_expander.hygiene = Hygiene::new(db.upcast(), mark.file_id); 172 self.cfg_expander.hygiene = Hygiene::new(db.upcast(), mark.file_id);
175 self.current_file_id = mark.file_id; 173 self.current_file_id = mark.file_id;
176 self.ast_id_map = mem::take(&mut mark.ast_id_map); 174 self.ast_id_map = mem::take(&mut mark.ast_id_map);
@@ -190,7 +188,7 @@ impl Expander {
190 &self.cfg_expander.cfg_options 188 &self.cfg_expander.cfg_options
191 } 189 }
192 190
193 pub(crate) fn current_file_id(&self) -> HirFileId { 191 pub fn current_file_id(&self) -> HirFileId {
194 self.current_file_id 192 self.current_file_id
195 } 193 }
196 194
@@ -210,7 +208,7 @@ impl Expander {
210} 208}
211 209
212#[derive(Debug)] 210#[derive(Debug)]
213pub(crate) struct Mark { 211pub struct Mark {
214 file_id: HirFileId, 212 file_id: HirFileId,
215 ast_id_map: Arc<AstIdMap>, 213 ast_id_map: Arc<AstIdMap>,
216 bomb: DropBomb, 214 bomb: DropBomb,