aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/body.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src/body.rs')
-rw-r--r--crates/hir_def/src/body.rs20
1 files changed, 9 insertions, 11 deletions
diff --git a/crates/hir_def/src/body.rs b/crates/hir_def/src/body.rs
index 9a432f7d1..19c4eb521 100644
--- a/crates/hir_def/src/body.rs
+++ b/crates/hir_def/src/body.rs
@@ -20,7 +20,6 @@ use la_arena::{Arena, ArenaMap};
20use profile::Count; 20use profile::Count;
21use rustc_hash::FxHashMap; 21use rustc_hash::FxHashMap;
22use syntax::{ast, AstNode, AstPtr}; 22use syntax::{ast, AstNode, AstPtr};
23use test_utils::mark;
24 23
25pub(crate) use lower::LowerCtx; 24pub(crate) use lower::LowerCtx;
26 25
@@ -29,11 +28,10 @@ use crate::{
29 db::DefDatabase, 28 db::DefDatabase,
30 expr::{Expr, ExprId, Label, LabelId, Pat, PatId}, 29 expr::{Expr, ExprId, Label, LabelId, Pat, PatId},
31 item_scope::BuiltinShadowMode, 30 item_scope::BuiltinShadowMode,
32 item_scope::ItemScope,
33 nameres::DefMap, 31 nameres::DefMap,
34 path::{ModPath, Path}, 32 path::{ModPath, Path},
35 src::HasSource, 33 src::HasSource,
36 AsMacroCall, DefWithBodyId, HasModule, LocalModuleId, Lookup, ModuleId, 34 AsMacroCall, BlockId, DefWithBodyId, HasModule, LocalModuleId, Lookup, ModuleId,
37}; 35};
38 36
39/// A subset of Expander that only deals with cfg attributes. We only need it to 37/// A subset of Expander that only deals with cfg attributes. We only need it to
@@ -87,11 +85,11 @@ impl Expander {
87 module: ModuleId, 85 module: ModuleId,
88 ) -> Expander { 86 ) -> Expander {
89 let cfg_expander = CfgExpander::new(db, current_file_id, module.krate); 87 let cfg_expander = CfgExpander::new(db, current_file_id, module.krate);
90 let crate_def_map = module.def_map(db); 88 let def_map = module.def_map(db);
91 let ast_id_map = db.ast_id_map(current_file_id); 89 let ast_id_map = db.ast_id_map(current_file_id);
92 Expander { 90 Expander {
93 cfg_expander, 91 cfg_expander,
94 def_map: crate_def_map, 92 def_map,
95 current_file_id, 93 current_file_id,
96 ast_id_map, 94 ast_id_map,
97 module: module.local_id, 95 module: module.local_id,
@@ -105,7 +103,7 @@ impl Expander {
105 macro_call: ast::MacroCall, 103 macro_call: ast::MacroCall,
106 ) -> ExpandResult<Option<(Mark, T)>> { 104 ) -> ExpandResult<Option<(Mark, T)>> {
107 if self.recursion_limit + 1 > EXPANSION_RECURSION_LIMIT { 105 if self.recursion_limit + 1 > EXPANSION_RECURSION_LIMIT {
108 mark::hit!(your_stack_belongs_to_me); 106 cov_mark::hit!(your_stack_belongs_to_me);
109 return ExpandResult::str_err("reached recursion limit during macro expansion".into()); 107 return ExpandResult::str_err("reached recursion limit during macro expansion".into());
110 } 108 }
111 109
@@ -123,7 +121,7 @@ impl Expander {
123 Some(it) => it, 121 Some(it) => it,
124 None => { 122 None => {
125 if err.is_none() { 123 if err.is_none() {
126 eprintln!("no error despite `as_call_id_with_errors` returning `None`"); 124 log::warn!("no error despite `as_call_id_with_errors` returning `None`");
127 } 125 }
128 return ExpandResult { value: None, err }; 126 return ExpandResult { value: None, err };
129 } 127 }
@@ -227,7 +225,8 @@ pub struct Body {
227 pub params: Vec<PatId>, 225 pub params: Vec<PatId>,
228 /// The `ExprId` of the actual body expression. 226 /// The `ExprId` of the actual body expression.
229 pub body_expr: ExprId, 227 pub body_expr: ExprId,
230 pub item_scope: ItemScope, 228 /// Block expressions in this body that may contain inner items.
229 pub block_scopes: Vec<BlockId>,
231 _c: Count<Self>, 230 _c: Count<Self>,
232} 231}
233 232
@@ -296,7 +295,7 @@ impl Body {
296 } 295 }
297 }; 296 };
298 let expander = Expander::new(db, file_id, module); 297 let expander = Expander::new(db, file_id, module);
299 let (body, source_map) = Body::new(db, def, expander, params, body); 298 let (body, source_map) = Body::new(db, expander, params, body);
300 (Arc::new(body), Arc::new(source_map)) 299 (Arc::new(body), Arc::new(source_map))
301 } 300 }
302 301
@@ -306,12 +305,11 @@ impl Body {
306 305
307 fn new( 306 fn new(
308 db: &dyn DefDatabase, 307 db: &dyn DefDatabase,
309 def: DefWithBodyId,
310 expander: Expander, 308 expander: Expander,
311 params: Option<ast::ParamList>, 309 params: Option<ast::ParamList>,
312 body: Option<ast::Expr>, 310 body: Option<ast::Expr>,
313 ) -> (Body, BodySourceMap) { 311 ) -> (Body, BodySourceMap) {
314 lower::lower(db, def, expander, params, body) 312 lower::lower(db, expander, params, body)
315 } 313 }
316} 314}
317 315