aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/item_tree/lower.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src/item_tree/lower.rs')
-rw-r--r--crates/hir_def/src/item_tree/lower.rs22
1 files changed, 16 insertions, 6 deletions
diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs
index acc001add..8f2f0b340 100644
--- a/crates/hir_def/src/item_tree/lower.rs
+++ b/crates/hir_def/src/item_tree/lower.rs
@@ -183,6 +183,7 @@ impl Ctx {
183 block_stack.push(self.source_ast_id_map.ast_id(&block)); 183 block_stack.push(self.source_ast_id_map.ast_id(&block));
184 }, 184 },
185 ast::Item(item) => { 185 ast::Item(item) => {
186 // FIXME: This triggers for macro calls in expression position
186 let mod_items = self.lower_mod_item(&item, true); 187 let mod_items = self.lower_mod_item(&item, true);
187 let current_block = block_stack.last(); 188 let current_block = block_stack.last();
188 if let (Some(mod_items), Some(block)) = (mod_items, current_block) { 189 if let (Some(mod_items), Some(block)) = (mod_items, current_block) {
@@ -363,6 +364,7 @@ impl Ctx {
363 params.push(type_ref); 364 params.push(type_ref);
364 } 365 }
365 } 366 }
367 let params = params.into_iter().map(|param| self.data().type_refs.intern(param)).collect();
366 368
367 let mut is_varargs = false; 369 let mut is_varargs = false;
368 if let Some(params) = func.param_list() { 370 if let Some(params) = func.param_list() {
@@ -384,6 +386,8 @@ impl Ctx {
384 ret_type 386 ret_type
385 }; 387 };
386 388
389 let ret_type = self.data().type_refs.intern(ret_type);
390
387 let has_body = func.body().is_some(); 391 let has_body = func.body().is_some();
388 392
389 let ast_id = self.source_ast_id_map.ast_id(func); 393 let ast_id = self.source_ast_id_map.ast_id(func);
@@ -395,7 +399,7 @@ impl Ctx {
395 has_body, 399 has_body,
396 is_unsafe: func.unsafe_token().is_some(), 400 is_unsafe: func.unsafe_token().is_some(),
397 is_extern: false, 401 is_extern: false,
398 params: params.into_boxed_slice(), 402 params,
399 is_varargs, 403 is_varargs,
400 ret_type, 404 ret_type,
401 ast_id, 405 ast_id,
@@ -656,6 +660,7 @@ impl Ctx {
656 generics.fill(&self.body_ctx, sm, node); 660 generics.fill(&self.body_ctx, sm, node);
657 // lower `impl Trait` in arguments 661 // lower `impl Trait` in arguments
658 for param in &*func.params { 662 for param in &*func.params {
663 let param = self.data().type_refs.lookup(*param);
659 generics.fill_implicit_impl_trait_args(param); 664 generics.fill_implicit_impl_trait_args(param);
660 } 665 }
661 } 666 }
@@ -708,11 +713,15 @@ impl Ctx {
708 self.data().vis.alloc(vis) 713 self.data().vis.alloc(vis)
709 } 714 }
710 715
711 fn lower_type_ref(&self, type_ref: &ast::Type) -> TypeRef { 716 fn lower_type_ref(&mut self, type_ref: &ast::Type) -> Idx<TypeRef> {
712 TypeRef::from_ast(&self.body_ctx, type_ref.clone()) 717 let tyref = TypeRef::from_ast(&self.body_ctx, type_ref.clone());
718 self.data().type_refs.intern(tyref)
713 } 719 }
714 fn lower_type_ref_opt(&self, type_ref: Option<ast::Type>) -> TypeRef { 720 fn lower_type_ref_opt(&mut self, type_ref: Option<ast::Type>) -> Idx<TypeRef> {
715 type_ref.map(|ty| self.lower_type_ref(&ty)).unwrap_or(TypeRef::Error) 721 match type_ref.map(|ty| self.lower_type_ref(&ty)) {
722 Some(it) => it,
723 None => self.data().type_refs.intern(TypeRef::Error),
724 }
716 } 725 }
717 726
718 /// Forces the visibility `vis` to be used for all items lowered during execution of `f`. 727 /// Forces the visibility `vis` to be used for all items lowered during execution of `f`.
@@ -741,7 +750,8 @@ impl Ctx {
741 750
742fn desugar_future_path(orig: TypeRef) -> Path { 751fn desugar_future_path(orig: TypeRef) -> Path {
743 let path = path![core::future::Future]; 752 let path = path![core::future::Future];
744 let mut generic_args: Vec<_> = std::iter::repeat(None).take(path.segments.len() - 1).collect(); 753 let mut generic_args: Vec<_> =
754 std::iter::repeat(None).take(path.segments().len() - 1).collect();
745 let mut last = GenericArgs::empty(); 755 let mut last = GenericArgs::empty();
746 let binding = 756 let binding =
747 AssociatedTypeBinding { name: name![Output], type_ref: Some(orig), bounds: Vec::new() }; 757 AssociatedTypeBinding { name: name![Output], type_ref: Some(orig), bounds: Vec::new() };