diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-01-21 18:04:58 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-01-21 18:04:58 +0000 |
commit | 7caa9d694a5a6bea567cf3ebd7d7b8ec4cebd06d (patch) | |
tree | faf5ddeff96cb7bb864657e9275cd639adb8f386 /crates/hir_def/src/body | |
parent | e76d8c1d9af2a78a16d25f348c1d69c331349c1f (diff) | |
parent | 3f4f253028e59ed79f1a461e39381ce3a360b7ef (diff) |
Merge #7381
7381: Revert "Make use of `block_def_map` in body lowering" r=jonas-schievink a=jonas-schievink
Reverts rust-analyzer/rust-analyzer#7380, since it broke stuff
bors r+
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_def/src/body')
-rw-r--r-- | crates/hir_def/src/body/lower.rs | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/crates/hir_def/src/body/lower.rs b/crates/hir_def/src/body/lower.rs index 2c8a86723..4ce5e5b72 100644 --- a/crates/hir_def/src/body/lower.rs +++ b/crates/hir_def/src/body/lower.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | //! Transforms `ast::Expr` into an equivalent `hir_def::expr::Expr` | 1 | //! Transforms `ast::Expr` into an equivalent `hir_def::expr::Expr` |
2 | //! representation. | 2 | //! representation. |
3 | 3 | ||
4 | use std::{any::type_name, mem, sync::Arc}; | 4 | use std::{any::type_name, sync::Arc}; |
5 | 5 | ||
6 | use either::Either; | 6 | use either::Either; |
7 | use hir_expand::{ | 7 | use hir_expand::{ |
@@ -559,7 +559,7 @@ impl ExprCollector<'_> { | |||
559 | let outer_file = self.expander.current_file_id; | 559 | let outer_file = self.expander.current_file_id; |
560 | 560 | ||
561 | let macro_call = self.expander.to_source(AstPtr::new(&e)); | 561 | let macro_call = self.expander.to_source(AstPtr::new(&e)); |
562 | let res = self.expander.enter_expand(self.db, e); | 562 | let res = self.expander.enter_expand(self.db, Some(&self.body.item_scope), e); |
563 | 563 | ||
564 | match &res.err { | 564 | match &res.err { |
565 | Some(ExpandError::UnresolvedProcMacro) => { | 565 | Some(ExpandError::UnresolvedProcMacro) => { |
@@ -696,19 +696,11 @@ impl ExprCollector<'_> { | |||
696 | 696 | ||
697 | fn collect_block(&mut self, block: ast::BlockExpr) -> ExprId { | 697 | fn collect_block(&mut self, block: ast::BlockExpr) -> ExprId { |
698 | let syntax_node_ptr = AstPtr::new(&block.clone().into()); | 698 | let syntax_node_ptr = AstPtr::new(&block.clone().into()); |
699 | let ast_id = self.expander.ast_id(&block); | ||
700 | let def_map = self.db.block_def_map(self.expander.module.krate, ast_id); | ||
701 | let prev_def_map = mem::replace(&mut self.expander.def_map, def_map); | ||
702 | |||
703 | self.collect_stmts_items(block.statements()); | 699 | self.collect_stmts_items(block.statements()); |
704 | let statements = | 700 | let statements = |
705 | block.statements().filter_map(|s| self.collect_stmt(s)).flatten().collect(); | 701 | block.statements().filter_map(|s| self.collect_stmt(s)).flatten().collect(); |
706 | let tail = block.tail_expr().map(|e| self.collect_expr(e)); | 702 | let tail = block.tail_expr().map(|e| self.collect_expr(e)); |
707 | let expr_id = | 703 | self.alloc_expr(Expr::Block { statements, tail, label: None }, syntax_node_ptr) |
708 | self.alloc_expr(Expr::Block { statements, tail, label: None }, syntax_node_ptr); | ||
709 | |||
710 | self.expander.def_map = prev_def_map; | ||
711 | expr_id | ||
712 | } | 704 | } |
713 | 705 | ||
714 | fn collect_stmts_items(&mut self, stmts: ast::AstChildren<ast::Stmt>) { | 706 | fn collect_stmts_items(&mut self, stmts: ast::AstChildren<ast::Stmt>) { |
@@ -838,7 +830,7 @@ impl ExprCollector<'_> { | |||
838 | if annotation == BindingAnnotation::Unannotated && subpat.is_none() { | 830 | if annotation == BindingAnnotation::Unannotated && subpat.is_none() { |
839 | // This could also be a single-segment path pattern. To | 831 | // This could also be a single-segment path pattern. To |
840 | // decide that, we need to try resolving the name. | 832 | // decide that, we need to try resolving the name. |
841 | let (resolved, _) = self.expander.def_map.resolve_path( | 833 | let (resolved, _) = self.expander.crate_def_map.resolve_path( |
842 | self.db, | 834 | self.db, |
843 | self.expander.module.local_id, | 835 | self.expander.module.local_id, |
844 | &name.clone().into(), | 836 | &name.clone().into(), |