From d8caf56dfc9eb3cdddff05b58b954a78cf1b9476 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 22 Nov 2019 21:52:06 +0300 Subject: Uniformalize naming --- crates/ra_hir_def/src/adt.rs | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'crates/ra_hir_def') diff --git a/crates/ra_hir_def/src/adt.rs b/crates/ra_hir_def/src/adt.rs index d04f54e15..2bd18255c 100644 --- a/crates/ra_hir_def/src/adt.rs +++ b/crates/ra_hir_def/src/adt.rs @@ -30,13 +30,9 @@ pub struct EnumVariantData { pub variant_data: Arc, } -/// Fields of an enum variant or struct #[derive(Debug, Clone, PartialEq, Eq)] -pub struct VariantData(VariantDataInner); - -#[derive(Debug, Clone, PartialEq, Eq)] -enum VariantDataInner { - Struct(Arena), +pub enum VariantData { + Record(Arena), Tuple(Arena), Unit, } @@ -86,7 +82,7 @@ impl EnumData { impl VariantData { fn new(flavor: ast::StructKind) -> Self { - let inner = match flavor { + match flavor { ast::StructKind::Tuple(fl) => { let fields = fl .fields() @@ -96,9 +92,9 @@ impl VariantData { type_ref: TypeRef::from_ast_opt(fd.type_ref()), }) .collect(); - VariantDataInner::Tuple(fields) + VariantData::Tuple(fields) } - ast::StructKind::Named(fl) => { + ast::StructKind::Record(fl) => { let fields = fl .fields() .map(|fd| StructFieldData { @@ -106,16 +102,15 @@ impl VariantData { type_ref: TypeRef::from_ast_opt(fd.ascribed_type()), }) .collect(); - VariantDataInner::Struct(fields) + VariantData::Record(fields) } - ast::StructKind::Unit => VariantDataInner::Unit, - }; - VariantData(inner) + ast::StructKind::Unit => VariantData::Unit, + } } pub fn fields(&self) -> Option<&Arena> { - match &self.0 { - VariantDataInner::Struct(fields) | VariantDataInner::Tuple(fields) => Some(fields), + match self { + VariantData::Record(fields) | VariantData::Tuple(fields) => Some(fields), _ => None, } } -- cgit v1.2.3