diff options
Diffstat (limited to 'crates/hir_def/src/item_tree')
-rw-r--r-- | crates/hir_def/src/item_tree/lower.rs | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index 124dcc866..23d3dea7b 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs | |||
@@ -362,7 +362,7 @@ impl Ctx { | |||
362 | } | 362 | } |
363 | } | 363 | } |
364 | }; | 364 | }; |
365 | let ty = self.data().type_refs.intern(self_type); | 365 | let ty = Interned::new(self_type); |
366 | let idx = self.data().params.alloc(Param::Normal(ty)); | 366 | let idx = self.data().params.alloc(Param::Normal(ty)); |
367 | self.add_attrs(idx.into(), RawAttrs::new(&self_param, &self.hygiene)); | 367 | self.add_attrs(idx.into(), RawAttrs::new(&self_param, &self.hygiene)); |
368 | has_self_param = true; | 368 | has_self_param = true; |
@@ -372,7 +372,7 @@ impl Ctx { | |||
372 | Some(_) => self.data().params.alloc(Param::Varargs), | 372 | Some(_) => self.data().params.alloc(Param::Varargs), |
373 | None => { | 373 | None => { |
374 | let type_ref = TypeRef::from_ast_opt(&self.body_ctx, param.ty()); | 374 | let type_ref = TypeRef::from_ast_opt(&self.body_ctx, param.ty()); |
375 | let ty = self.data().type_refs.intern(type_ref); | 375 | let ty = Interned::new(type_ref); |
376 | self.data().params.alloc(Param::Normal(ty)) | 376 | self.data().params.alloc(Param::Normal(ty)) |
377 | } | 377 | } |
378 | }; | 378 | }; |
@@ -395,8 +395,6 @@ impl Ctx { | |||
395 | ret_type | 395 | ret_type |
396 | }; | 396 | }; |
397 | 397 | ||
398 | let ret_type = self.data().type_refs.intern(ret_type); | ||
399 | |||
400 | let has_body = func.body().is_some(); | 398 | let has_body = func.body().is_some(); |
401 | 399 | ||
402 | let ast_id = self.source_ast_id_map.ast_id(func); | 400 | let ast_id = self.source_ast_id_map.ast_id(func); |
@@ -428,7 +426,7 @@ impl Ctx { | |||
428 | qualifier, | 426 | qualifier, |
429 | is_in_extern_block: false, | 427 | is_in_extern_block: false, |
430 | params, | 428 | params, |
431 | ret_type, | 429 | ret_type: Interned::new(ret_type), |
432 | ast_id, | 430 | ast_id, |
433 | }; | 431 | }; |
434 | res.generic_params = self.lower_generic_params(GenericsOwner::Function(&res), func); | 432 | res.generic_params = self.lower_generic_params(GenericsOwner::Function(&res), func); |
@@ -694,8 +692,7 @@ impl Ctx { | |||
694 | generics.fill(&self.body_ctx, sm, node); | 692 | generics.fill(&self.body_ctx, sm, node); |
695 | // lower `impl Trait` in arguments | 693 | // lower `impl Trait` in arguments |
696 | for id in func.params.clone() { | 694 | for id in func.params.clone() { |
697 | if let Param::Normal(ty) = self.data().params[id] { | 695 | if let Param::Normal(ty) = &self.data().params[id] { |
698 | let ty = self.data().type_refs.lookup(ty); | ||
699 | generics.fill_implicit_impl_trait_args(ty); | 696 | generics.fill_implicit_impl_trait_args(ty); |
700 | } | 697 | } |
701 | } | 698 | } |
@@ -749,20 +746,20 @@ impl Ctx { | |||
749 | self.data().vis.alloc(vis) | 746 | self.data().vis.alloc(vis) |
750 | } | 747 | } |
751 | 748 | ||
752 | fn lower_trait_ref(&mut self, trait_ref: &ast::Type) -> Option<Idx<TraitRef>> { | 749 | fn lower_trait_ref(&mut self, trait_ref: &ast::Type) -> Option<Interned<TraitRef>> { |
753 | let trait_ref = TraitRef::from_ast(&self.body_ctx, trait_ref.clone())?; | 750 | let trait_ref = TraitRef::from_ast(&self.body_ctx, trait_ref.clone())?; |
754 | Some(self.data().trait_refs.intern(trait_ref)) | 751 | Some(Interned::new(trait_ref)) |
755 | } | 752 | } |
756 | 753 | ||
757 | fn lower_type_ref(&mut self, type_ref: &ast::Type) -> Idx<TypeRef> { | 754 | fn lower_type_ref(&mut self, type_ref: &ast::Type) -> Interned<TypeRef> { |
758 | let tyref = TypeRef::from_ast(&self.body_ctx, type_ref.clone()); | 755 | let tyref = TypeRef::from_ast(&self.body_ctx, type_ref.clone()); |
759 | self.data().type_refs.intern(tyref) | 756 | Interned::new(tyref) |
760 | } | 757 | } |
761 | 758 | ||
762 | fn lower_type_ref_opt(&mut self, type_ref: Option<ast::Type>) -> Idx<TypeRef> { | 759 | fn lower_type_ref_opt(&mut self, type_ref: Option<ast::Type>) -> Interned<TypeRef> { |
763 | match type_ref.map(|ty| self.lower_type_ref(&ty)) { | 760 | match type_ref.map(|ty| self.lower_type_ref(&ty)) { |
764 | Some(it) => it, | 761 | Some(it) => it, |
765 | None => self.data().type_refs.intern(TypeRef::Error), | 762 | None => Interned::new(TypeRef::Error), |
766 | } | 763 | } |
767 | } | 764 | } |
768 | 765 | ||