From 94169ee504bf1a5e59530c1ab1f5f5550ae45914 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 24 Jun 2020 16:07:02 +0200 Subject: ItemTree: Use more boxed slices --- crates/ra_hir_def/src/item_tree/lower.rs | 15 +++++++++++---- crates/ra_hir_def/src/item_tree/tests.rs | 8 ++++---- 2 files changed, 15 insertions(+), 8 deletions(-) (limited to 'crates/ra_hir_def/src/item_tree') diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index b1847a6cb..6e31266a2 100644 --- a/crates/ra_hir_def/src/item_tree/lower.rs +++ b/crates/ra_hir_def/src/item_tree/lower.rs @@ -325,7 +325,7 @@ impl Ctx { generic_params: GenericParamsId::EMPTY, has_self_param, is_unsafe: func.unsafe_token().is_some(), - params, + params: params.into_boxed_slice(), ret_type, ast_id, }; @@ -344,7 +344,14 @@ impl Ctx { let bounds = self.lower_type_bounds(type_alias); let generic_params = self.lower_generic_params(GenericsOwner::TypeAlias, type_alias); let ast_id = self.source_ast_id_map.ast_id(type_alias); - let res = TypeAlias { name, visibility, bounds, generic_params, type_ref, ast_id }; + let res = TypeAlias { + name, + visibility, + bounds: bounds.into_boxed_slice(), + generic_params, + type_ref, + ast_id, + }; Some(id(self.data().type_aliases.alloc(res))) } @@ -384,7 +391,7 @@ impl Ctx { }) .unwrap_or_else(|| { mark::hit!(name_res_works_for_broken_modules); - Vec::new() + Box::new([]) as Box<[_]> }), } }; @@ -552,7 +559,7 @@ impl Ctx { GenericsOwner::Function(func) => { generics.fill(&self.body_ctx, sm, node); // lower `impl Trait` in arguments - for param in &func.params { + for param in &*func.params { generics.fill_implicit_impl_trait_args(param); } } diff --git a/crates/ra_hir_def/src/item_tree/tests.rs b/crates/ra_hir_def/src/item_tree/tests.rs index b72f0f47b..cd4c8a199 100644 --- a/crates/ra_hir_def/src/item_tree/tests.rs +++ b/crates/ra_hir_def/src/item_tree/tests.rs @@ -31,7 +31,7 @@ fn test_inner_items(ra_fixture: &str) { ModItem::TypeAlias(it) => tree.source(&db, InFile::new(file_id, it)).into(), ModItem::Mod(it) => { if let ModKind::Inline { items } = &tree[it].kind { - worklist.extend(items); + worklist.extend(&**items); } tree.source(&db, InFile::new(file_id, it)).into() } @@ -125,14 +125,14 @@ fn fmt_mod_item(out: &mut String, tree: &ItemTree, item: ModItem) { } ModItem::Trait(it) => { format_to!(out, "{:?}", tree[it]); - for item in &tree[it].items { + for item in &*tree[it].items { fmt_mod_item(&mut children, tree, ModItem::from(*item)); format_to!(children, "\n"); } } ModItem::Impl(it) => { format_to!(out, "{:?}", tree[it]); - for item in &tree[it].items { + for item in &*tree[it].items { fmt_mod_item(&mut children, tree, ModItem::from(*item)); format_to!(children, "\n"); } @@ -144,7 +144,7 @@ fn fmt_mod_item(out: &mut String, tree: &ItemTree, item: ModItem) { format_to!(out, "{:?}", tree[it]); match &tree[it].kind { ModKind::Inline { items } => { - for item in items { + for item in &**items { fmt_mod_item(&mut children, tree, *item); format_to!(children, "\n"); } -- cgit v1.2.3