From 45f4a1e559f11054fd567be24d91b5559b76a397 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 21 May 2021 21:08:06 +0200 Subject: Remove `StructDefKind` --- crates/hir_def/src/item_tree.rs | 11 ----------- crates/hir_def/src/item_tree/lower.rs | 7 +------ crates/hir_def/src/nameres/collector.rs | 6 +++--- 3 files changed, 4 insertions(+), 20 deletions(-) (limited to 'crates') 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 { pub generic_params: Interned, pub fields: Fields, pub ast_id: FileAstId, - pub kind: StructDefKind, -} - -#[derive(Debug, Clone, Eq, PartialEq)] -pub enum StructDefKind { - /// `struct S { ... }` - type namespace only. - Record, - /// `struct S(...);` - Tuple, - /// `struct S;` - Unit, } #[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> { let generic_params = self.lower_generic_params(GenericsOwner::Struct, strukt); let fields = self.lower_fields(&strukt.kind()); let ast_id = self.source_ast_id_map.ast_id(strukt); - let kind = match strukt.kind() { - ast::StructKind::Record(_) => StructDefKind::Record, - ast::StructKind::Tuple(_) => StructDefKind::Tuple, - ast::StructKind::Unit => StructDefKind::Unit, - }; - let res = Struct { name, visibility, generic_params, fields, ast_id, kind }; + let res = Struct { name, visibility, generic_params, fields, ast_id }; Some(id(self.data().structs.alloc(res))) } 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::{ intern::Interned, item_scope::{ImportType, PerNsGlobImports}, item_tree::{ - self, FileItemTreeId, ItemTree, ItemTreeId, MacroCall, MacroDef, MacroRules, Mod, ModItem, - ModKind, StructDefKind, + self, Fields, FileItemTreeId, ItemTree, ItemTreeId, MacroCall, MacroDef, MacroRules, Mod, + ModItem, ModKind, }, macro_call_as_call_id, nameres::{ @@ -1281,7 +1281,7 @@ impl ModCollector<'_, '_> { .into(), name: &it.name, visibility: &self.item_tree[it.visibility], - has_constructor: it.kind != StructDefKind::Record, + has_constructor: !matches!(it.fields, Fields::Record(_)), }); } ModItem::Union(id) => { -- cgit v1.2.3