aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/expr.rs139
1 files changed, 79 insertions, 60 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs
index 817e660f9..7759a6d4f 100644
--- a/crates/ra_hir/src/expr.rs
+++ b/crates/ra_hir/src/expr.rs
@@ -12,6 +12,7 @@ use ra_syntax::{
12use crate::{ 12use crate::{
13 Path, Name, HirDatabase, Resolver,DefWithBody, Either, 13 Path, Name, HirDatabase, Resolver,DefWithBody, Either,
14 name::AsName, 14 name::AsName,
15 ids::MacroDefId,
15 type_ref::{Mutability, TypeRef}, 16 type_ref::{Mutability, TypeRef},
16}; 17};
17use crate::{path::GenericArgs, ty::primitive::{IntTy, UncertainIntTy, FloatTy, UncertainFloatTy}}; 18use crate::{path::GenericArgs, ty::primitive::{IntTy, UncertainIntTy, FloatTy, UncertainFloatTy}};
@@ -485,17 +486,20 @@ pub(crate) struct ExprCollector {
485 source_map: BodySourceMap, 486 source_map: BodySourceMap,
486 params: Vec<PatId>, 487 params: Vec<PatId>,
487 body_expr: Option<ExprId>, 488 body_expr: Option<ExprId>,
489 resolver: Resolver,
488} 490}
489 491
490impl ExprCollector { 492impl ExprCollector{
491 fn new(owner: DefWithBody) -> Self { 493 fn new(owner: DefWithBody,resolver:Resolver) -> Self {
492 ExprCollector { 494 ExprCollector {
493 owner, 495 owner,
496 resolver,
494 exprs: Arena::default(), 497 exprs: Arena::default(),
495 pats: Arena::default(), 498 pats: Arena::default(),
496 source_map: BodySourceMap::default(), 499 source_map: BodySourceMap::default(),
497 params: Vec::new(), 500 params: Vec::new(),
498 body_expr: None, 501 body_expr: None,
502
499 } 503 }
500 } 504 }
501 505
@@ -518,7 +522,7 @@ impl ExprCollector {
518 self.exprs.alloc(block) 522 self.exprs.alloc(block)
519 } 523 }
520 524
521 fn collect_expr(&mut self, expr: &ast::Expr) -> ExprId { 525 fn collect_expr(&mut self, expr: &ast::Expr,db:&impl HirDatabase) -> ExprId {
522 let syntax_ptr = SyntaxNodePtr::new(expr.syntax()); 526 let syntax_ptr = SyntaxNodePtr::new(expr.syntax());
523 match expr.kind() { 527 match expr.kind() {
524 ast::ExprKind::IfExpr(e) => { 528 ast::ExprKind::IfExpr(e) => {
@@ -526,15 +530,15 @@ impl ExprCollector {
526 // if let -- desugar to match 530 // if let -- desugar to match
527 let pat = self.collect_pat(pat); 531 let pat = self.collect_pat(pat);
528 let match_expr = 532 let match_expr =
529 self.collect_expr_opt(e.condition().expect("checked above").expr()); 533 self.collect_expr_opt(e.condition().expect("checked above").expr(),db);
530 let then_branch = self.collect_block_opt(e.then_branch()); 534 let then_branch = self.collect_block_opt(e.then_branch(),db);
531 let else_branch = e 535 let else_branch = e
532 .else_branch() 536 .else_branch()
533 .map(|b| match b { 537 .map(|b| match b {
534 ast::ElseBranch::Block(it) => self.collect_block(it), 538 ast::ElseBranch::Block(it) => self.collect_block(it,db),
535 ast::ElseBranch::IfExpr(elif) => { 539 ast::ElseBranch::IfExpr(elif) => {
536 let expr: &ast::Expr = ast::Expr::cast(elif.syntax()).unwrap(); 540 let expr: &ast::Expr = ast::Expr::cast(elif.syntax()).unwrap();
537 self.collect_expr(expr) 541 self.collect_expr(expr,db)
538 } 542 }
539 }) 543 })
540 .unwrap_or_else(|| self.empty_block()); 544 .unwrap_or_else(|| self.empty_block());
@@ -545,27 +549,27 @@ impl ExprCollector {
545 ]; 549 ];
546 self.alloc_expr(Expr::Match { expr: match_expr, arms }, syntax_ptr) 550 self.alloc_expr(Expr::Match { expr: match_expr, arms }, syntax_ptr)
547 } else { 551 } else {
548 let condition = self.collect_expr_opt(e.condition().and_then(|c| c.expr())); 552 let condition = self.collect_expr_opt(e.condition().and_then(|c| c.expr()),db);
549 let then_branch = self.collect_block_opt(e.then_branch()); 553 let then_branch = self.collect_block_opt(e.then_branch(),db);
550 let else_branch = e.else_branch().map(|b| match b { 554 let else_branch = e.else_branch().map(|b| match b {
551 ast::ElseBranch::Block(it) => self.collect_block(it), 555 ast::ElseBranch::Block(it) => self.collect_block(it,db),
552 ast::ElseBranch::IfExpr(elif) => { 556 ast::ElseBranch::IfExpr(elif) => {
553 let expr: &ast::Expr = ast::Expr::cast(elif.syntax()).unwrap(); 557 let expr: &ast::Expr = ast::Expr::cast(elif.syntax()).unwrap();
554 self.collect_expr(expr) 558 self.collect_expr(expr,db)
555 } 559 }
556 }); 560 });
557 self.alloc_expr(Expr::If { condition, then_branch, else_branch }, syntax_ptr) 561 self.alloc_expr(Expr::If { condition, then_branch, else_branch }, syntax_ptr)
558 } 562 }
559 } 563 }
560 ast::ExprKind::BlockExpr(e) => self.collect_block_opt(e.block()), 564 ast::ExprKind::BlockExpr(e) => self.collect_block_opt(e.block(),db),
561 ast::ExprKind::LoopExpr(e) => { 565 ast::ExprKind::LoopExpr(e) => {
562 let body = self.collect_block_opt(e.loop_body()); 566 let body = self.collect_block_opt(e.loop_body(),db);
563 self.alloc_expr(Expr::Loop { body }, syntax_ptr) 567 self.alloc_expr(Expr::Loop { body }, syntax_ptr)
564 } 568 }
565 ast::ExprKind::WhileExpr(e) => { 569 ast::ExprKind::WhileExpr(e) => {
566 let condition = if let Some(condition) = e.condition() { 570 let condition = if let Some(condition) = e.condition() {
567 if condition.pat().is_none() { 571 if condition.pat().is_none() {
568 self.collect_expr_opt(condition.expr()) 572 self.collect_expr_opt(condition.expr(),db)
569 } else { 573 } else {
570 // FIXME handle while let 574 // FIXME handle while let
571 return self.alloc_expr(Expr::Missing, syntax_ptr); 575 return self.alloc_expr(Expr::Missing, syntax_ptr);
@@ -573,28 +577,28 @@ impl ExprCollector {
573 } else { 577 } else {
574 self.exprs.alloc(Expr::Missing) 578 self.exprs.alloc(Expr::Missing)
575 }; 579 };
576 let body = self.collect_block_opt(e.loop_body()); 580 let body = self.collect_block_opt(e.loop_body(),db);
577 self.alloc_expr(Expr::While { condition, body }, syntax_ptr) 581 self.alloc_expr(Expr::While { condition, body }, syntax_ptr)
578 } 582 }
579 ast::ExprKind::ForExpr(e) => { 583 ast::ExprKind::ForExpr(e) => {
580 let iterable = self.collect_expr_opt(e.iterable()); 584 let iterable = self.collect_expr_opt(e.iterable(),db);
581 let pat = self.collect_pat_opt(e.pat()); 585 let pat = self.collect_pat_opt(e.pat());
582 let body = self.collect_block_opt(e.loop_body()); 586 let body = self.collect_block_opt(e.loop_body(),db);
583 self.alloc_expr(Expr::For { iterable, pat, body }, syntax_ptr) 587 self.alloc_expr(Expr::For { iterable, pat, body }, syntax_ptr)
584 } 588 }
585 ast::ExprKind::CallExpr(e) => { 589 ast::ExprKind::CallExpr(e) => {
586 let callee = self.collect_expr_opt(e.expr()); 590 let callee = self.collect_expr_opt(e.expr(),db);
587 let args = if let Some(arg_list) = e.arg_list() { 591 let args = if let Some(arg_list) = e.arg_list() {
588 arg_list.args().map(|e| self.collect_expr(e)).collect() 592 arg_list.args().map(|e| self.collect_expr(e,db)).collect()
589 } else { 593 } else {
590 Vec::new() 594 Vec::new()
591 }; 595 };
592 self.alloc_expr(Expr::Call { callee, args }, syntax_ptr) 596 self.alloc_expr(Expr::Call { callee, args }, syntax_ptr)
593 } 597 }
594 ast::ExprKind::MethodCallExpr(e) => { 598 ast::ExprKind::MethodCallExpr(e) => {
595 let receiver = self.collect_expr_opt(e.expr()); 599 let receiver = self.collect_expr_opt(e.expr(),db);
596 let args = if let Some(arg_list) = e.arg_list() { 600 let args = if let Some(arg_list) = e.arg_list() {
597 arg_list.args().map(|e| self.collect_expr(e)).collect() 601 arg_list.args().map(|e| self.collect_expr(e,db)).collect()
598 } else { 602 } else {
599 Vec::new() 603 Vec::new()
600 }; 604 };
@@ -606,17 +610,17 @@ impl ExprCollector {
606 ) 610 )
607 } 611 }
608 ast::ExprKind::MatchExpr(e) => { 612 ast::ExprKind::MatchExpr(e) => {
609 let expr = self.collect_expr_opt(e.expr()); 613 let expr = self.collect_expr_opt(e.expr(),db);
610 let arms = if let Some(match_arm_list) = e.match_arm_list() { 614 let arms = if let Some(match_arm_list) = e.match_arm_list() {
611 match_arm_list 615 match_arm_list
612 .arms() 616 .arms()
613 .map(|arm| MatchArm { 617 .map(|arm| MatchArm {
614 pats: arm.pats().map(|p| self.collect_pat(p)).collect(), 618 pats: arm.pats().map(|p| self.collect_pat(p)).collect(),
615 expr: self.collect_expr_opt(arm.expr()), 619 expr: self.collect_expr_opt(arm.expr(),db),
616 guard: arm 620 guard: arm
617 .guard() 621 .guard()
618 .and_then(|guard| guard.expr()) 622 .and_then(|guard| guard.expr())
619 .map(|e| self.collect_expr(e)), 623 .map(|e| self.collect_expr(e,db)),
620 }) 624 })
621 .collect() 625 .collect()
622 } else { 626 } else {
@@ -634,17 +638,17 @@ impl ExprCollector {
634 self.alloc_expr(Expr::Continue, syntax_ptr) 638 self.alloc_expr(Expr::Continue, syntax_ptr)
635 } 639 }
636 ast::ExprKind::BreakExpr(e) => { 640 ast::ExprKind::BreakExpr(e) => {
637 let expr = e.expr().map(|e| self.collect_expr(e)); 641 let expr = e.expr().map(|e| self.collect_expr(e,db));
638 self.alloc_expr(Expr::Break { expr }, syntax_ptr) 642 self.alloc_expr(Expr::Break { expr }, syntax_ptr)
639 } 643 }
640 ast::ExprKind::ParenExpr(e) => { 644 ast::ExprKind::ParenExpr(e) => {
641 let inner = self.collect_expr_opt(e.expr()); 645 let inner = self.collect_expr_opt(e.expr(),db);
642 // make the paren expr point to the inner expression as well 646 // make the paren expr point to the inner expression as well
643 self.source_map.expr_map.insert(syntax_ptr, inner); 647 self.source_map.expr_map.insert(syntax_ptr, inner);
644 inner 648 inner
645 } 649 }
646 ast::ExprKind::ReturnExpr(e) => { 650 ast::ExprKind::ReturnExpr(e) => {
647 let expr = e.expr().map(|e| self.collect_expr(e)); 651 let expr = e.expr().map(|e| self.collect_expr(e,db));
648 self.alloc_expr(Expr::Return { expr }, syntax_ptr) 652 self.alloc_expr(Expr::Return { expr }, syntax_ptr)
649 } 653 }
650 ast::ExprKind::StructLit(e) => { 654 ast::ExprKind::StructLit(e) => {
@@ -659,7 +663,7 @@ impl ExprCollector {
659 .map(|nr| nr.as_name()) 663 .map(|nr| nr.as_name())
660 .unwrap_or_else(Name::missing), 664 .unwrap_or_else(Name::missing),
661 expr: if let Some(e) = field.expr() { 665 expr: if let Some(e) = field.expr() {
662 self.collect_expr(e) 666 self.collect_expr(e,db)
663 } else if let Some(nr) = field.name_ref() { 667 } else if let Some(nr) = field.name_ref() {
664 // field shorthand 668 // field shorthand
665 let id = self.exprs.alloc(Expr::Path(Path::from_name_ref(nr))); 669 let id = self.exprs.alloc(Expr::Path(Path::from_name_ref(nr)));
@@ -678,7 +682,7 @@ impl ExprCollector {
678 } else { 682 } else {
679 Vec::new() 683 Vec::new()
680 }; 684 };
681 let spread = e.spread().map(|s| self.collect_expr(s)); 685 let spread = e.spread().map(|s| self.collect_expr(s,db));
682 let res = self.alloc_expr(Expr::StructLit { path, fields, spread }, syntax_ptr); 686 let res = self.alloc_expr(Expr::StructLit { path, fields, spread }, syntax_ptr);
683 for (i, ptr) in field_ptrs.into_iter().enumerate() { 687 for (i, ptr) in field_ptrs.into_iter().enumerate() {
684 self.source_map.field_map.insert((res, i), ptr); 688 self.source_map.field_map.insert((res, i), ptr);
@@ -686,7 +690,7 @@ impl ExprCollector {
686 res 690 res
687 } 691 }
688 ast::ExprKind::FieldExpr(e) => { 692 ast::ExprKind::FieldExpr(e) => {
689 let expr = self.collect_expr_opt(e.expr()); 693 let expr = self.collect_expr_opt(e.expr(),db);
690 let name = match e.field_access() { 694 let name = match e.field_access() {
691 Some(kind) => kind.as_name(), 695 Some(kind) => kind.as_name(),
692 _ => Name::missing(), 696 _ => Name::missing(),
@@ -694,21 +698,21 @@ impl ExprCollector {
694 self.alloc_expr(Expr::Field { expr, name }, syntax_ptr) 698 self.alloc_expr(Expr::Field { expr, name }, syntax_ptr)
695 } 699 }
696 ast::ExprKind::TryExpr(e) => { 700 ast::ExprKind::TryExpr(e) => {
697 let expr = self.collect_expr_opt(e.expr()); 701 let expr = self.collect_expr_opt(e.expr(),db);
698 self.alloc_expr(Expr::Try { expr }, syntax_ptr) 702 self.alloc_expr(Expr::Try { expr }, syntax_ptr)
699 } 703 }
700 ast::ExprKind::CastExpr(e) => { 704 ast::ExprKind::CastExpr(e) => {
701 let expr = self.collect_expr_opt(e.expr()); 705 let expr = self.collect_expr_opt(e.expr(),db);
702 let type_ref = TypeRef::from_ast_opt(e.type_ref()); 706 let type_ref = TypeRef::from_ast_opt(e.type_ref());
703 self.alloc_expr(Expr::Cast { expr, type_ref }, syntax_ptr) 707 self.alloc_expr(Expr::Cast { expr, type_ref }, syntax_ptr)
704 } 708 }
705 ast::ExprKind::RefExpr(e) => { 709 ast::ExprKind::RefExpr(e) => {
706 let expr = self.collect_expr_opt(e.expr()); 710 let expr = self.collect_expr_opt(e.expr(),db);
707 let mutability = Mutability::from_mutable(e.is_mut()); 711 let mutability = Mutability::from_mutable(e.is_mut());
708 self.alloc_expr(Expr::Ref { expr, mutability }, syntax_ptr) 712 self.alloc_expr(Expr::Ref { expr, mutability }, syntax_ptr)
709 } 713 }
710 ast::ExprKind::PrefixExpr(e) => { 714 ast::ExprKind::PrefixExpr(e) => {
711 let expr = self.collect_expr_opt(e.expr()); 715 let expr = self.collect_expr_opt(e.expr(),db);
712 if let Some(op) = e.op_kind() { 716 if let Some(op) = e.op_kind() {
713 self.alloc_expr(Expr::UnaryOp { expr, op }, syntax_ptr) 717 self.alloc_expr(Expr::UnaryOp { expr, op }, syntax_ptr)
714 } else { 718 } else {
@@ -726,17 +730,17 @@ impl ExprCollector {
726 arg_types.push(type_ref); 730 arg_types.push(type_ref);
727 } 731 }
728 } 732 }
729 let body = self.collect_expr_opt(e.body()); 733 let body = self.collect_expr_opt(e.body(),db);
730 self.alloc_expr(Expr::Lambda { args, arg_types, body }, syntax_ptr) 734 self.alloc_expr(Expr::Lambda { args, arg_types, body }, syntax_ptr)
731 } 735 }
732 ast::ExprKind::BinExpr(e) => { 736 ast::ExprKind::BinExpr(e) => {
733 let lhs = self.collect_expr_opt(e.lhs()); 737 let lhs = self.collect_expr_opt(e.lhs(),db);
734 let rhs = self.collect_expr_opt(e.rhs()); 738 let rhs = self.collect_expr_opt(e.rhs(),db);
735 let op = e.op_kind(); 739 let op = e.op_kind();
736 self.alloc_expr(Expr::BinaryOp { lhs, rhs, op }, syntax_ptr) 740 self.alloc_expr(Expr::BinaryOp { lhs, rhs, op }, syntax_ptr)
737 } 741 }
738 ast::ExprKind::TupleExpr(e) => { 742 ast::ExprKind::TupleExpr(e) => {
739 let exprs = e.exprs().map(|expr| self.collect_expr(expr)).collect(); 743 let exprs = e.exprs().map(|expr| self.collect_expr(expr,db)).collect();
740 self.alloc_expr(Expr::Tuple { exprs }, syntax_ptr) 744 self.alloc_expr(Expr::Tuple { exprs }, syntax_ptr)
741 } 745 }
742 746
@@ -745,12 +749,12 @@ impl ExprCollector {
745 749
746 match kind { 750 match kind {
747 ArrayExprKind::ElementList(e) => { 751 ArrayExprKind::ElementList(e) => {
748 let exprs = e.map(|expr| self.collect_expr(expr)).collect(); 752 let exprs = e.map(|expr| self.collect_expr(expr,db)).collect();
749 self.alloc_expr(Expr::Array(Array::ElementList(exprs)), syntax_ptr) 753 self.alloc_expr(Expr::Array(Array::ElementList(exprs)), syntax_ptr)
750 } 754 }
751 ArrayExprKind::Repeat { initializer, repeat } => { 755 ArrayExprKind::Repeat { initializer, repeat } => {
752 let initializer = self.collect_expr_opt(initializer); 756 let initializer = self.collect_expr_opt(initializer,db);
753 let repeat = self.collect_expr_opt(repeat); 757 let repeat = self.collect_expr_opt(repeat,db);
754 self.alloc_expr( 758 self.alloc_expr(
755 Expr::Array(Array::Repeat { initializer, repeat }), 759 Expr::Array(Array::Repeat { initializer, repeat }),
756 syntax_ptr, 760 syntax_ptr,
@@ -794,40 +798,53 @@ impl ExprCollector {
794 ast::ExprKind::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), 798 ast::ExprKind::Label(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
795 ast::ExprKind::IndexExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), 799 ast::ExprKind::IndexExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
796 ast::ExprKind::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), 800 ast::ExprKind::RangeExpr(_e) => self.alloc_expr(Expr::Missing, syntax_ptr),
797 ast::ExprKind::MacroCall(_e) => self.alloc_expr(Expr::Missing, syntax_ptr), 801 ast::ExprKind::MacroCall(e) => {
802
803 let name = e.name().map(|nr| nr.as_name()).unwrap_or_else(Name::missing);
804
805 let res = self.resolver.resolve_name(db,&name);
806
807 // match res {
808
809 // }
810
811 // let resolver = Resolver
812
813 self.alloc_expr(Expr::Missing, syntax_ptr)
814 },
798 } 815 }
799 } 816 }
800 817
801 fn collect_expr_opt(&mut self, expr: Option<&ast::Expr>) -> ExprId { 818 fn collect_expr_opt(&mut self, expr: Option<&ast::Expr>,db:&impl HirDatabase) -> ExprId {
802 if let Some(expr) = expr { 819 if let Some(expr) = expr {
803 self.collect_expr(expr) 820 self.collect_expr(expr,db)
804 } else { 821 } else {
805 self.exprs.alloc(Expr::Missing) 822 self.exprs.alloc(Expr::Missing)
806 } 823 }
807 } 824 }
808 825
809 fn collect_block(&mut self, block: &ast::Block) -> ExprId { 826 fn collect_block(&mut self, block: &ast::Block,db:&impl HirDatabase) -> ExprId {
810 let statements = block 827 let statements = block
811 .statements() 828 .statements()
812 .map(|s| match s.kind() { 829 .map(|s| match s.kind() {
813 ast::StmtKind::LetStmt(stmt) => { 830 ast::StmtKind::LetStmt(stmt) => {
814 let pat = self.collect_pat_opt(stmt.pat()); 831 let pat = self.collect_pat_opt(stmt.pat());
815 let type_ref = stmt.ascribed_type().map(TypeRef::from_ast); 832 let type_ref = stmt.ascribed_type().map(TypeRef::from_ast);
816 let initializer = stmt.initializer().map(|e| self.collect_expr(e)); 833 let initializer = stmt.initializer().map(|e| self.collect_expr(e,db));
817 Statement::Let { pat, type_ref, initializer } 834 Statement::Let { pat, type_ref, initializer }
818 } 835 }
819 ast::StmtKind::ExprStmt(stmt) => { 836 ast::StmtKind::ExprStmt(stmt) => {
820 Statement::Expr(self.collect_expr_opt(stmt.expr())) 837 Statement::Expr(self.collect_expr_opt(stmt.expr(),db))
821 } 838 }
822 }) 839 })
823 .collect(); 840 .collect();
824 let tail = block.expr().map(|e| self.collect_expr(e)); 841 let tail = block.expr().map(|e| self.collect_expr(e,db));
825 self.alloc_expr(Expr::Block { statements, tail }, SyntaxNodePtr::new(block.syntax())) 842 self.alloc_expr(Expr::Block { statements, tail }, SyntaxNodePtr::new(block.syntax()))
826 } 843 }
827 844
828 fn collect_block_opt(&mut self, block: Option<&ast::Block>) -> ExprId { 845 fn collect_block_opt(&mut self, block: Option<&ast::Block>,db:&impl HirDatabase) -> ExprId {
829 if let Some(block) = block { 846 if let Some(block) = block {
830 self.collect_block(block) 847 self.collect_block(block,db)
831 } else { 848 } else {
832 self.exprs.alloc(Expr::Missing) 849 self.exprs.alloc(Expr::Missing)
833 } 850 }
@@ -900,17 +917,17 @@ impl ExprCollector {
900 } 917 }
901 } 918 }
902 919
903 fn collect_const_body(&mut self, node: &ast::ConstDef) { 920 fn collect_const_body(&mut self, node: &ast::ConstDef,db:&impl HirDatabase) {
904 let body = self.collect_expr_opt(node.body()); 921 let body = self.collect_expr_opt(node.body(),db);
905 self.body_expr = Some(body); 922 self.body_expr = Some(body);
906 } 923 }
907 924
908 fn collect_static_body(&mut self, node: &ast::StaticDef) { 925 fn collect_static_body(&mut self, node: &ast::StaticDef,db:&impl HirDatabase) {
909 let body = self.collect_expr_opt(node.body()); 926 let body = self.collect_expr_opt(node.body(),db);
910 self.body_expr = Some(body); 927 self.body_expr = Some(body);
911 } 928 }
912 929
913 fn collect_fn_body(&mut self, node: &ast::FnDef) { 930 fn collect_fn_body(&mut self, node: &ast::FnDef,db:&impl HirDatabase) {
914 if let Some(param_list) = node.param_list() { 931 if let Some(param_list) = node.param_list() {
915 if let Some(self_param) = param_list.self_param() { 932 if let Some(self_param) = param_list.self_param() {
916 let ptr = AstPtr::new(self_param); 933 let ptr = AstPtr::new(self_param);
@@ -936,7 +953,7 @@ impl ExprCollector {
936 } 953 }
937 }; 954 };
938 955
939 let body = self.collect_block_opt(node.body()); 956 let body = self.collect_block_opt(node.body(),db);
940 self.body_expr = Some(body); 957 self.body_expr = Some(body);
941 } 958 }
942 959
@@ -956,12 +973,14 @@ pub(crate) fn body_with_source_map_query(
956 db: &impl HirDatabase, 973 db: &impl HirDatabase,
957 def: DefWithBody, 974 def: DefWithBody,
958) -> (Arc<Body>, Arc<BodySourceMap>) { 975) -> (Arc<Body>, Arc<BodySourceMap>) {
959 let mut collector = ExprCollector::new(def); 976
977 let mut resolver = def.resolver(db);
978 let mut collector = ExprCollector::new(def,resolver);
960 979
961 match def { 980 match def {
962 DefWithBody::Const(ref c) => collector.collect_const_body(&c.source(db).1), 981 DefWithBody::Const(ref c) => collector.collect_const_body(&c.source(db).1,db),
963 DefWithBody::Function(ref f) => collector.collect_fn_body(&f.source(db).1), 982 DefWithBody::Function(ref f) => collector.collect_fn_body(&f.source(db).1,db),
964 DefWithBody::Static(ref s) => collector.collect_static_body(&s.source(db).1), 983 DefWithBody::Static(ref s) => collector.collect_static_body(&s.source(db).1,db),
965 } 984 }
966 985
967 let (body, source_map) = collector.finish(); 986 let (body, source_map) = collector.finish();