diff options
Diffstat (limited to 'crates/ra_hir_def/src/nameres')
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 20 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/path_resolution.rs | 5 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/tests/globs.rs | 21 |
3 files changed, 32 insertions, 14 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index 8bbf7ffa2..e68bf4868 100644 --- a/crates/ra_hir_def/src/nameres/collector.rs +++ b/crates/ra_hir_def/src/nameres/collector.rs | |||
@@ -661,9 +661,10 @@ where | |||
661 | krate: self.def_collector.def_map.krate, | 661 | krate: self.def_collector.def_map.krate, |
662 | local_id: self.module_id, | 662 | local_id: self.module_id, |
663 | }; | 663 | }; |
664 | let container = ContainerId::ModuleId(module); | ||
664 | let ast_id = self.raw_items[imp].ast_id; | 665 | let ast_id = self.raw_items[imp].ast_id; |
665 | let impl_id = | 666 | let impl_id = |
666 | ImplLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } | 667 | ImplLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
667 | .intern(self.def_collector.db); | 668 | .intern(self.def_collector.db); |
668 | self.def_collector.def_map.modules[self.module_id].impls.push(impl_id) | 669 | self.def_collector.def_map.modules[self.module_id].impls.push(impl_id) |
669 | } | 670 | } |
@@ -760,10 +761,11 @@ where | |||
760 | self.collect_derives(attrs, def); | 761 | self.collect_derives(attrs, def); |
761 | 762 | ||
762 | let name = def.name.clone(); | 763 | let name = def.name.clone(); |
764 | let container = ContainerId::ModuleId(module); | ||
763 | let def: PerNs = match def.kind { | 765 | let def: PerNs = match def.kind { |
764 | raw::DefKind::Function(ast_id) => { | 766 | raw::DefKind::Function(ast_id) => { |
765 | let def = FunctionLoc { | 767 | let def = FunctionLoc { |
766 | container: ContainerId::ModuleId(module), | 768 | container: container.into(), |
767 | ast_id: AstId::new(self.file_id, ast_id), | 769 | ast_id: AstId::new(self.file_id, ast_id), |
768 | } | 770 | } |
769 | .intern(self.def_collector.db); | 771 | .intern(self.def_collector.db); |
@@ -771,23 +773,23 @@ where | |||
771 | PerNs::values(def.into()) | 773 | PerNs::values(def.into()) |
772 | } | 774 | } |
773 | raw::DefKind::Struct(ast_id) => { | 775 | raw::DefKind::Struct(ast_id) => { |
774 | let def = StructLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } | 776 | let def = StructLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
775 | .intern(self.def_collector.db); | 777 | .intern(self.def_collector.db); |
776 | PerNs::both(def.into(), def.into()) | 778 | PerNs::both(def.into(), def.into()) |
777 | } | 779 | } |
778 | raw::DefKind::Union(ast_id) => { | 780 | raw::DefKind::Union(ast_id) => { |
779 | let def = UnionLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } | 781 | let def = UnionLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
780 | .intern(self.def_collector.db); | 782 | .intern(self.def_collector.db); |
781 | PerNs::both(def.into(), def.into()) | 783 | PerNs::both(def.into(), def.into()) |
782 | } | 784 | } |
783 | raw::DefKind::Enum(ast_id) => { | 785 | raw::DefKind::Enum(ast_id) => { |
784 | let def = EnumLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } | 786 | let def = EnumLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
785 | .intern(self.def_collector.db); | 787 | .intern(self.def_collector.db); |
786 | PerNs::types(def.into()) | 788 | PerNs::types(def.into()) |
787 | } | 789 | } |
788 | raw::DefKind::Const(ast_id) => { | 790 | raw::DefKind::Const(ast_id) => { |
789 | let def = ConstLoc { | 791 | let def = ConstLoc { |
790 | container: ContainerId::ModuleId(module), | 792 | container: container.into(), |
791 | ast_id: AstId::new(self.file_id, ast_id), | 793 | ast_id: AstId::new(self.file_id, ast_id), |
792 | } | 794 | } |
793 | .intern(self.def_collector.db); | 795 | .intern(self.def_collector.db); |
@@ -795,20 +797,20 @@ where | |||
795 | PerNs::values(def.into()) | 797 | PerNs::values(def.into()) |
796 | } | 798 | } |
797 | raw::DefKind::Static(ast_id) => { | 799 | raw::DefKind::Static(ast_id) => { |
798 | let def = StaticLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } | 800 | let def = StaticLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
799 | .intern(self.def_collector.db); | 801 | .intern(self.def_collector.db); |
800 | 802 | ||
801 | PerNs::values(def.into()) | 803 | PerNs::values(def.into()) |
802 | } | 804 | } |
803 | raw::DefKind::Trait(ast_id) => { | 805 | raw::DefKind::Trait(ast_id) => { |
804 | let def = TraitLoc { container: module, ast_id: AstId::new(self.file_id, ast_id) } | 806 | let def = TraitLoc { container, ast_id: AstId::new(self.file_id, ast_id) } |
805 | .intern(self.def_collector.db); | 807 | .intern(self.def_collector.db); |
806 | 808 | ||
807 | PerNs::types(def.into()) | 809 | PerNs::types(def.into()) |
808 | } | 810 | } |
809 | raw::DefKind::TypeAlias(ast_id) => { | 811 | raw::DefKind::TypeAlias(ast_id) => { |
810 | let def = TypeAliasLoc { | 812 | let def = TypeAliasLoc { |
811 | container: ContainerId::ModuleId(module), | 813 | container: container.into(), |
812 | ast_id: AstId::new(self.file_id, ast_id), | 814 | ast_id: AstId::new(self.file_id, ast_id), |
813 | } | 815 | } |
814 | .intern(self.def_collector.db); | 816 | .intern(self.def_collector.db); |
diff --git a/crates/ra_hir_def/src/nameres/path_resolution.rs b/crates/ra_hir_def/src/nameres/path_resolution.rs index 1dbc4f371..2dd779b66 100644 --- a/crates/ra_hir_def/src/nameres/path_resolution.rs +++ b/crates/ra_hir_def/src/nameres/path_resolution.rs | |||
@@ -145,11 +145,6 @@ impl CrateDefMap { | |||
145 | return ResolvePathResult::empty(ReachedFixedPoint::No); // extern crate declarations can add to the extern prelude | 145 | return ResolvePathResult::empty(ReachedFixedPoint::No); // extern crate declarations can add to the extern prelude |
146 | } | 146 | } |
147 | } | 147 | } |
148 | PathKind::Type(_) => { | ||
149 | // This is handled in `infer::infer_path_expr` | ||
150 | // The result returned here does not matter | ||
151 | return ResolvePathResult::empty(ReachedFixedPoint::Yes); | ||
152 | } | ||
153 | }; | 148 | }; |
154 | 149 | ||
155 | for (i, segment) in segments { | 150 | for (i, segment) in segments { |
diff --git a/crates/ra_hir_def/src/nameres/tests/globs.rs b/crates/ra_hir_def/src/nameres/tests/globs.rs index 5b03fe365..5e24cb94d 100644 --- a/crates/ra_hir_def/src/nameres/tests/globs.rs +++ b/crates/ra_hir_def/src/nameres/tests/globs.rs | |||
@@ -112,3 +112,24 @@ fn glob_enum() { | |||
112 | "### | 112 | "### |
113 | ); | 113 | ); |
114 | } | 114 | } |
115 | |||
116 | #[test] | ||
117 | fn glob_enum_group() { | ||
118 | covers!(glob_enum_group); | ||
119 | let map = def_map( | ||
120 | " | ||
121 | //- /lib.rs | ||
122 | enum Foo { | ||
123 | Bar, Baz | ||
124 | } | ||
125 | use self::Foo::{*}; | ||
126 | ", | ||
127 | ); | ||
128 | assert_snapshot!(map, @r###" | ||
129 | ⋮crate | ||
130 | ⋮Bar: t v | ||
131 | ⋮Baz: t v | ||
132 | ⋮Foo: t | ||
133 | "### | ||
134 | ); | ||
135 | } | ||