diff options
author | Jonas Schievink <[email protected]> | 2020-06-24 14:54:35 +0100 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2020-06-24 15:54:21 +0100 |
commit | abdba92334f800d236c65e543377f75327f7307a (patch) | |
tree | 61fbd8e6dd3269dcd746767bcac8ba169d6eebfc /crates/ra_hir_def | |
parent | 43cad21623bc5de59598a565097be9c7d8642818 (diff) |
Don't allocate empty generics
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/generics.rs | 14 | ||||
-rw-r--r-- | crates/ra_hir_def/src/item_tree.rs | 51 | ||||
-rw-r--r-- | crates/ra_hir_def/src/item_tree/lower.rs | 7 | ||||
-rw-r--r-- | crates/ra_hir_def/src/item_tree/tests.rs | 46 |
4 files changed, 78 insertions, 40 deletions
diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs index c4b9f626f..6a0f493a7 100644 --- a/crates/ra_hir_def/src/generics.rs +++ b/crates/ra_hir_def/src/generics.rs | |||
@@ -80,43 +80,43 @@ impl GenericParams { | |||
80 | let id = id.lookup(db).id; | 80 | let id = id.lookup(db).id; |
81 | let tree = db.item_tree(id.file_id); | 81 | let tree = db.item_tree(id.file_id); |
82 | let item = &tree[id.value]; | 82 | let item = &tree[id.value]; |
83 | item.generic_params.clone() | 83 | tree[item.generic_params].clone() |
84 | } | 84 | } |
85 | GenericDefId::AdtId(AdtId::StructId(id)) => { | 85 | GenericDefId::AdtId(AdtId::StructId(id)) => { |
86 | let id = id.lookup(db).id; | 86 | let id = id.lookup(db).id; |
87 | let tree = db.item_tree(id.file_id); | 87 | let tree = db.item_tree(id.file_id); |
88 | let item = &tree[id.value]; | 88 | let item = &tree[id.value]; |
89 | item.generic_params.clone() | 89 | tree[item.generic_params].clone() |
90 | } | 90 | } |
91 | GenericDefId::AdtId(AdtId::EnumId(id)) => { | 91 | GenericDefId::AdtId(AdtId::EnumId(id)) => { |
92 | let id = id.lookup(db).id; | 92 | let id = id.lookup(db).id; |
93 | let tree = db.item_tree(id.file_id); | 93 | let tree = db.item_tree(id.file_id); |
94 | let item = &tree[id.value]; | 94 | let item = &tree[id.value]; |
95 | item.generic_params.clone() | 95 | tree[item.generic_params].clone() |
96 | } | 96 | } |
97 | GenericDefId::AdtId(AdtId::UnionId(id)) => { | 97 | GenericDefId::AdtId(AdtId::UnionId(id)) => { |
98 | let id = id.lookup(db).id; | 98 | let id = id.lookup(db).id; |
99 | let tree = db.item_tree(id.file_id); | 99 | let tree = db.item_tree(id.file_id); |
100 | let item = &tree[id.value]; | 100 | let item = &tree[id.value]; |
101 | item.generic_params.clone() | 101 | tree[item.generic_params].clone() |
102 | } | 102 | } |
103 | GenericDefId::TraitId(id) => { | 103 | GenericDefId::TraitId(id) => { |
104 | let id = id.lookup(db).id; | 104 | let id = id.lookup(db).id; |
105 | let tree = db.item_tree(id.file_id); | 105 | let tree = db.item_tree(id.file_id); |
106 | let item = &tree[id.value]; | 106 | let item = &tree[id.value]; |
107 | item.generic_params.clone() | 107 | tree[item.generic_params].clone() |
108 | } | 108 | } |
109 | GenericDefId::TypeAliasId(id) => { | 109 | GenericDefId::TypeAliasId(id) => { |
110 | let id = id.lookup(db).id; | 110 | let id = id.lookup(db).id; |
111 | let tree = db.item_tree(id.file_id); | 111 | let tree = db.item_tree(id.file_id); |
112 | let item = &tree[id.value]; | 112 | let item = &tree[id.value]; |
113 | item.generic_params.clone() | 113 | tree[item.generic_params].clone() |
114 | } | 114 | } |
115 | GenericDefId::ImplId(id) => { | 115 | GenericDefId::ImplId(id) => { |
116 | let id = id.lookup(db).id; | 116 | let id = id.lookup(db).id; |
117 | let tree = db.item_tree(id.file_id); | 117 | let tree = db.item_tree(id.file_id); |
118 | let item = &tree[id.value]; | 118 | let item = &tree[id.value]; |
119 | item.generic_params.clone() | 119 | tree[item.generic_params].clone() |
120 | } | 120 | } |
121 | GenericDefId::EnumVariantId(_) | GenericDefId::ConstId(_) => GenericParams::default(), | 121 | GenericDefId::EnumVariantId(_) | GenericDefId::ConstId(_) => GenericParams::default(), |
122 | }; | 122 | }; |
diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs index bbaa7c1f6..9e1fd904f 100644 --- a/crates/ra_hir_def/src/item_tree.rs +++ b/crates/ra_hir_def/src/item_tree.rs | |||
@@ -76,12 +76,37 @@ impl fmt::Debug for RawVisibilityId { | |||
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
79 | #[derive(Default, Debug, Eq, PartialEq)] | ||
80 | struct GenericParamsStorage { | ||
81 | arena: Arena<GenericParams>, | ||
82 | } | ||
83 | |||
84 | impl GenericParamsStorage { | ||
85 | fn alloc(&mut self, params: GenericParams) -> GenericParamsId { | ||
86 | if params.types.is_empty() && params.where_predicates.is_empty() { | ||
87 | return GenericParamsId::EMPTY; | ||
88 | } | ||
89 | |||
90 | GenericParamsId(self.arena.alloc(params).into_raw().into()) | ||
91 | } | ||
92 | } | ||
93 | |||
94 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] | ||
95 | pub struct GenericParamsId(u32); | ||
96 | |||
97 | impl GenericParamsId { | ||
98 | pub const EMPTY: Self = GenericParamsId(u32::max_value()); | ||
99 | } | ||
100 | |||
79 | static VIS_PUB: RawVisibility = RawVisibility::Public; | 101 | static VIS_PUB: RawVisibility = RawVisibility::Public; |
80 | static VIS_PRIV: RawVisibility = | 102 | static VIS_PRIV: RawVisibility = |
81 | RawVisibility::Module(ModPath { kind: PathKind::Super(0), segments: Vec::new() }); | 103 | RawVisibility::Module(ModPath { kind: PathKind::Super(0), segments: Vec::new() }); |
82 | static VIS_PUB_CRATE: RawVisibility = | 104 | static VIS_PUB_CRATE: RawVisibility = |
83 | RawVisibility::Module(ModPath { kind: PathKind::Crate, segments: Vec::new() }); | 105 | RawVisibility::Module(ModPath { kind: PathKind::Crate, segments: Vec::new() }); |
84 | 106 | ||
107 | static EMPTY_GENERICS: GenericParams = | ||
108 | GenericParams { types: Arena::new(), where_predicates: Vec::new() }; | ||
109 | |||
85 | #[derive(Default, Debug, Eq, PartialEq)] | 110 | #[derive(Default, Debug, Eq, PartialEq)] |
86 | struct ItemTreeData { | 111 | struct ItemTreeData { |
87 | imports: Arena<Import>, | 112 | imports: Arena<Import>, |
@@ -102,6 +127,7 @@ struct ItemTreeData { | |||
102 | exprs: Arena<Expr>, | 127 | exprs: Arena<Expr>, |
103 | 128 | ||
104 | vis: ItemVisibilities, | 129 | vis: ItemVisibilities, |
130 | generics: GenericParamsStorage, | ||
105 | } | 131 | } |
106 | 132 | ||
107 | #[derive(Debug, Eq, PartialEq, Hash)] | 133 | #[derive(Debug, Eq, PartialEq, Hash)] |
@@ -364,6 +390,17 @@ impl Index<RawVisibilityId> for ItemTree { | |||
364 | } | 390 | } |
365 | } | 391 | } |
366 | 392 | ||
393 | impl Index<GenericParamsId> for ItemTree { | ||
394 | type Output = GenericParams; | ||
395 | |||
396 | fn index(&self, index: GenericParamsId) -> &Self::Output { | ||
397 | match index { | ||
398 | GenericParamsId::EMPTY => &EMPTY_GENERICS, | ||
399 | _ => &self.data().generics.arena[Idx::from_raw(index.0.into())], | ||
400 | } | ||
401 | } | ||
402 | } | ||
403 | |||
367 | impl<N: ItemTreeNode> Index<FileItemTreeId<N>> for ItemTree { | 404 | impl<N: ItemTreeNode> Index<FileItemTreeId<N>> for ItemTree { |
368 | type Output = N; | 405 | type Output = N; |
369 | fn index(&self, id: FileItemTreeId<N>) -> &N { | 406 | fn index(&self, id: FileItemTreeId<N>) -> &N { |
@@ -398,7 +435,7 @@ pub struct ExternCrate { | |||
398 | pub struct Function { | 435 | pub struct Function { |
399 | pub name: Name, | 436 | pub name: Name, |
400 | pub visibility: RawVisibilityId, | 437 | pub visibility: RawVisibilityId, |
401 | pub generic_params: GenericParams, | 438 | pub generic_params: GenericParamsId, |
402 | pub has_self_param: bool, | 439 | pub has_self_param: bool, |
403 | pub is_unsafe: bool, | 440 | pub is_unsafe: bool, |
404 | pub params: Vec<TypeRef>, | 441 | pub params: Vec<TypeRef>, |
@@ -410,7 +447,7 @@ pub struct Function { | |||
410 | pub struct Struct { | 447 | pub struct Struct { |
411 | pub name: Name, | 448 | pub name: Name, |
412 | pub visibility: RawVisibilityId, | 449 | pub visibility: RawVisibilityId, |
413 | pub generic_params: GenericParams, | 450 | pub generic_params: GenericParamsId, |
414 | pub fields: Fields, | 451 | pub fields: Fields, |
415 | pub ast_id: FileAstId<ast::StructDef>, | 452 | pub ast_id: FileAstId<ast::StructDef>, |
416 | pub kind: StructDefKind, | 453 | pub kind: StructDefKind, |
@@ -430,7 +467,7 @@ pub enum StructDefKind { | |||
430 | pub struct Union { | 467 | pub struct Union { |
431 | pub name: Name, | 468 | pub name: Name, |
432 | pub visibility: RawVisibilityId, | 469 | pub visibility: RawVisibilityId, |
433 | pub generic_params: GenericParams, | 470 | pub generic_params: GenericParamsId, |
434 | pub fields: Fields, | 471 | pub fields: Fields, |
435 | pub ast_id: FileAstId<ast::UnionDef>, | 472 | pub ast_id: FileAstId<ast::UnionDef>, |
436 | } | 473 | } |
@@ -439,7 +476,7 @@ pub struct Union { | |||
439 | pub struct Enum { | 476 | pub struct Enum { |
440 | pub name: Name, | 477 | pub name: Name, |
441 | pub visibility: RawVisibilityId, | 478 | pub visibility: RawVisibilityId, |
442 | pub generic_params: GenericParams, | 479 | pub generic_params: GenericParamsId, |
443 | pub variants: Range<Idx<Variant>>, | 480 | pub variants: Range<Idx<Variant>>, |
444 | pub ast_id: FileAstId<ast::EnumDef>, | 481 | pub ast_id: FileAstId<ast::EnumDef>, |
445 | } | 482 | } |
@@ -466,7 +503,7 @@ pub struct Static { | |||
466 | pub struct Trait { | 503 | pub struct Trait { |
467 | pub name: Name, | 504 | pub name: Name, |
468 | pub visibility: RawVisibilityId, | 505 | pub visibility: RawVisibilityId, |
469 | pub generic_params: GenericParams, | 506 | pub generic_params: GenericParamsId, |
470 | pub auto: bool, | 507 | pub auto: bool, |
471 | pub items: Vec<AssocItem>, | 508 | pub items: Vec<AssocItem>, |
472 | pub ast_id: FileAstId<ast::TraitDef>, | 509 | pub ast_id: FileAstId<ast::TraitDef>, |
@@ -474,7 +511,7 @@ pub struct Trait { | |||
474 | 511 | ||
475 | #[derive(Debug, Clone, Eq, PartialEq)] | 512 | #[derive(Debug, Clone, Eq, PartialEq)] |
476 | pub struct Impl { | 513 | pub struct Impl { |
477 | pub generic_params: GenericParams, | 514 | pub generic_params: GenericParamsId, |
478 | pub target_trait: Option<TypeRef>, | 515 | pub target_trait: Option<TypeRef>, |
479 | pub target_type: TypeRef, | 516 | pub target_type: TypeRef, |
480 | pub is_negative: bool, | 517 | pub is_negative: bool, |
@@ -488,7 +525,7 @@ pub struct TypeAlias { | |||
488 | pub visibility: RawVisibilityId, | 525 | pub visibility: RawVisibilityId, |
489 | /// 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;`. |
490 | pub bounds: Vec<TypeBound>, | 527 | pub bounds: Vec<TypeBound>, |
491 | pub generic_params: GenericParams, | 528 | pub generic_params: GenericParamsId, |
492 | pub type_ref: Option<TypeRef>, | 529 | pub type_ref: Option<TypeRef>, |
493 | pub ast_id: FileAstId<ast::TypeAliasDef>, | 530 | pub ast_id: FileAstId<ast::TypeAliasDef>, |
494 | } | 531 | } |
diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index 73c21b9ec..b1847a6cb 100644 --- a/crates/ra_hir_def/src/item_tree/lower.rs +++ b/crates/ra_hir_def/src/item_tree/lower.rs | |||
@@ -322,7 +322,7 @@ impl Ctx { | |||
322 | let mut res = Function { | 322 | let mut res = Function { |
323 | name, | 323 | name, |
324 | visibility, | 324 | visibility, |
325 | generic_params: GenericParams::default(), | 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, |
@@ -545,7 +545,7 @@ impl Ctx { | |||
545 | &mut self, | 545 | &mut self, |
546 | owner: GenericsOwner<'_>, | 546 | owner: GenericsOwner<'_>, |
547 | node: &impl ast::TypeParamsOwner, | 547 | node: &impl ast::TypeParamsOwner, |
548 | ) -> GenericParams { | 548 | ) -> GenericParamsId { |
549 | let mut sm = &mut ArenaMap::default(); | 549 | let mut sm = &mut ArenaMap::default(); |
550 | let mut generics = GenericParams::default(); | 550 | let mut generics = GenericParams::default(); |
551 | match owner { | 551 | match owner { |
@@ -584,7 +584,8 @@ impl Ctx { | |||
584 | generics.fill(&self.body_ctx, &mut sm, node); | 584 | generics.fill(&self.body_ctx, &mut sm, node); |
585 | } | 585 | } |
586 | } | 586 | } |
587 | generics | 587 | |
588 | self.data().generics.alloc(generics) | ||
588 | } | 589 | } |
589 | 590 | ||
590 | fn lower_type_bounds(&mut self, node: &impl ast::TypeBoundsOwner) -> Vec<TypeBound> { | 591 | fn lower_type_bounds(&mut self, node: &impl ast::TypeBoundsOwner) -> Vec<TypeBound> { |
diff --git a/crates/ra_hir_def/src/item_tree/tests.rs b/crates/ra_hir_def/src/item_tree/tests.rs index 42394a960..b72f0f47b 100644 --- a/crates/ra_hir_def/src/item_tree/tests.rs +++ b/crates/ra_hir_def/src/item_tree/tests.rs | |||
@@ -225,25 +225,25 @@ Import { path: ModPath { kind: Plain, segments: [Name(Text("b"))] }, alias: None | |||
225 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("ext_crate"))] }, input: None }]) }] | 225 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("ext_crate"))] }, input: None }]) }] |
226 | ExternCrate { path: ModPath { kind: Plain, segments: [Name(Text("krate"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_macro_use: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ExternCrateItem>(1) } | 226 | ExternCrate { path: ModPath { kind: Plain, segments: [Name(Text("krate"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_macro_use: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ExternCrateItem>(1) } |
227 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_trait"))] }, input: None }]) }] | 227 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_trait"))] }, input: None }]) }] |
228 | Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParams { types: Arena { len: 2, data: [TypeParamData { name: Some(Name(Text("Self"))), default: None, provenance: TraitSelf }, TypeParamData { name: Some(Name(Text("U"))), default: None, provenance: TypeParamList }] }, where_predicates: [] }, auto: false, items: [TypeAlias(Idx::<TypeAlias>(0)), Const(Idx::<Const>(0)), Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TraitDef>(2) } | 228 | Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [TypeAlias(Idx::<TypeAlias>(0)), Const(Idx::<Const>(0)), Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TraitDef>(2) } |
229 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_ty"))] }, input: None }]) }] | 229 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_ty"))] }, input: None }]) }] |
230 | > TypeAlias { name: Name(Text("AssocTy")), visibility: RawVisibilityId("pub(self)"), bounds: [Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Tr"))] }, generic_args: [Some(GenericArgs { args: [Type(Tuple([]))], has_self_type: false, bindings: [] })] })], generic_params: GenericParams { types: Arena { len: 0, data: [] }, where_predicates: [] }, type_ref: None, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TypeAliasDef>(8) } | 230 | > TypeAlias { name: Name(Text("AssocTy")), visibility: RawVisibilityId("pub(self)"), bounds: [Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Tr"))] }, generic_args: [Some(GenericArgs { args: [Type(Tuple([]))], has_self_type: false, bindings: [] })] })], generic_params: GenericParamsId(4294967295), type_ref: None, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TypeAliasDef>(8) } |
231 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_const"))] }, input: None }]) }] | 231 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_const"))] }, input: None }]) }] |
232 | > Const { name: Some(Name(Text("CONST"))), visibility: RawVisibilityId("pub(self)"), type_ref: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("u8"))] }, generic_args: [None] }), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ConstDef>(9) } | 232 | > Const { name: Some(Name(Text("CONST"))), visibility: RawVisibilityId("pub(self)"), type_ref: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("u8"))] }, generic_args: [None] }), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ConstDef>(9) } |
233 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_method"))] }, input: None }]) }] | 233 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_method"))] }, input: None }]) }] |
234 | > Function { name: Name(Text("method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParams { types: Arena { len: 0, data: [] }, where_predicates: [] }, has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Shared)], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(10) } | 234 | > Function { name: Name(Text("method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Shared)], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(10) } |
235 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_dfl_method"))] }, input: None }]) }] | 235 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("assoc_dfl_method"))] }, input: None }]) }] |
236 | > Function { name: Name(Text("dfl_method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParams { types: Arena { len: 0, data: [] }, where_predicates: [] }, has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Mut)], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(11) } | 236 | > Function { name: Name(Text("dfl_method")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: true, is_unsafe: false, params: [Reference(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Self"))] }, generic_args: [None] }), Mut)], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(11) } |
237 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct0"))] }, input: None }]) }] | 237 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct0"))] }, input: None }]) }] |
238 | Struct { name: Name(Text("Struct0")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParams { types: Arena { len: 1, data: [TypeParamData { name: Some(Name(Text("T"))), default: Some(Tuple([])), provenance: TypeParamList }] }, where_predicates: [] }, fields: Unit, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::StructDef>(3), kind: Unit } | 238 | Struct { name: Name(Text("Struct0")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), fields: Unit, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::StructDef>(3), kind: Unit } |
239 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct1"))] }, input: None }]) }] | 239 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct1"))] }, input: None }]) }] |
240 | Struct { name: Name(Text("Struct1")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParams { types: Arena { len: 1, data: [TypeParamData { name: Some(Name(Text("T"))), default: None, provenance: TypeParamList }] }, where_predicates: [] }, fields: Tuple(Idx::<Field>(0)..Idx::<Field>(1)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::StructDef>(4), kind: Tuple } | 240 | Struct { name: Name(Text("Struct1")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(2), fields: Tuple(Idx::<Field>(0)..Idx::<Field>(1)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::StructDef>(4), kind: Tuple } |
241 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct2"))] }, input: None }]) }] | 241 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("struct2"))] }, input: None }]) }] |
242 | Struct { name: Name(Text("Struct2")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParams { types: Arena { len: 1, data: [TypeParamData { name: Some(Name(Text("T"))), default: None, provenance: TypeParamList }] }, where_predicates: [] }, fields: Record(Idx::<Field>(1)..Idx::<Field>(2)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::StructDef>(5), kind: Record } | 242 | Struct { name: Name(Text("Struct2")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(3), fields: Record(Idx::<Field>(1)..Idx::<Field>(2)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::StructDef>(5), kind: Record } |
243 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("en"))] }, input: None }]) }] | 243 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("en"))] }, input: None }]) }] |
244 | Enum { name: Name(Text("En")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParams { types: Arena { len: 0, data: [] }, where_predicates: [] }, variants: Idx::<Variant>(0)..Idx::<Variant>(1), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::EnumDef>(6) } | 244 | Enum { name: Name(Text("En")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), variants: Idx::<Variant>(0)..Idx::<Variant>(1), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::EnumDef>(6) } |
245 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("un"))] }, input: None }]) }] | 245 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("un"))] }, input: None }]) }] |
246 | Union { name: Name(Text("Un")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParams { types: Arena { len: 0, data: [] }, where_predicates: [] }, fields: Record(Idx::<Field>(3)..Idx::<Field>(4)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::UnionDef>(7) } | 246 | Union { name: Name(Text("Un")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), fields: Record(Idx::<Field>(3)..Idx::<Field>(4)), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::UnionDef>(7) } |
247 | "###); | 247 | "###); |
248 | } | 248 | } |
249 | 249 | ||
@@ -266,13 +266,13 @@ fn simple_inner_items() { | |||
266 | inner attrs: Attrs { entries: None } | 266 | inner attrs: Attrs { entries: None } |
267 | 267 | ||
268 | top-level items: | 268 | top-level items: |
269 | Impl { generic_params: GenericParams { types: Arena { len: 1, data: [TypeParamData { name: Some(Name(Text("T"))), default: None, provenance: TypeParamList }] }, where_predicates: [WherePredicate { target: TypeRef(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] })), bound: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("A"))] }, generic_args: [None] }) }] }, target_trait: Some(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("D"))] }, generic_args: [None] })), target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Response"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), is_negative: false, items: [Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ImplDef>(0) } | 269 | Impl { generic_params: GenericParamsId(0), target_trait: Some(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("D"))] }, generic_args: [None] })), target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Response"))] }, generic_args: [Some(GenericArgs { args: [Type(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("T"))] }, generic_args: [None] }))], has_self_type: false, bindings: [] })] }), is_negative: false, items: [Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ImplDef>(0) } |
270 | > Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParams { types: Arena { len: 0, data: [] }, where_predicates: [] }, has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } | 270 | > Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } |
271 | 271 | ||
272 | inner items: | 272 | inner items: |
273 | 273 | ||
274 | for AST FileAstId::<ra_syntax::ast::generated::nodes::ModuleItem>(2): | 274 | for AST FileAstId::<ra_syntax::ast::generated::nodes::ModuleItem>(2): |
275 | Function { name: Name(Text("end")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParams { types: Arena { len: 1, data: [TypeParamData { name: Some(Name(Text("W"))), default: None, provenance: TypeParamList }] }, where_predicates: [WherePredicate { target: TypeRef(Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("W"))] }, generic_args: [None] })), bound: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Write"))] }, generic_args: [None] }) }] }, has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) } | 275 | Function { name: Name(Text("end")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(1), has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) } |
276 | 276 | ||
277 | "###); | 277 | "###); |
278 | } | 278 | } |
@@ -296,9 +296,9 @@ inner attrs: Attrs { entries: None } | |||
296 | 296 | ||
297 | top-level items: | 297 | top-level items: |
298 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }] | 298 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }] |
299 | Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParams { types: Arena { len: 0, data: [] }, where_predicates: [] }, has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } | 299 | Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } |
300 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }] | 300 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }, Attr { path: ModPath { kind: Plain, segments: [Name(Text("block_attr"))] }, input: None }]) }] |
301 | Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParams { types: Arena { len: 0, data: [] }, where_predicates: [] }, has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) } | 301 | Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) } |
302 | "###); | 302 | "###); |
303 | } | 303 | } |
304 | 304 | ||
@@ -321,11 +321,11 @@ inner attrs: Attrs { entries: None } | |||
321 | 321 | ||
322 | top-level items: | 322 | top-level items: |
323 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("trait_attr"))] }, input: None }]) }] | 323 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("trait_attr"))] }, input: None }]) }] |
324 | Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParams { types: Arena { len: 1, data: [TypeParamData { name: Some(Name(Text("Self"))), default: None, provenance: TraitSelf }] }, where_predicates: [] }, auto: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TraitDef>(0) } | 324 | Trait { name: Name(Text("Tr")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(0), auto: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::TraitDef>(0) } |
325 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }] | 325 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }] |
326 | > Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParams { types: Arena { len: 0, data: [] }, where_predicates: [] }, has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } | 326 | > Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } |
327 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }] | 327 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }] |
328 | > Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParams { types: Arena { len: 0, data: [] }, where_predicates: [] }, has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) } | 328 | > Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) } |
329 | "###); | 329 | "###); |
330 | } | 330 | } |
331 | 331 | ||
@@ -348,11 +348,11 @@ inner attrs: Attrs { entries: None } | |||
348 | 348 | ||
349 | top-level items: | 349 | top-level items: |
350 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("impl_attr"))] }, input: None }]) }] | 350 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("impl_attr"))] }, input: None }]) }] |
351 | Impl { generic_params: GenericParams { types: Arena { len: 0, data: [] }, where_predicates: [] }, target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Ty"))] }, generic_args: [None] }), is_negative: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ImplDef>(0) } | 351 | Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("Ty"))] }, generic_args: [None] }), is_negative: false, items: [Function(Idx::<Function>(0)), Function(Idx::<Function>(1))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ImplDef>(0) } |
352 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }] | 352 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_a"))] }, input: None }]) }] |
353 | > Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParams { types: Arena { len: 0, data: [] }, where_predicates: [] }, has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } | 353 | > Function { name: Name(Text("a")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } |
354 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }] | 354 | > #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_b"))] }, input: None }]) }] |
355 | > Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParams { types: Arena { len: 0, data: [] }, where_predicates: [] }, has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) } | 355 | > Function { name: Name(Text("b")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(2) } |
356 | "###); | 356 | "###); |
357 | } | 357 | } |
358 | 358 | ||
@@ -398,13 +398,13 @@ fn inner_item_attrs() { | |||
398 | inner attrs: Attrs { entries: None } | 398 | inner attrs: Attrs { entries: None } |
399 | 399 | ||
400 | top-level items: | 400 | top-level items: |
401 | Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParams { types: Arena { len: 0, data: [] }, where_predicates: [] }, has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(0) } | 401 | Function { name: Name(Text("foo")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(0) } |
402 | 402 | ||
403 | inner items: | 403 | inner items: |
404 | 404 | ||
405 | for AST FileAstId::<ra_syntax::ast::generated::nodes::ModuleItem>(1): | 405 | for AST FileAstId::<ra_syntax::ast::generated::nodes::ModuleItem>(1): |
406 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_inner"))] }, input: None }]) }] | 406 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("on_inner"))] }, input: None }]) }] |
407 | Function { name: Name(Text("inner")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParams { types: Arena { len: 0, data: [] }, where_predicates: [] }, has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } | 407 | Function { name: Name(Text("inner")), visibility: RawVisibilityId("pub(self)"), generic_params: GenericParamsId(4294967295), has_self_param: false, is_unsafe: false, params: [], ret_type: Tuple([]), ast_id: FileAstId::<ra_syntax::ast::generated::nodes::FnDef>(1) } |
408 | 408 | ||
409 | "###); | 409 | "###); |
410 | } | 410 | } |
@@ -423,7 +423,7 @@ fn assoc_item_macros() { | |||
423 | inner attrs: Attrs { entries: None } | 423 | inner attrs: Attrs { entries: None } |
424 | 424 | ||
425 | top-level items: | 425 | top-level items: |
426 | Impl { generic_params: GenericParams { types: Arena { len: 0, data: [] }, where_predicates: [] }, target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("S"))] }, generic_args: [None] }), is_negative: false, items: [MacroCall(Idx::<MacroCall>(0))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ImplDef>(0) } | 426 | Impl { generic_params: GenericParamsId(4294967295), target_trait: None, target_type: Path(Path { type_anchor: None, mod_path: ModPath { kind: Plain, segments: [Name(Text("S"))] }, generic_args: [None] }), is_negative: false, items: [MacroCall(Idx::<MacroCall>(0))], ast_id: FileAstId::<ra_syntax::ast::generated::nodes::ImplDef>(0) } |
427 | > MacroCall { name: None, path: ModPath { kind: Plain, segments: [Name(Text("items"))] }, is_export: false, is_local_inner: false, is_builtin: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::MacroCall>(1) } | 427 | > MacroCall { name: None, path: ModPath { kind: Plain, segments: [Name(Text("items"))] }, is_export: false, is_local_inner: false, is_builtin: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::MacroCall>(1) } |
428 | "###); | 428 | "###); |
429 | } | 429 | } |