aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir_def/src/data.rs4
-rw-r--r--crates/ra_hir_def/src/item_tree.rs10
-rw-r--r--crates/ra_hir_def/src/item_tree/lower.rs15
-rw-r--r--crates/ra_hir_def/src/item_tree/tests.rs8
4 files changed, 22 insertions, 15 deletions
diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs
index 5ca331380..f9e5701db 100644
--- a/crates/ra_hir_def/src/data.rs
+++ b/crates/ra_hir_def/src/data.rs
@@ -38,7 +38,7 @@ impl FunctionData {
38 38
39 Arc::new(FunctionData { 39 Arc::new(FunctionData {
40 name: func.name.clone(), 40 name: func.name.clone(),
41 params: func.params.clone(), 41 params: func.params.to_vec(),
42 ret_type: func.ret_type.clone(), 42 ret_type: func.ret_type.clone(),
43 attrs: item_tree.attrs(loc.id.value.into()).clone(), 43 attrs: item_tree.attrs(loc.id.value.into()).clone(),
44 has_self_param: func.has_self_param, 44 has_self_param: func.has_self_param,
@@ -70,7 +70,7 @@ impl TypeAliasData {
70 name: typ.name.clone(), 70 name: typ.name.clone(),
71 type_ref: typ.type_ref.clone(), 71 type_ref: typ.type_ref.clone(),
72 visibility: item_tree[typ.visibility].clone(), 72 visibility: item_tree[typ.visibility].clone(),
73 bounds: typ.bounds.clone(), 73 bounds: typ.bounds.to_vec(),
74 }) 74 })
75 } 75 }
76} 76}
diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs
index 9e1fd904f..5155b6111 100644
--- a/crates/ra_hir_def/src/item_tree.rs
+++ b/crates/ra_hir_def/src/item_tree.rs
@@ -438,7 +438,7 @@ pub struct Function {
438 pub generic_params: GenericParamsId, 438 pub generic_params: GenericParamsId,
439 pub has_self_param: bool, 439 pub has_self_param: bool,
440 pub is_unsafe: bool, 440 pub is_unsafe: bool,
441 pub params: Vec<TypeRef>, 441 pub params: Box<[TypeRef]>,
442 pub ret_type: TypeRef, 442 pub ret_type: TypeRef,
443 pub ast_id: FileAstId<ast::FnDef>, 443 pub ast_id: FileAstId<ast::FnDef>,
444} 444}
@@ -505,7 +505,7 @@ pub struct Trait {
505 pub visibility: RawVisibilityId, 505 pub visibility: RawVisibilityId,
506 pub generic_params: GenericParamsId, 506 pub generic_params: GenericParamsId,
507 pub auto: bool, 507 pub auto: bool,
508 pub items: Vec<AssocItem>, 508 pub items: Box<[AssocItem]>,
509 pub ast_id: FileAstId<ast::TraitDef>, 509 pub ast_id: FileAstId<ast::TraitDef>,
510} 510}
511 511
@@ -515,7 +515,7 @@ pub struct Impl {
515 pub target_trait: Option<TypeRef>, 515 pub target_trait: Option<TypeRef>,
516 pub target_type: TypeRef, 516 pub target_type: TypeRef,
517 pub is_negative: bool, 517 pub is_negative: bool,
518 pub items: Vec<AssocItem>, 518 pub items: Box<[AssocItem]>,
519 pub ast_id: FileAstId<ast::ImplDef>, 519 pub ast_id: FileAstId<ast::ImplDef>,
520} 520}
521 521
@@ -524,7 +524,7 @@ pub struct TypeAlias {
524 pub name: Name, 524 pub name: Name,
525 pub visibility: RawVisibilityId, 525 pub visibility: RawVisibilityId,
526 /// Bounds on the type alias itself. Only valid in trait declarations, eg. `type Assoc: Copy;`. 526 /// Bounds on the type alias itself. Only valid in trait declarations, eg. `type Assoc: Copy;`.
527 pub bounds: Vec<TypeBound>, 527 pub bounds: Box<[TypeBound]>,
528 pub generic_params: GenericParamsId, 528 pub generic_params: GenericParamsId,
529 pub type_ref: Option<TypeRef>, 529 pub type_ref: Option<TypeRef>,
530 pub ast_id: FileAstId<ast::TypeAliasDef>, 530 pub ast_id: FileAstId<ast::TypeAliasDef>,
@@ -541,7 +541,7 @@ pub struct Mod {
541#[derive(Debug, Clone, Eq, PartialEq)] 541#[derive(Debug, Clone, Eq, PartialEq)]
542pub enum ModKind { 542pub enum ModKind {
543 /// `mod m { ... }` 543 /// `mod m { ... }`
544 Inline { items: Vec<ModItem> }, 544 Inline { items: Box<[ModItem]> },
545 545
546 /// `mod m;` 546 /// `mod m;`
547 Outline {}, 547 Outline {},
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 {
325 generic_params: GenericParamsId::EMPTY, 325 generic_params: GenericParamsId::EMPTY,
326 has_self_param, 326 has_self_param,
327 is_unsafe: func.unsafe_token().is_some(), 327 is_unsafe: func.unsafe_token().is_some(),
328 params, 328 params: params.into_boxed_slice(),
329 ret_type, 329 ret_type,
330 ast_id, 330 ast_id,
331 }; 331 };
@@ -344,7 +344,14 @@ impl Ctx {
344 let bounds = self.lower_type_bounds(type_alias); 344 let bounds = self.lower_type_bounds(type_alias);
345 let generic_params = self.lower_generic_params(GenericsOwner::TypeAlias, type_alias); 345 let generic_params = self.lower_generic_params(GenericsOwner::TypeAlias, type_alias);
346 let ast_id = self.source_ast_id_map.ast_id(type_alias); 346 let ast_id = self.source_ast_id_map.ast_id(type_alias);
347 let res = TypeAlias { name, visibility, bounds, generic_params, type_ref, ast_id }; 347 let res = TypeAlias {
348 name,
349 visibility,
350 bounds: bounds.into_boxed_slice(),
351 generic_params,
352 type_ref,
353 ast_id,
354 };
348 Some(id(self.data().type_aliases.alloc(res))) 355 Some(id(self.data().type_aliases.alloc(res)))
349 } 356 }
350 357
@@ -384,7 +391,7 @@ impl Ctx {
384 }) 391 })
385 .unwrap_or_else(|| { 392 .unwrap_or_else(|| {
386 mark::hit!(name_res_works_for_broken_modules); 393 mark::hit!(name_res_works_for_broken_modules);
387 Vec::new() 394 Box::new([]) as Box<[_]>
388 }), 395 }),
389 } 396 }
390 }; 397 };
@@ -552,7 +559,7 @@ impl Ctx {
552 GenericsOwner::Function(func) => { 559 GenericsOwner::Function(func) => {
553 generics.fill(&self.body_ctx, sm, node); 560 generics.fill(&self.body_ctx, sm, node);
554 // lower `impl Trait` in arguments 561 // lower `impl Trait` in arguments
555 for param in &func.params { 562 for param in &*func.params {
556 generics.fill_implicit_impl_trait_args(param); 563 generics.fill_implicit_impl_trait_args(param);
557 } 564 }
558 } 565 }
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) {
31 ModItem::TypeAlias(it) => tree.source(&db, InFile::new(file_id, it)).into(), 31 ModItem::TypeAlias(it) => tree.source(&db, InFile::new(file_id, it)).into(),
32 ModItem::Mod(it) => { 32 ModItem::Mod(it) => {
33 if let ModKind::Inline { items } = &tree[it].kind { 33 if let ModKind::Inline { items } = &tree[it].kind {
34 worklist.extend(items); 34 worklist.extend(&**items);
35 } 35 }
36 tree.source(&db, InFile::new(file_id, it)).into() 36 tree.source(&db, InFile::new(file_id, it)).into()
37 } 37 }
@@ -125,14 +125,14 @@ fn fmt_mod_item(out: &mut String, tree: &ItemTree, item: ModItem) {
125 } 125 }
126 ModItem::Trait(it) => { 126 ModItem::Trait(it) => {
127 format_to!(out, "{:?}", tree[it]); 127 format_to!(out, "{:?}", tree[it]);
128 for item in &tree[it].items { 128 for item in &*tree[it].items {
129 fmt_mod_item(&mut children, tree, ModItem::from(*item)); 129 fmt_mod_item(&mut children, tree, ModItem::from(*item));
130 format_to!(children, "\n"); 130 format_to!(children, "\n");
131 } 131 }
132 } 132 }
133 ModItem::Impl(it) => { 133 ModItem::Impl(it) => {
134 format_to!(out, "{:?}", tree[it]); 134 format_to!(out, "{:?}", tree[it]);
135 for item in &tree[it].items { 135 for item in &*tree[it].items {
136 fmt_mod_item(&mut children, tree, ModItem::from(*item)); 136 fmt_mod_item(&mut children, tree, ModItem::from(*item));
137 format_to!(children, "\n"); 137 format_to!(children, "\n");
138 } 138 }
@@ -144,7 +144,7 @@ fn fmt_mod_item(out: &mut String, tree: &ItemTree, item: ModItem) {
144 format_to!(out, "{:?}", tree[it]); 144 format_to!(out, "{:?}", tree[it]);
145 match &tree[it].kind { 145 match &tree[it].kind {
146 ModKind::Inline { items } => { 146 ModKind::Inline { items } => {
147 for item in items { 147 for item in &**items {
148 fmt_mod_item(&mut children, tree, *item); 148 fmt_mod_item(&mut children, tree, *item);
149 format_to!(children, "\n"); 149 format_to!(children, "\n");
150 } 150 }