From 7c0c713a102ee86ee32af115acba63a5c3b3a657 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 5 Apr 2021 03:50:10 +0200 Subject: Intern `GenericParams` Also share the same instance between `ItemTree` and `generic_params` query. --- crates/hir_def/src/item_tree/lower.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/hir_def/src/item_tree') diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs index 0c8112dda..c5629af24 100644 --- a/crates/hir_def/src/item_tree/lower.rs +++ b/crates/hir_def/src/item_tree/lower.rs @@ -434,7 +434,7 @@ impl Ctx { let mut res = Function { name, visibility, - generic_params: GenericParamsId::EMPTY, + generic_params: Interned::new(GenericParams::default()), abi, params, ret_type: Interned::new(ret_type), @@ -682,7 +682,7 @@ impl Ctx { &mut self, owner: GenericsOwner<'_>, node: &impl ast::GenericParamsOwner, - ) -> GenericParamsId { + ) -> Interned { // Generics are part of item headers and may contain inner items we need to collect. if let Some(params) = node.generic_param_list() { self.collect_inner_items(params.syntax()); @@ -698,7 +698,7 @@ impl Ctx { &mut self, owner: GenericsOwner<'_>, node: &impl ast::GenericParamsOwner, - ) -> GenericParamsId { + ) -> Interned { let mut sm = &mut Default::default(); let mut generics = GenericParams::default(); match owner { @@ -740,7 +740,7 @@ impl Ctx { } generics.shrink_to_fit(); - self.data().generics.alloc(generics) + Interned::new(generics) } fn lower_type_bounds(&mut self, node: &impl ast::TypeBoundsOwner) -> Vec { -- cgit v1.2.3