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.rs28
1 files changed, 6 insertions, 22 deletions
diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs
index c06997cf1..45a36d793 100644
--- a/crates/ra_hir_def/src/body.rs
+++ b/crates/ra_hir_def/src/body.rs
@@ -20,7 +20,7 @@ use crate::{
20 DefWithBodyId, HasModule, HasSource, Lookup, ModuleId, 20 DefWithBodyId, HasModule, HasSource, Lookup, ModuleId,
21}; 21};
22 22
23pub struct Expander { 23struct Expander {
24 crate_def_map: Arc<CrateDefMap>, 24 crate_def_map: Arc<CrateDefMap>,
25 current_file_id: HirFileId, 25 current_file_id: HirFileId,
26 hygiene: Hygiene, 26 hygiene: Hygiene,
@@ -28,7 +28,7 @@ pub struct Expander {
28} 28}
29 29
30impl Expander { 30impl Expander {
31 pub fn new(db: &impl DefDatabase, current_file_id: HirFileId, module: ModuleId) -> Expander { 31 fn new(db: &impl DefDatabase, current_file_id: HirFileId, module: ModuleId) -> Expander {
32 let crate_def_map = db.crate_def_map(module.krate); 32 let crate_def_map = db.crate_def_map(module.krate);
33 let hygiene = Hygiene::new(db, current_file_id); 33 let hygiene = Hygiene::new(db, current_file_id);
34 Expander { crate_def_map, current_file_id, hygiene, module } 34 Expander { crate_def_map, current_file_id, hygiene, module }
@@ -101,17 +101,17 @@ impl Drop for Mark {
101/// The body of an item (function, const etc.). 101/// The body of an item (function, const etc.).
102#[derive(Debug, Eq, PartialEq)] 102#[derive(Debug, Eq, PartialEq)]
103pub struct Body { 103pub struct Body {
104 exprs: Arena<ExprId, Expr>, 104 pub exprs: Arena<ExprId, Expr>,
105 pats: Arena<PatId, Pat>, 105 pub pats: Arena<PatId, Pat>,
106 /// The patterns for the function's parameters. While the parameter types are 106 /// The patterns for the function's parameters. While the parameter types are
107 /// part of the function signature, the patterns are not (they don't change 107 /// part of the function signature, the patterns are not (they don't change
108 /// the external type of the function). 108 /// the external type of the function).
109 /// 109 ///
110 /// If this `Body` is for the body of a constant, this will just be 110 /// If this `Body` is for the body of a constant, this will just be
111 /// empty. 111 /// empty.
112 params: Vec<PatId>, 112 pub params: Vec<PatId>,
113 /// The `ExprId` of the actual body expression. 113 /// The `ExprId` of the actual body expression.
114 body_expr: ExprId, 114 pub body_expr: ExprId,
115} 115}
116 116
117pub type ExprPtr = Either<AstPtr<ast::Expr>, AstPtr<ast::RecordField>>; 117pub type ExprPtr = Either<AstPtr<ast::Expr>, AstPtr<ast::RecordField>>;
@@ -182,22 +182,6 @@ impl Body {
182 ) -> (Body, BodySourceMap) { 182 ) -> (Body, BodySourceMap) {
183 lower::lower(db, expander, params, body) 183 lower::lower(db, expander, params, body)
184 } 184 }
185
186 pub fn params(&self) -> &[PatId] {
187 &self.params
188 }
189
190 pub fn body_expr(&self) -> ExprId {
191 self.body_expr
192 }
193
194 pub fn exprs(&self) -> impl Iterator<Item = (ExprId, &Expr)> {
195 self.exprs.iter()
196 }
197
198 pub fn pats(&self) -> impl Iterator<Item = (PatId, &Pat)> {
199 self.pats.iter()
200 }
201} 185}
202 186
203impl Index<ExprId> for Body { 187impl Index<ExprId> for Body {