aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/nameres
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-04-07 02:12:40 +0100
committerJonas Schievink <[email protected]>2021-04-07 02:12:40 +0100
commitf04f38d3d79c3cc51956bc530a34e32945cdb294 (patch)
tree130dca17ca576146796b1877a81e17def36f2f02 /crates/hir_def/src/nameres
parent3e7ac2b830f692fd993a9b30b6be96a4206b8229 (diff)
nameres: collect unnamed consts
Diffstat (limited to 'crates/hir_def/src/nameres')
-rw-r--r--crates/hir_def/src/nameres/collector.rs34
1 files changed, 21 insertions, 13 deletions
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs
index f42f92702..492d8c71f 100644
--- a/crates/hir_def/src/nameres/collector.rs
+++ b/crates/hir_def/src/nameres/collector.rs
@@ -1163,19 +1163,27 @@ impl ModCollector<'_, '_> {
1163 } 1163 }
1164 ModItem::Const(id) => { 1164 ModItem::Const(id) => {
1165 let it = &self.item_tree[id]; 1165 let it = &self.item_tree[id];
1166 1166 let const_id = ConstLoc {
1167 if let Some(name) = &it.name { 1167 container: module.into(),
1168 def = Some(DefData { 1168 id: ItemTreeId::new(self.file_id, id),
1169 id: ConstLoc { 1169 }
1170 container: module.into(), 1170 .intern(self.def_collector.db);
1171 id: ItemTreeId::new(self.file_id, id), 1171
1172 } 1172 match &it.name {
1173 .intern(self.def_collector.db) 1173 Some(name) => {
1174 .into(), 1174 def = Some(DefData {
1175 name, 1175 id: const_id.into(),
1176 visibility: &self.item_tree[it.visibility], 1176 name,
1177 has_constructor: false, 1177 visibility: &self.item_tree[it.visibility],
1178 }); 1178 has_constructor: false,
1179 });
1180 }
1181 None => {
1182 // const _: T = ...;
1183 self.def_collector.def_map.modules[self.module_id]
1184 .scope
1185 .define_unnamed_const(const_id);
1186 }
1179 } 1187 }
1180 } 1188 }
1181 ModItem::Static(id) => { 1189 ModItem::Static(id) => {