diff options
-rw-r--r-- | crates/ra_hir_def/src/data.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir_def/src/item_tree.rs | 87 | ||||
-rw-r--r-- | crates/ra_hir_def/src/item_tree/lower.rs | 22 | ||||
-rw-r--r-- | crates/ra_hir_def/src/item_tree/tests.rs | 48 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 52 |
5 files changed, 142 insertions, 75 deletions
diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs index 5f8eb72a0..5ca331380 100644 --- a/crates/ra_hir_def/src/data.rs +++ b/crates/ra_hir_def/src/data.rs | |||
@@ -43,7 +43,7 @@ impl FunctionData { | |||
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, |
45 | is_unsafe: func.is_unsafe, | 45 | is_unsafe: func.is_unsafe, |
46 | visibility: func.visibility.clone(), | 46 | visibility: item_tree[func.visibility].clone(), |
47 | }) | 47 | }) |
48 | } | 48 | } |
49 | } | 49 | } |
@@ -69,7 +69,7 @@ impl TypeAliasData { | |||
69 | Arc::new(TypeAliasData { | 69 | Arc::new(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: typ.visibility.clone(), | 72 | visibility: item_tree[typ.visibility].clone(), |
73 | bounds: typ.bounds.clone(), | 73 | bounds: typ.bounds.clone(), |
74 | }) | 74 | }) |
75 | } | 75 | } |
@@ -175,7 +175,7 @@ impl ConstData { | |||
175 | Arc::new(ConstData { | 175 | Arc::new(ConstData { |
176 | name: konst.name.clone(), | 176 | name: konst.name.clone(), |
177 | type_ref: konst.type_ref.clone(), | 177 | type_ref: konst.type_ref.clone(), |
178 | visibility: konst.visibility.clone(), | 178 | visibility: item_tree[konst.visibility].clone(), |
179 | }) | 179 | }) |
180 | } | 180 | } |
181 | } | 181 | } |
@@ -197,7 +197,7 @@ impl StaticData { | |||
197 | Arc::new(StaticData { | 197 | Arc::new(StaticData { |
198 | name: Some(statik.name.clone()), | 198 | name: Some(statik.name.clone()), |
199 | type_ref: statik.type_ref.clone(), | 199 | type_ref: statik.type_ref.clone(), |
200 | visibility: statik.visibility.clone(), | 200 | visibility: item_tree[statik.visibility].clone(), |
201 | mutable: statik.mutable, | 201 | mutable: statik.mutable, |
202 | }) | 202 | }) |
203 | } | 203 | } |
diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs index 40bb78b57..bbaa7c1f6 100644 --- a/crates/ra_hir_def/src/item_tree.rs +++ b/crates/ra_hir_def/src/item_tree.rs | |||
@@ -29,13 +29,60 @@ use crate::{ | |||
29 | attr::Attrs, | 29 | attr::Attrs, |
30 | db::DefDatabase, | 30 | db::DefDatabase, |
31 | generics::GenericParams, | 31 | generics::GenericParams, |
32 | path::{path, AssociatedTypeBinding, GenericArgs, ImportAlias, ModPath, Path}, | 32 | path::{path, AssociatedTypeBinding, GenericArgs, ImportAlias, ModPath, Path, PathKind}, |
33 | type_ref::{Mutability, TypeBound, TypeRef}, | 33 | type_ref::{Mutability, TypeBound, TypeRef}, |
34 | visibility::RawVisibility, | 34 | visibility::RawVisibility, |
35 | }; | 35 | }; |
36 | use smallvec::SmallVec; | 36 | use smallvec::SmallVec; |
37 | 37 | ||
38 | #[derive(Default, Debug, Eq, PartialEq)] | 38 | #[derive(Default, Debug, Eq, PartialEq)] |
39 | struct ItemVisibilities { | ||
40 | arena: Arena<RawVisibility>, | ||
41 | } | ||
42 | |||
43 | impl ItemVisibilities { | ||
44 | fn alloc(&mut self, vis: RawVisibility) -> RawVisibilityId { | ||
45 | match &vis { | ||
46 | RawVisibility::Public => RawVisibilityId::PUB, | ||
47 | RawVisibility::Module(path) if path.segments.is_empty() => match &path.kind { | ||
48 | PathKind::Super(0) => RawVisibilityId::PRIV, | ||
49 | PathKind::Crate => RawVisibilityId::PUB_CRATE, | ||
50 | _ => RawVisibilityId(self.arena.alloc(vis).into_raw().into()), | ||
51 | }, | ||
52 | _ => RawVisibilityId(self.arena.alloc(vis).into_raw().into()), | ||
53 | } | ||
54 | } | ||
55 | } | ||
56 | |||
57 | #[derive(Copy, Clone, Eq, PartialEq)] | ||
58 | pub struct RawVisibilityId(u32); | ||
59 | |||
60 | impl RawVisibilityId { | ||
61 | pub const PUB: Self = RawVisibilityId(u32::max_value()); | ||
62 | pub const PRIV: Self = RawVisibilityId(u32::max_value() - 1); | ||
63 | pub const PUB_CRATE: Self = RawVisibilityId(u32::max_value() - 2); | ||
64 | } | ||
65 | |||
66 | impl fmt::Debug for RawVisibilityId { | ||
67 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
68 | let mut f = f.debug_tuple("RawVisibilityId"); | ||
69 | match *self { | ||
70 | Self::PUB => f.field(&"pub"), | ||
71 | Self::PRIV => f.field(&"pub(self)"), | ||
72 | Self::PUB_CRATE => f.field(&"pub(crate)"), | ||
73 | _ => f.field(&self.0), | ||
74 | }; | ||
75 | f.finish() | ||
76 | } | ||
77 | } | ||
78 | |||
79 | static VIS_PUB: RawVisibility = RawVisibility::Public; | ||
80 | static VIS_PRIV: RawVisibility = | ||
81 | RawVisibility::Module(ModPath { kind: PathKind::Super(0), segments: Vec::new() }); | ||
82 | static VIS_PUB_CRATE: RawVisibility = | ||
83 | RawVisibility::Module(ModPath { kind: PathKind::Crate, segments: Vec::new() }); | ||
84 | |||
85 | #[derive(Default, Debug, Eq, PartialEq)] | ||
39 | struct ItemTreeData { | 86 | struct ItemTreeData { |
40 | imports: Arena<Import>, | 87 | imports: Arena<Import>, |
41 | extern_crates: Arena<ExternCrate>, | 88 | extern_crates: Arena<ExternCrate>, |
@@ -53,6 +100,8 @@ struct ItemTreeData { | |||
53 | mods: Arena<Mod>, | 100 | mods: Arena<Mod>, |
54 | macro_calls: Arena<MacroCall>, | 101 | macro_calls: Arena<MacroCall>, |
55 | exprs: Arena<Expr>, | 102 | exprs: Arena<Expr>, |
103 | |||
104 | vis: ItemVisibilities, | ||
56 | } | 105 | } |
57 | 106 | ||
58 | #[derive(Debug, Eq, PartialEq, Hash)] | 107 | #[derive(Debug, Eq, PartialEq, Hash)] |
@@ -303,6 +352,18 @@ macro_rules! impl_index { | |||
303 | 352 | ||
304 | impl_index!(fields: Field, variants: Variant, exprs: Expr); | 353 | impl_index!(fields: Field, variants: Variant, exprs: Expr); |
305 | 354 | ||
355 | impl Index<RawVisibilityId> for ItemTree { | ||
356 | type Output = RawVisibility; | ||
357 | fn index(&self, index: RawVisibilityId) -> &Self::Output { | ||
358 | match index { | ||
359 | RawVisibilityId::PRIV => &VIS_PRIV, | ||
360 | RawVisibilityId::PUB => &VIS_PUB, | ||
361 | RawVisibilityId::PUB_CRATE => &VIS_PUB_CRATE, | ||
362 | _ => &self.data().vis.arena[Idx::from_raw(index.0.into())], | ||
363 | } | ||
364 | } | ||
365 | } | ||
366 | |||
306 | impl<N: ItemTreeNode> Index<FileItemTreeId<N>> for ItemTree { | 367 | impl<N: ItemTreeNode> Index<FileItemTreeId<N>> for ItemTree { |
307 | type Output = N; | 368 | type Output = N; |
308 | fn index(&self, id: FileItemTreeId<N>) -> &N { | 369 | fn index(&self, id: FileItemTreeId<N>) -> &N { |
@@ -315,7 +376,7 @@ impl<N: ItemTreeNode> Index<FileItemTreeId<N>> for ItemTree { | |||
315 | pub struct Import { | 376 | pub struct Import { |
316 | pub path: ModPath, | 377 | pub path: ModPath, |
317 | pub alias: Option<ImportAlias>, | 378 | pub alias: Option<ImportAlias>, |
318 | pub visibility: RawVisibility, | 379 | pub visibility: RawVisibilityId, |
319 | pub is_glob: bool, | 380 | pub is_glob: bool, |
320 | pub is_prelude: bool, | 381 | pub is_prelude: bool, |
321 | /// AST ID of the `use` or `extern crate` item this import was derived from. Note that many | 382 | /// AST ID of the `use` or `extern crate` item this import was derived from. Note that many |
@@ -327,7 +388,7 @@ pub struct Import { | |||
327 | pub struct ExternCrate { | 388 | pub struct ExternCrate { |
328 | pub path: ModPath, | 389 | pub path: ModPath, |
329 | pub alias: Option<ImportAlias>, | 390 | pub alias: Option<ImportAlias>, |
330 | pub visibility: RawVisibility, | 391 | pub visibility: RawVisibilityId, |
331 | /// Whether this is a `#[macro_use] extern crate ...`. | 392 | /// Whether this is a `#[macro_use] extern crate ...`. |
332 | pub is_macro_use: bool, | 393 | pub is_macro_use: bool, |
333 | pub ast_id: FileAstId<ast::ExternCrateItem>, | 394 | pub ast_id: FileAstId<ast::ExternCrateItem>, |
@@ -336,7 +397,7 @@ pub struct ExternCrate { | |||
336 | #[derive(Debug, Clone, Eq, PartialEq)] | 397 | #[derive(Debug, Clone, Eq, PartialEq)] |
337 | pub struct Function { | 398 | pub struct Function { |
338 | pub name: Name, | 399 | pub name: Name, |
339 | pub visibility: RawVisibility, | 400 | pub visibility: RawVisibilityId, |
340 | pub generic_params: GenericParams, | 401 | pub generic_params: GenericParams, |
341 | pub has_self_param: bool, | 402 | pub has_self_param: bool, |
342 | pub is_unsafe: bool, | 403 | pub is_unsafe: bool, |
@@ -348,7 +409,7 @@ pub struct Function { | |||
348 | #[derive(Debug, Clone, Eq, PartialEq)] | 409 | #[derive(Debug, Clone, Eq, PartialEq)] |
349 | pub struct Struct { | 410 | pub struct Struct { |
350 | pub name: Name, | 411 | pub name: Name, |
351 | pub visibility: RawVisibility, | 412 | pub visibility: RawVisibilityId, |
352 | pub generic_params: GenericParams, | 413 | pub generic_params: GenericParams, |
353 | pub fields: Fields, | 414 | pub fields: Fields, |
354 | pub ast_id: FileAstId<ast::StructDef>, | 415 | pub ast_id: FileAstId<ast::StructDef>, |
@@ -368,7 +429,7 @@ pub enum StructDefKind { | |||
368 | #[derive(Debug, Clone, Eq, PartialEq)] | 429 | #[derive(Debug, Clone, Eq, PartialEq)] |
369 | pub struct Union { | 430 | pub struct Union { |
370 | pub name: Name, | 431 | pub name: Name, |
371 | pub visibility: RawVisibility, | 432 | pub visibility: RawVisibilityId, |
372 | pub generic_params: GenericParams, | 433 | pub generic_params: GenericParams, |
373 | pub fields: Fields, | 434 | pub fields: Fields, |
374 | pub ast_id: FileAstId<ast::UnionDef>, | 435 | pub ast_id: FileAstId<ast::UnionDef>, |
@@ -377,7 +438,7 @@ pub struct Union { | |||
377 | #[derive(Debug, Clone, Eq, PartialEq)] | 438 | #[derive(Debug, Clone, Eq, PartialEq)] |
378 | pub struct Enum { | 439 | pub struct Enum { |
379 | pub name: Name, | 440 | pub name: Name, |
380 | pub visibility: RawVisibility, | 441 | pub visibility: RawVisibilityId, |
381 | pub generic_params: GenericParams, | 442 | pub generic_params: GenericParams, |
382 | pub variants: Range<Idx<Variant>>, | 443 | pub variants: Range<Idx<Variant>>, |
383 | pub ast_id: FileAstId<ast::EnumDef>, | 444 | pub ast_id: FileAstId<ast::EnumDef>, |
@@ -387,7 +448,7 @@ pub struct Enum { | |||
387 | pub struct Const { | 448 | pub struct Const { |
388 | /// const _: () = (); | 449 | /// const _: () = (); |
389 | pub name: Option<Name>, | 450 | pub name: Option<Name>, |
390 | pub visibility: RawVisibility, | 451 | pub visibility: RawVisibilityId, |
391 | pub type_ref: TypeRef, | 452 | pub type_ref: TypeRef, |
392 | pub ast_id: FileAstId<ast::ConstDef>, | 453 | pub ast_id: FileAstId<ast::ConstDef>, |
393 | } | 454 | } |
@@ -395,7 +456,7 @@ pub struct Const { | |||
395 | #[derive(Debug, Clone, Eq, PartialEq)] | 456 | #[derive(Debug, Clone, Eq, PartialEq)] |
396 | pub struct Static { | 457 | pub struct Static { |
397 | pub name: Name, | 458 | pub name: Name, |
398 | pub visibility: RawVisibility, | 459 | pub visibility: RawVisibilityId, |
399 | pub mutable: bool, | 460 | pub mutable: bool, |
400 | pub type_ref: TypeRef, | 461 | pub type_ref: TypeRef, |
401 | pub ast_id: FileAstId<ast::StaticDef>, | 462 | pub ast_id: FileAstId<ast::StaticDef>, |
@@ -404,7 +465,7 @@ pub struct Static { | |||
404 | #[derive(Debug, Clone, Eq, PartialEq)] | 465 | #[derive(Debug, Clone, Eq, PartialEq)] |
405 | pub struct Trait { | 466 | pub struct Trait { |
406 | pub name: Name, | 467 | pub name: Name, |
407 | pub visibility: RawVisibility, | 468 | pub visibility: RawVisibilityId, |
408 | pub generic_params: GenericParams, | 469 | pub generic_params: GenericParams, |
409 | pub auto: bool, | 470 | pub auto: bool, |
410 | pub items: Vec<AssocItem>, | 471 | pub items: Vec<AssocItem>, |
@@ -424,7 +485,7 @@ pub struct Impl { | |||
424 | #[derive(Debug, Clone, PartialEq, Eq)] | 485 | #[derive(Debug, Clone, PartialEq, Eq)] |
425 | pub struct TypeAlias { | 486 | pub struct TypeAlias { |
426 | pub name: Name, | 487 | pub name: Name, |
427 | pub visibility: RawVisibility, | 488 | pub visibility: RawVisibilityId, |
428 | /// Bounds on the type alias itself. Only valid in trait declarations, eg. `type Assoc: Copy;`. | 489 | /// Bounds on the type alias itself. Only valid in trait declarations, eg. `type Assoc: Copy;`. |
429 | pub bounds: Vec<TypeBound>, | 490 | pub bounds: Vec<TypeBound>, |
430 | pub generic_params: GenericParams, | 491 | pub generic_params: GenericParams, |
@@ -435,7 +496,7 @@ pub struct TypeAlias { | |||
435 | #[derive(Debug, Clone, Eq, PartialEq)] | 496 | #[derive(Debug, Clone, Eq, PartialEq)] |
436 | pub struct Mod { | 497 | pub struct Mod { |
437 | pub name: Name, | 498 | pub name: Name, |
438 | pub visibility: RawVisibility, | 499 | pub visibility: RawVisibilityId, |
439 | pub kind: ModKind, | 500 | pub kind: ModKind, |
440 | pub ast_id: FileAstId<ast::Module>, | 501 | pub ast_id: FileAstId<ast::Module>, |
441 | } | 502 | } |
@@ -549,5 +610,5 @@ pub enum Fields { | |||
549 | pub struct Field { | 610 | pub struct Field { |
550 | pub name: Name, | 611 | pub name: Name, |
551 | pub type_ref: TypeRef, | 612 | pub type_ref: TypeRef, |
552 | pub visibility: RawVisibility, | 613 | pub visibility: RawVisibilityId, |
553 | } | 614 | } |
diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs index 3af22149d..73c21b9ec 100644 --- a/crates/ra_hir_def/src/item_tree/lower.rs +++ b/crates/ra_hir_def/src/item_tree/lower.rs | |||
@@ -36,7 +36,7 @@ pub(super) struct Ctx { | |||
36 | source_ast_id_map: Arc<AstIdMap>, | 36 | source_ast_id_map: Arc<AstIdMap>, |
37 | body_ctx: crate::body::LowerCtx, | 37 | body_ctx: crate::body::LowerCtx, |
38 | inner_items: Vec<ModItem>, | 38 | inner_items: Vec<ModItem>, |
39 | forced_visibility: Option<RawVisibility>, | 39 | forced_visibility: Option<RawVisibilityId>, |
40 | } | 40 | } |
41 | 41 | ||
42 | impl Ctx { | 42 | impl Ctx { |
@@ -201,7 +201,7 @@ impl Ctx { | |||
201 | start..end | 201 | start..end |
202 | } | 202 | } |
203 | 203 | ||
204 | fn lower_record_field(&self, field: &ast::RecordFieldDef) -> Option<Field> { | 204 | fn lower_record_field(&mut self, field: &ast::RecordFieldDef) -> Option<Field> { |
205 | let name = field.name()?.as_name(); | 205 | let name = field.name()?.as_name(); |
206 | let visibility = self.lower_visibility(field); | 206 | let visibility = self.lower_visibility(field); |
207 | let type_ref = self.lower_type_ref(&field.ascribed_type()?); | 207 | let type_ref = self.lower_type_ref(&field.ascribed_type()?); |
@@ -220,7 +220,7 @@ impl Ctx { | |||
220 | start..end | 220 | start..end |
221 | } | 221 | } |
222 | 222 | ||
223 | fn lower_tuple_field(&self, idx: usize, field: &ast::TupleFieldDef) -> Option<Field> { | 223 | fn lower_tuple_field(&mut self, idx: usize, field: &ast::TupleFieldDef) -> Option<Field> { |
224 | let name = Name::new_tuple_field(idx); | 224 | let name = Name::new_tuple_field(idx); |
225 | let visibility = self.lower_visibility(field); | 225 | let visibility = self.lower_visibility(field); |
226 | let type_ref = self.lower_type_ref(&field.type_ref()?); | 226 | let type_ref = self.lower_type_ref(&field.type_ref()?); |
@@ -399,7 +399,7 @@ impl Ctx { | |||
399 | let generic_params = self.lower_generic_params(GenericsOwner::Trait(trait_def), trait_def); | 399 | let generic_params = self.lower_generic_params(GenericsOwner::Trait(trait_def), trait_def); |
400 | let auto = trait_def.auto_token().is_some(); | 400 | let auto = trait_def.auto_token().is_some(); |
401 | let items = trait_def.item_list().map(|list| { | 401 | let items = trait_def.item_list().map(|list| { |
402 | self.with_inherited_visibility(visibility.clone(), |this| { | 402 | self.with_inherited_visibility(visibility, |this| { |
403 | list.items() | 403 | list.items() |
404 | .filter_map(|item| { | 404 | .filter_map(|item| { |
405 | let attrs = Attrs::new(&item, &this.hygiene); | 405 | let attrs = Attrs::new(&item, &this.hygiene); |
@@ -463,7 +463,7 @@ impl Ctx { | |||
463 | imports.push(id(tree.imports.alloc(Import { | 463 | imports.push(id(tree.imports.alloc(Import { |
464 | path, | 464 | path, |
465 | alias, | 465 | alias, |
466 | visibility: visibility.clone(), | 466 | visibility, |
467 | is_glob, | 467 | is_glob, |
468 | is_prelude, | 468 | is_prelude, |
469 | ast_id, | 469 | ast_id, |
@@ -596,11 +596,13 @@ impl Ctx { | |||
596 | } | 596 | } |
597 | } | 597 | } |
598 | 598 | ||
599 | fn lower_visibility(&self, item: &impl ast::VisibilityOwner) -> RawVisibility { | 599 | fn lower_visibility(&mut self, item: &impl ast::VisibilityOwner) -> RawVisibilityId { |
600 | match &self.forced_visibility { | 600 | let vis = match self.forced_visibility { |
601 | Some(vis) => vis.clone(), | 601 | Some(vis) => return vis, |
602 | None => RawVisibility::from_ast_with_hygiene(item.visibility(), &self.hygiene), | 602 | None => RawVisibility::from_ast_with_hygiene(item.visibility(), &self.hygiene), |
603 | } | 603 | }; |
604 | |||
605 | self.data().vis.alloc(vis) | ||
604 | } | 606 | } |
605 | 607 | ||
606 | fn lower_type_ref(&self, type_ref: &ast::TypeRef) -> TypeRef { | 608 | fn lower_type_ref(&self, type_ref: &ast::TypeRef) -> TypeRef { |
@@ -613,7 +615,7 @@ impl Ctx { | |||
613 | /// Forces the visibility `vis` to be used for all items lowered during execution of `f`. | 615 | /// Forces the visibility `vis` to be used for all items lowered during execution of `f`. |
614 | fn with_inherited_visibility<R>( | 616 | fn with_inherited_visibility<R>( |
615 | &mut self, | 617 | &mut self, |
616 | vis: RawVisibility, | 618 | vis: RawVisibilityId, |
617 | f: impl FnOnce(&mut Self) -> R, | 619 | f: impl FnOnce(&mut Self) -> R, |
618 | ) -> R { | 620 | ) -> R { |
619 | let old = mem::replace(&mut self.forced_visibility, Some(vis)); | 621 | let old = mem::replace(&mut self.forced_visibility, Some(vis)); |
diff --git a/crates/ra_hir_def/src/item_tree/tests.rs b/crates/ra_hir_def/src/item_tree/tests.rs index 179baee78..42394a960 100644 --- a/crates/ra_hir_def/src/item_tree/tests.rs +++ b/crates/ra_hir_def/src/item_tree/tests.rs | |||
@@ -219,31 +219,31 @@ inner attrs: Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments | |||
219 | 219 | ||
220 | top-level items: | 220 | top-level items: |
221 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }] | 221 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }] |
222 | Import { path: ModPath { kind: Plain, segments: [Name(Text("a"))] }, alias: None, visibility: Module(ModPath { kind: Super(0), segments: [] }), is_glob: false, is_prelude: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::UseItem>(0) } | 222 | Import { path: ModPath { kind: Plain, segments: [Name(Text("a"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: false, is_prelude: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::UseItem>(0) } |
223 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }] | 223 | #[Attrs { entries: Some([Attr { path: ModPath { kind: Plain, segments: [Name(Text("attr_on_use"))] }, input: None }]) }] |
224 | Import { path: ModPath { kind: Plain, segments: [Name(Text("b"))] }, alias: None, visibility: Module(ModPath { kind: Super(0), segments: [] }), is_glob: true, is_prelude: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::UseItem>(0) } | 224 | Import { path: ModPath { kind: Plain, segments: [Name(Text("b"))] }, alias: None, visibility: RawVisibilityId("pub(self)"), is_glob: true, is_prelude: false, ast_id: FileAstId::<ra_syntax::ast::generated::nodes::UseItem>(0) } |
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: Module(ModPath { kind: Super(0), segments: [] }), 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: Module(ModPath { kind: Super(0), segments: [] }), 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: 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) } |
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: Module(ModPath { kind: Super(0), segments: [] }), 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: GenericParams { types: Arena { len: 0, data: [] }, where_predicates: [] }, 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: Module(ModPath { kind: Super(0), segments: [] }), 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: Module(ModPath { kind: Super(0), segments: [] }), 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: 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) } |
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: Module(ModPath { kind: Super(0), segments: [] }), 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: 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) } |
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: Module(ModPath { kind: Super(0), segments: [] }), 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: 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 } |
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: Module(ModPath { kind: Super(0), segments: [] }), 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: 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 } |
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: Module(ModPath { kind: Super(0), segments: [] }), 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: 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 } |
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: Module(ModPath { kind: Super(0), segments: [] }), 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: 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) } |
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: Module(ModPath { kind: Super(0), segments: [] }), 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: 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) } |
247 | "###); | 247 | "###); |
248 | } | 248 | } |
249 | 249 | ||
@@ -267,12 +267,12 @@ 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: 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) } |
270 | > Function { name: Name(Text("foo")), visibility: Module(ModPath { kind: Super(0), segments: [] }), 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: 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) } |
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: Module(ModPath { kind: Super(0), segments: [] }), 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: 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) } |
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: Module(ModPath { kind: Super(0), segments: [] }), 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: 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) } |
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: Module(ModPath { kind: Super(0), segments: [] }), 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: 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) } |
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: Module(ModPath { kind: Super(0), segments: [] }), 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: 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) } |
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: Module(ModPath { kind: Super(0), segments: [] }), 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: 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) } |
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: Module(ModPath { kind: Super(0), segments: [] }), 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: 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) } |
329 | "###); | 329 | "###); |
330 | } | 330 | } |
331 | 331 | ||
@@ -350,9 +350,9 @@ 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: 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) } |
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: Module(ModPath { kind: Super(0), segments: [] }), 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: 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) } |
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: Module(ModPath { kind: Super(0), segments: [] }), 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: 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) } |
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: Module(ModPath { kind: Super(0), segments: [] }), 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: 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) } |
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: Module(ModPath { kind: Super(0), segments: [] }), 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: 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) } |
408 | 408 | ||
409 | "###); | 409 | "###); |
410 | } | 410 | } |
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 40aff830f..94da700ad 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -20,7 +20,9 @@ use test_utils::mark; | |||
20 | use crate::{ | 20 | use crate::{ |
21 | attr::Attrs, | 21 | attr::Attrs, |
22 | db::DefDatabase, | 22 | db::DefDatabase, |
23 | item_tree::{self, ItemTree, ItemTreeId, MacroCall, Mod, ModItem, ModKind, StructDefKind}, | 23 | item_tree::{ |
24 | self, FileItemTreeId, ItemTree, ItemTreeId, MacroCall, Mod, ModItem, ModKind, StructDefKind, | ||
25 | }, | ||
24 | nameres::{ | 26 | nameres::{ |
25 | diagnostics::DefDiagnostic, mod_resolution::ModDir, path_resolution::ReachedFixedPoint, | 27 | diagnostics::DefDiagnostic, mod_resolution::ModDir, path_resolution::ReachedFixedPoint, |
26 | BuiltinShadowMode, CrateDefMap, ModuleData, ModuleOrigin, ResolveMode, | 28 | BuiltinShadowMode, CrateDefMap, ModuleData, ModuleOrigin, ResolveMode, |
@@ -114,26 +116,28 @@ struct Import { | |||
114 | pub is_macro_use: bool, | 116 | pub is_macro_use: bool, |
115 | } | 117 | } |
116 | 118 | ||
117 | impl From<item_tree::Import> for Import { | 119 | impl Import { |
118 | fn from(it: item_tree::Import) -> Self { | 120 | fn from_use(tree: &ItemTree, id: FileItemTreeId<item_tree::Import>) -> Self { |
121 | let it = &tree[id]; | ||
122 | let visibility = &tree[it.visibility]; | ||
119 | Self { | 123 | Self { |
120 | path: it.path, | 124 | path: it.path.clone(), |
121 | alias: it.alias, | 125 | alias: it.alias.clone(), |
122 | visibility: it.visibility, | 126 | visibility: visibility.clone(), |
123 | is_glob: it.is_glob, | 127 | is_glob: it.is_glob, |
124 | is_prelude: it.is_prelude, | 128 | is_prelude: it.is_prelude, |
125 | is_extern_crate: false, | 129 | is_extern_crate: false, |
126 | is_macro_use: false, | 130 | is_macro_use: false, |
127 | } | 131 | } |
128 | } | 132 | } |
129 | } | ||
130 | 133 | ||
131 | impl From<item_tree::ExternCrate> for Import { | 134 | fn from_extern_crate(tree: &ItemTree, id: FileItemTreeId<item_tree::ExternCrate>) -> Self { |
132 | fn from(it: item_tree::ExternCrate) -> Self { | 135 | let it = &tree[id]; |
136 | let visibility = &tree[it.visibility]; | ||
133 | Self { | 137 | Self { |
134 | path: it.path, | 138 | path: it.path.clone(), |
135 | alias: it.alias, | 139 | alias: it.alias.clone(), |
136 | visibility: it.visibility, | 140 | visibility: visibility.clone(), |
137 | is_glob: false, | 141 | is_glob: false, |
138 | is_prelude: false, | 142 | is_prelude: false, |
139 | is_extern_crate: true, | 143 | is_extern_crate: true, |
@@ -761,14 +765,14 @@ impl ModCollector<'_, '_> { | |||
761 | ModItem::Import(import_id) => { | 765 | ModItem::Import(import_id) => { |
762 | self.def_collector.unresolved_imports.push(ImportDirective { | 766 | self.def_collector.unresolved_imports.push(ImportDirective { |
763 | module_id: self.module_id, | 767 | module_id: self.module_id, |
764 | import: self.item_tree[import_id].clone().into(), | 768 | import: Import::from_use(&self.item_tree, import_id), |
765 | status: PartialResolvedImport::Unresolved, | 769 | status: PartialResolvedImport::Unresolved, |
766 | }) | 770 | }) |
767 | } | 771 | } |
768 | ModItem::ExternCrate(import_id) => { | 772 | ModItem::ExternCrate(import_id) => { |
769 | self.def_collector.unresolved_imports.push(ImportDirective { | 773 | self.def_collector.unresolved_imports.push(ImportDirective { |
770 | module_id: self.module_id, | 774 | module_id: self.module_id, |
771 | import: self.item_tree[import_id].clone().into(), | 775 | import: Import::from_extern_crate(&self.item_tree, import_id), |
772 | status: PartialResolvedImport::Unresolved, | 776 | status: PartialResolvedImport::Unresolved, |
773 | }) | 777 | }) |
774 | } | 778 | } |
@@ -795,7 +799,7 @@ impl ModCollector<'_, '_> { | |||
795 | .intern(self.def_collector.db) | 799 | .intern(self.def_collector.db) |
796 | .into(), | 800 | .into(), |
797 | name: &func.name, | 801 | name: &func.name, |
798 | visibility: &func.visibility, | 802 | visibility: &self.item_tree[func.visibility], |
799 | has_constructor: false, | 803 | has_constructor: false, |
800 | }); | 804 | }); |
801 | } | 805 | } |
@@ -812,7 +816,7 @@ impl ModCollector<'_, '_> { | |||
812 | .intern(self.def_collector.db) | 816 | .intern(self.def_collector.db) |
813 | .into(), | 817 | .into(), |
814 | name: &it.name, | 818 | name: &it.name, |
815 | visibility: &it.visibility, | 819 | visibility: &self.item_tree[it.visibility], |
816 | has_constructor: it.kind != StructDefKind::Record, | 820 | has_constructor: it.kind != StructDefKind::Record, |
817 | }); | 821 | }); |
818 | } | 822 | } |
@@ -829,7 +833,7 @@ impl ModCollector<'_, '_> { | |||
829 | .intern(self.def_collector.db) | 833 | .intern(self.def_collector.db) |
830 | .into(), | 834 | .into(), |
831 | name: &it.name, | 835 | name: &it.name, |
832 | visibility: &it.visibility, | 836 | visibility: &self.item_tree[it.visibility], |
833 | has_constructor: false, | 837 | has_constructor: false, |
834 | }); | 838 | }); |
835 | } | 839 | } |
@@ -846,7 +850,7 @@ impl ModCollector<'_, '_> { | |||
846 | .intern(self.def_collector.db) | 850 | .intern(self.def_collector.db) |
847 | .into(), | 851 | .into(), |
848 | name: &it.name, | 852 | name: &it.name, |
849 | visibility: &it.visibility, | 853 | visibility: &self.item_tree[it.visibility], |
850 | has_constructor: false, | 854 | has_constructor: false, |
851 | }); | 855 | }); |
852 | } | 856 | } |
@@ -862,7 +866,7 @@ impl ModCollector<'_, '_> { | |||
862 | .intern(self.def_collector.db) | 866 | .intern(self.def_collector.db) |
863 | .into(), | 867 | .into(), |
864 | name, | 868 | name, |
865 | visibility: &it.visibility, | 869 | visibility: &self.item_tree[it.visibility], |
866 | has_constructor: false, | 870 | has_constructor: false, |
867 | }); | 871 | }); |
868 | } | 872 | } |
@@ -875,7 +879,7 @@ impl ModCollector<'_, '_> { | |||
875 | .intern(self.def_collector.db) | 879 | .intern(self.def_collector.db) |
876 | .into(), | 880 | .into(), |
877 | name: &it.name, | 881 | name: &it.name, |
878 | visibility: &it.visibility, | 882 | visibility: &self.item_tree[it.visibility], |
879 | has_constructor: false, | 883 | has_constructor: false, |
880 | }); | 884 | }); |
881 | } | 885 | } |
@@ -887,7 +891,7 @@ impl ModCollector<'_, '_> { | |||
887 | .intern(self.def_collector.db) | 891 | .intern(self.def_collector.db) |
888 | .into(), | 892 | .into(), |
889 | name: &it.name, | 893 | name: &it.name, |
890 | visibility: &it.visibility, | 894 | visibility: &self.item_tree[it.visibility], |
891 | has_constructor: false, | 895 | has_constructor: false, |
892 | }); | 896 | }); |
893 | } | 897 | } |
@@ -902,7 +906,7 @@ impl ModCollector<'_, '_> { | |||
902 | .intern(self.def_collector.db) | 906 | .intern(self.def_collector.db) |
903 | .into(), | 907 | .into(), |
904 | name: &it.name, | 908 | name: &it.name, |
905 | visibility: &it.visibility, | 909 | visibility: &self.item_tree[it.visibility], |
906 | has_constructor: false, | 910 | has_constructor: false, |
907 | }); | 911 | }); |
908 | } | 912 | } |
@@ -935,7 +939,7 @@ impl ModCollector<'_, '_> { | |||
935 | module.name.clone(), | 939 | module.name.clone(), |
936 | AstId::new(self.file_id, module.ast_id), | 940 | AstId::new(self.file_id, module.ast_id), |
937 | None, | 941 | None, |
938 | &module.visibility, | 942 | &self.item_tree[module.visibility], |
939 | ); | 943 | ); |
940 | 944 | ||
941 | ModCollector { | 945 | ModCollector { |
@@ -965,7 +969,7 @@ impl ModCollector<'_, '_> { | |||
965 | module.name.clone(), | 969 | module.name.clone(), |
966 | ast_id, | 970 | ast_id, |
967 | Some((file_id, is_mod_rs)), | 971 | Some((file_id, is_mod_rs)), |
968 | &module.visibility, | 972 | &self.item_tree[module.visibility], |
969 | ); | 973 | ); |
970 | let item_tree = self.def_collector.db.item_tree(file_id.into()); | 974 | let item_tree = self.def_collector.db.item_tree(file_id.into()); |
971 | ModCollector { | 975 | ModCollector { |