diff options
Diffstat (limited to 'crates/hir_def/src/nameres/collector.rs')
-rw-r--r-- | crates/hir_def/src/nameres/collector.rs | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index 3bb69d935..9ed48c506 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs | |||
@@ -37,9 +37,9 @@ use crate::{ | |||
37 | path::{ImportAlias, ModPath, PathKind}, | 37 | path::{ImportAlias, ModPath, PathKind}, |
38 | per_ns::PerNs, | 38 | per_ns::PerNs, |
39 | visibility::{RawVisibility, Visibility}, | 39 | visibility::{RawVisibility, Visibility}, |
40 | AdtId, AstId, AstIdWithPath, ConstLoc, ContainerId, EnumLoc, EnumVariantId, FunctionLoc, | 40 | AdtId, AstId, AstIdWithPath, ConstLoc, EnumLoc, EnumVariantId, FunctionLoc, ImplLoc, Intern, |
41 | ImplLoc, Intern, LocalModuleId, ModuleDefId, StaticLoc, StructLoc, TraitLoc, TypeAliasLoc, | 41 | LocalModuleId, ModuleDefId, StaticLoc, StructLoc, TraitLoc, TypeAliasLoc, UnionLoc, |
42 | UnionLoc, UnresolvedMacro, | 42 | UnresolvedMacro, |
43 | }; | 43 | }; |
44 | 44 | ||
45 | const GLOB_RECURSION_LIMIT: usize = 100; | 45 | const GLOB_RECURSION_LIMIT: usize = 100; |
@@ -1042,7 +1042,6 @@ impl ModCollector<'_, '_> { | |||
1042 | } | 1042 | } |
1043 | } | 1043 | } |
1044 | let module = self.def_collector.def_map.module_id(self.module_id); | 1044 | let module = self.def_collector.def_map.module_id(self.module_id); |
1045 | let container = ContainerId::ModuleId(module); | ||
1046 | 1045 | ||
1047 | let mut def = None; | 1046 | let mut def = None; |
1048 | match item { | 1047 | match item { |
@@ -1109,9 +1108,9 @@ impl ModCollector<'_, '_> { | |||
1109 | } | 1108 | } |
1110 | ModItem::Impl(imp) => { | 1109 | ModItem::Impl(imp) => { |
1111 | let module = self.def_collector.def_map.module_id(self.module_id); | 1110 | let module = self.def_collector.def_map.module_id(self.module_id); |
1112 | let container = ContainerId::ModuleId(module); | 1111 | let impl_id = |
1113 | let impl_id = ImplLoc { container, id: ItemTreeId::new(self.file_id, imp) } | 1112 | ImplLoc { container: module, id: ItemTreeId::new(self.file_id, imp) } |
1114 | .intern(self.def_collector.db); | 1113 | .intern(self.def_collector.db); |
1115 | self.def_collector.def_map.modules[self.module_id].scope.define_impl(impl_id) | 1114 | self.def_collector.def_map.modules[self.module_id].scope.define_impl(impl_id) |
1116 | } | 1115 | } |
1117 | ModItem::Function(id) => { | 1116 | ModItem::Function(id) => { |
@@ -1121,7 +1120,7 @@ impl ModCollector<'_, '_> { | |||
1121 | 1120 | ||
1122 | def = Some(DefData { | 1121 | def = Some(DefData { |
1123 | id: FunctionLoc { | 1122 | id: FunctionLoc { |
1124 | container: container.into(), | 1123 | container: module.into(), |
1125 | id: ItemTreeId::new(self.file_id, id), | 1124 | id: ItemTreeId::new(self.file_id, id), |
1126 | } | 1125 | } |
1127 | .intern(self.def_collector.db) | 1126 | .intern(self.def_collector.db) |
@@ -1140,7 +1139,7 @@ impl ModCollector<'_, '_> { | |||
1140 | self.collect_derives(&attrs, it.ast_id.upcast()); | 1139 | self.collect_derives(&attrs, it.ast_id.upcast()); |
1141 | 1140 | ||
1142 | def = Some(DefData { | 1141 | def = Some(DefData { |
1143 | id: StructLoc { container, id: ItemTreeId::new(self.file_id, id) } | 1142 | id: StructLoc { container: module, id: ItemTreeId::new(self.file_id, id) } |
1144 | .intern(self.def_collector.db) | 1143 | .intern(self.def_collector.db) |
1145 | .into(), | 1144 | .into(), |
1146 | name: &it.name, | 1145 | name: &it.name, |
@@ -1157,7 +1156,7 @@ impl ModCollector<'_, '_> { | |||
1157 | self.collect_derives(&attrs, it.ast_id.upcast()); | 1156 | self.collect_derives(&attrs, it.ast_id.upcast()); |
1158 | 1157 | ||
1159 | def = Some(DefData { | 1158 | def = Some(DefData { |
1160 | id: UnionLoc { container, id: ItemTreeId::new(self.file_id, id) } | 1159 | id: UnionLoc { container: module, id: ItemTreeId::new(self.file_id, id) } |
1161 | .intern(self.def_collector.db) | 1160 | .intern(self.def_collector.db) |
1162 | .into(), | 1161 | .into(), |
1163 | name: &it.name, | 1162 | name: &it.name, |
@@ -1174,7 +1173,7 @@ impl ModCollector<'_, '_> { | |||
1174 | self.collect_derives(&attrs, it.ast_id.upcast()); | 1173 | self.collect_derives(&attrs, it.ast_id.upcast()); |
1175 | 1174 | ||
1176 | def = Some(DefData { | 1175 | def = Some(DefData { |
1177 | id: EnumLoc { container, id: ItemTreeId::new(self.file_id, id) } | 1176 | id: EnumLoc { container: module, id: ItemTreeId::new(self.file_id, id) } |
1178 | .intern(self.def_collector.db) | 1177 | .intern(self.def_collector.db) |
1179 | .into(), | 1178 | .into(), |
1180 | name: &it.name, | 1179 | name: &it.name, |
@@ -1188,7 +1187,7 @@ impl ModCollector<'_, '_> { | |||
1188 | if let Some(name) = &it.name { | 1187 | if let Some(name) = &it.name { |
1189 | def = Some(DefData { | 1188 | def = Some(DefData { |
1190 | id: ConstLoc { | 1189 | id: ConstLoc { |
1191 | container: container.into(), | 1190 | container: module.into(), |
1192 | id: ItemTreeId::new(self.file_id, id), | 1191 | id: ItemTreeId::new(self.file_id, id), |
1193 | } | 1192 | } |
1194 | .intern(self.def_collector.db) | 1193 | .intern(self.def_collector.db) |
@@ -1203,7 +1202,7 @@ impl ModCollector<'_, '_> { | |||
1203 | let it = &self.item_tree[id]; | 1202 | let it = &self.item_tree[id]; |
1204 | 1203 | ||
1205 | def = Some(DefData { | 1204 | def = Some(DefData { |
1206 | id: StaticLoc { container, id: ItemTreeId::new(self.file_id, id) } | 1205 | id: StaticLoc { container: module, id: ItemTreeId::new(self.file_id, id) } |
1207 | .intern(self.def_collector.db) | 1206 | .intern(self.def_collector.db) |
1208 | .into(), | 1207 | .into(), |
1209 | name: &it.name, | 1208 | name: &it.name, |
@@ -1215,7 +1214,7 @@ impl ModCollector<'_, '_> { | |||
1215 | let it = &self.item_tree[id]; | 1214 | let it = &self.item_tree[id]; |
1216 | 1215 | ||
1217 | def = Some(DefData { | 1216 | def = Some(DefData { |
1218 | id: TraitLoc { container, id: ItemTreeId::new(self.file_id, id) } | 1217 | id: TraitLoc { container: module, id: ItemTreeId::new(self.file_id, id) } |
1219 | .intern(self.def_collector.db) | 1218 | .intern(self.def_collector.db) |
1220 | .into(), | 1219 | .into(), |
1221 | name: &it.name, | 1220 | name: &it.name, |
@@ -1228,7 +1227,7 @@ impl ModCollector<'_, '_> { | |||
1228 | 1227 | ||
1229 | def = Some(DefData { | 1228 | def = Some(DefData { |
1230 | id: TypeAliasLoc { | 1229 | id: TypeAliasLoc { |
1231 | container: container.into(), | 1230 | container: module.into(), |
1232 | id: ItemTreeId::new(self.file_id, id), | 1231 | id: ItemTreeId::new(self.file_id, id), |
1233 | } | 1232 | } |
1234 | .intern(self.def_collector.db) | 1233 | .intern(self.def_collector.db) |