diff options
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/body.rs | 28 | ||||
-rw-r--r-- | crates/ra_hir_def/src/body/scope.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/tests.rs | 2 |
4 files changed, 10 insertions, 26 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 { |
diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs index 20d707bc4..5240a59d5 100644 --- a/crates/ra_hir_def/src/body/scope.rs +++ b/crates/ra_hir_def/src/body/scope.rs | |||
@@ -54,8 +54,8 @@ impl ExprScopes { | |||
54 | let mut scopes = | 54 | let mut scopes = |
55 | ExprScopes { scopes: Arena::default(), scope_by_expr: FxHashMap::default() }; | 55 | ExprScopes { scopes: Arena::default(), scope_by_expr: FxHashMap::default() }; |
56 | let root = scopes.root_scope(); | 56 | let root = scopes.root_scope(); |
57 | scopes.add_params_bindings(body, root, body.params()); | 57 | scopes.add_params_bindings(body, root, &body.params); |
58 | compute_expr_scopes(body.body_expr(), body, &mut scopes, root); | 58 | compute_expr_scopes(body.body_expr, body, &mut scopes, root); |
59 | scopes | 59 | scopes |
60 | } | 60 | } |
61 | 61 | ||
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs index 9476fb1ad..2359386c2 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs | |||
@@ -81,13 +81,13 @@ use crate::{ | |||
81 | #[derive(Debug, PartialEq, Eq)] | 81 | #[derive(Debug, PartialEq, Eq)] |
82 | pub struct CrateDefMap { | 82 | pub struct CrateDefMap { |
83 | pub root: LocalModuleId, | 83 | pub root: LocalModuleId, |
84 | pub modules: Arena<LocalModuleId, ModuleData>, | ||
84 | pub(crate) krate: CrateId, | 85 | pub(crate) krate: CrateId, |
85 | /// The prelude module for this crate. This either comes from an import | 86 | /// The prelude module for this crate. This either comes from an import |
86 | /// marked with the `prelude_import` attribute, or (in the normal case) from | 87 | /// marked with the `prelude_import` attribute, or (in the normal case) from |
87 | /// a dependency (`std` or `core`). | 88 | /// a dependency (`std` or `core`). |
88 | pub(crate) prelude: Option<ModuleId>, | 89 | pub(crate) prelude: Option<ModuleId>, |
89 | pub(crate) extern_prelude: FxHashMap<Name, ModuleDefId>, | 90 | pub(crate) extern_prelude: FxHashMap<Name, ModuleDefId>, |
90 | pub(crate) modules: Arena<LocalModuleId, ModuleData>, | ||
91 | 91 | ||
92 | edition: Edition, | 92 | edition: Edition, |
93 | diagnostics: Vec<DefDiagnostic>, | 93 | diagnostics: Vec<DefDiagnostic>, |
diff --git a/crates/ra_hir_def/src/nameres/tests.rs b/crates/ra_hir_def/src/nameres/tests.rs index f0b86af7c..f502f1cb3 100644 --- a/crates/ra_hir_def/src/nameres/tests.rs +++ b/crates/ra_hir_def/src/nameres/tests.rs | |||
@@ -25,7 +25,7 @@ fn compute_crate_def_map(fixture: &str) -> Arc<CrateDefMap> { | |||
25 | 25 | ||
26 | fn render_crate_def_map(map: &CrateDefMap) -> String { | 26 | fn render_crate_def_map(map: &CrateDefMap) -> String { |
27 | let mut buf = String::new(); | 27 | let mut buf = String::new(); |
28 | go(&mut buf, map, "\ncrate", map.root()); | 28 | go(&mut buf, map, "\ncrate", map.root); |
29 | return buf.trim().to_string(); | 29 | return buf.trim().to_string(); |
30 | 30 | ||
31 | fn go(buf: &mut String, map: &CrateDefMap, path: &str, module: LocalModuleId) { | 31 | fn go(buf: &mut String, map: &CrateDefMap, path: &str, module: LocalModuleId) { |