diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_cli/src/analysis_stats.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/expr.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/test_db.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/infer.rs | 4 | ||||
-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 |
8 files changed, 17 insertions, 33 deletions
diff --git a/crates/ra_cli/src/analysis_stats.rs b/crates/ra_cli/src/analysis_stats.rs index 9cd21e4b6..135de7ffb 100644 --- a/crates/ra_cli/src/analysis_stats.rs +++ b/crates/ra_cli/src/analysis_stats.rs | |||
@@ -109,7 +109,7 @@ pub fn run( | |||
109 | } | 109 | } |
110 | let body = f.body(db); | 110 | let body = f.body(db); |
111 | let inference_result = f.infer(db); | 111 | let inference_result = f.infer(db); |
112 | for (expr_id, _) in body.exprs() { | 112 | for (expr_id, _) in body.exprs.iter() { |
113 | let ty = &inference_result[expr_id]; | 113 | let ty = &inference_result[expr_id]; |
114 | num_exprs += 1; | 114 | num_exprs += 1; |
115 | if let Ty::Unknown = ty { | 115 | if let Ty::Unknown = ty { |
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index 6b703d8b4..43fedde7a 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -44,15 +44,15 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
44 | pub(crate) fn validate_body(&mut self, db: &impl HirDatabase) { | 44 | pub(crate) fn validate_body(&mut self, db: &impl HirDatabase) { |
45 | let body = self.func.body(db); | 45 | let body = self.func.body(db); |
46 | 46 | ||
47 | for e in body.exprs() { | 47 | for e in body.exprs.iter() { |
48 | if let (id, Expr::RecordLit { path, fields, spread }) = e { | 48 | if let (id, Expr::RecordLit { path, fields, spread }) = e { |
49 | self.validate_record_literal(id, path, fields, *spread, db); | 49 | self.validate_record_literal(id, path, fields, *spread, db); |
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
53 | let body_expr = &body[body.body_expr()]; | 53 | let body_expr = &body[body.body_expr]; |
54 | if let Expr::Block { statements: _, tail: Some(t) } = body_expr { | 54 | if let Expr::Block { statements: _, tail: Some(t) } = body_expr { |
55 | self.validate_results_in_tail_expr(body.body_expr(), *t, db); | 55 | self.validate_results_in_tail_expr(body.body_expr, *t, db); |
56 | } | 56 | } |
57 | } | 57 | } |
58 | 58 | ||
diff --git a/crates/ra_hir/src/test_db.rs b/crates/ra_hir/src/test_db.rs index 03c7ac155..efee2f658 100644 --- a/crates/ra_hir/src/test_db.rs +++ b/crates/ra_hir/src/test_db.rs | |||
@@ -80,7 +80,7 @@ impl TestDB { | |||
80 | let crate_graph = self.crate_graph(); | 80 | let crate_graph = self.crate_graph(); |
81 | for krate in crate_graph.iter().next() { | 81 | for krate in crate_graph.iter().next() { |
82 | let crate_def_map = self.crate_def_map(krate); | 82 | let crate_def_map = self.crate_def_map(krate); |
83 | for module_id in crate_def_map.modules() { | 83 | for (module_id, _) in crate_def_map.modules.iter() { |
84 | let module_id = ModuleId { krate, module_id }; | 84 | let module_id = ModuleId { krate, module_id }; |
85 | let module = crate::Module::from(module_id); | 85 | let module = crate::Module::from(module_id); |
86 | module.diagnostics( | 86 | module.diagnostics( |
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index 471bdc387..2e744e5ec 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs | |||
@@ -565,7 +565,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
565 | 565 | ||
566 | fn collect_fn(&mut self, data: &FunctionData) { | 566 | fn collect_fn(&mut self, data: &FunctionData) { |
567 | let body = Arc::clone(&self.body); // avoid borrow checker problem | 567 | let body = Arc::clone(&self.body); // avoid borrow checker problem |
568 | for (type_ref, pat) in data.params.iter().zip(body.params()) { | 568 | for (type_ref, pat) in data.params.iter().zip(body.params.iter()) { |
569 | let ty = self.make_ty(type_ref); | 569 | let ty = self.make_ty(type_ref); |
570 | 570 | ||
571 | self.infer_pat(*pat, &ty, BindingMode::default()); | 571 | self.infer_pat(*pat, &ty, BindingMode::default()); |
@@ -574,7 +574,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
574 | } | 574 | } |
575 | 575 | ||
576 | fn infer_body(&mut self) { | 576 | fn infer_body(&mut self) { |
577 | self.infer_expr(self.body.body_expr(), &Expectation::has_type(self.return_ty.clone())); | 577 | self.infer_expr(self.body.body_expr, &Expectation::has_type(self.return_ty.clone())); |
578 | } | 578 | } |
579 | 579 | ||
580 | fn resolve_into_iter_item(&self) -> Option<TypeAlias> { | 580 | fn resolve_into_iter_item(&self) -> Option<TypeAlias> { |
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) { |