aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src')
-rw-r--r--crates/hir_def/src/item_tree.rs11
-rw-r--r--crates/hir_def/src/item_tree/lower.rs7
-rw-r--r--crates/hir_def/src/nameres/collector.rs6
3 files changed, 4 insertions, 20 deletions
diff --git a/crates/hir_def/src/item_tree.rs b/crates/hir_def/src/item_tree.rs
index 797b905d1..7440e7d29 100644
--- a/crates/hir_def/src/item_tree.rs
+++ b/crates/hir_def/src/item_tree.rs
@@ -560,17 +560,6 @@ pub struct Struct {
560 pub generic_params: Interned<GenericParams>, 560 pub generic_params: Interned<GenericParams>,
561 pub fields: Fields, 561 pub fields: Fields,
562 pub ast_id: FileAstId<ast::Struct>, 562 pub ast_id: FileAstId<ast::Struct>,
563 pub kind: StructDefKind,
564}
565
566#[derive(Debug, Clone, Eq, PartialEq)]
567pub enum StructDefKind {
568 /// `struct S { ... }` - type namespace only.
569 Record,
570 /// `struct S(...);`
571 Tuple,
572 /// `struct S;`
573 Unit,
574} 563}
575 564
576#[derive(Debug, Clone, Eq, PartialEq)] 565#[derive(Debug, Clone, Eq, PartialEq)]
diff --git a/crates/hir_def/src/item_tree/lower.rs b/crates/hir_def/src/item_tree/lower.rs
index a7ffc6364..91cf75371 100644
--- a/crates/hir_def/src/item_tree/lower.rs
+++ b/crates/hir_def/src/item_tree/lower.rs
@@ -228,12 +228,7 @@ impl<'a> Ctx<'a> {
228 let generic_params = self.lower_generic_params(GenericsOwner::Struct, strukt); 228 let generic_params = self.lower_generic_params(GenericsOwner::Struct, strukt);
229 let fields = self.lower_fields(&strukt.kind()); 229 let fields = self.lower_fields(&strukt.kind());
230 let ast_id = self.source_ast_id_map.ast_id(strukt); 230 let ast_id = self.source_ast_id_map.ast_id(strukt);
231 let kind = match strukt.kind() { 231 let res = Struct { name, visibility, generic_params, fields, ast_id };
232 ast::StructKind::Record(_) => StructDefKind::Record,
233 ast::StructKind::Tuple(_) => StructDefKind::Tuple,
234 ast::StructKind::Unit => StructDefKind::Unit,
235 };
236 let res = Struct { name, visibility, generic_params, fields, ast_id, kind };
237 Some(id(self.data().structs.alloc(res))) 232 Some(id(self.data().structs.alloc(res)))
238 } 233 }
239 234
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs
index fa4b135fd..9b108bfe7 100644
--- a/crates/hir_def/src/nameres/collector.rs
+++ b/crates/hir_def/src/nameres/collector.rs
@@ -27,8 +27,8 @@ use crate::{
27 intern::Interned, 27 intern::Interned,
28 item_scope::{ImportType, PerNsGlobImports}, 28 item_scope::{ImportType, PerNsGlobImports},
29 item_tree::{ 29 item_tree::{
30 self, FileItemTreeId, ItemTree, ItemTreeId, MacroCall, MacroDef, MacroRules, Mod, ModItem, 30 self, Fields, FileItemTreeId, ItemTree, ItemTreeId, MacroCall, MacroDef, MacroRules, Mod,
31 ModKind, StructDefKind, 31 ModItem, ModKind,
32 }, 32 },
33 macro_call_as_call_id, 33 macro_call_as_call_id,
34 nameres::{ 34 nameres::{
@@ -1281,7 +1281,7 @@ impl ModCollector<'_, '_> {
1281 .into(), 1281 .into(),
1282 name: &it.name, 1282 name: &it.name,
1283 visibility: &self.item_tree[it.visibility], 1283 visibility: &self.item_tree[it.visibility],
1284 has_constructor: it.kind != StructDefKind::Record, 1284 has_constructor: !matches!(it.fields, Fields::Record(_)),
1285 }); 1285 });
1286 } 1286 }
1287 ModItem::Union(id) => { 1287 ModItem::Union(id) => {