diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-11-24 16:06:58 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2019-11-24 16:06:58 +0000 |
commit | ac9ba5eb32073c16608acaa04324e7dc46d303d6 (patch) | |
tree | a88c9a76a24787c1eac988f318e938406a288677 /crates/ra_hir_def/src/body.rs | |
parent | b0581c2403f49c68738c039065fa2cfc41345738 (diff) | |
parent | 434f108adad75b7c5e25db745a9f9fefa5cdaa31 (diff) |
Merge #2387
2387: Simplify r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/body.rs')
-rw-r--r-- | crates/ra_hir_def/src/body.rs | 28 |
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 | ||
23 | pub struct Expander { | 23 | struct 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 | ||
30 | impl Expander { | 30 | impl 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)] |
103 | pub struct Body { | 103 | pub 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 | ||
117 | pub type ExprPtr = Either<AstPtr<ast::Expr>, AstPtr<ast::RecordField>>; | 117 | pub 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 | ||
203 | impl Index<ExprId> for Body { | 187 | impl Index<ExprId> for Body { |