aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/adt.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/adt.rs')
-rw-r--r--crates/ra_hir/src/adt.rs22
1 files changed, 8 insertions, 14 deletions
diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs
index e65f8deb8..40a45b831 100644
--- a/crates/ra_hir/src/adt.rs
+++ b/crates/ra_hir/src/adt.rs
@@ -30,14 +30,14 @@ impl Struct {
30 Ok(db.struct_data(self.def_id)?) 30 Ok(db.struct_data(self.def_id)?)
31 } 31 }
32 32
33 pub fn name(&self, db: &impl HirDatabase) -> Cancelable<SmolStr> { 33 pub fn name(&self, db: &impl HirDatabase) -> Cancelable<Option<SmolStr>> {
34 Ok(db.struct_data(self.def_id)?.name.clone()) 34 Ok(db.struct_data(self.def_id)?.name.clone())
35 } 35 }
36} 36}
37 37
38#[derive(Debug, Clone, PartialEq, Eq)] 38#[derive(Debug, Clone, PartialEq, Eq)]
39pub struct StructData { 39pub struct StructData {
40 name: SmolStr, 40 name: Option<SmolStr>,
41 variant_data: Arc<VariantData>, 41 variant_data: Arc<VariantData>,
42} 42}
43 43
@@ -47,17 +47,14 @@ impl StructData {
47 module: &Module, 47 module: &Module,
48 struct_def: ast::StructDef, 48 struct_def: ast::StructDef,
49 ) -> Cancelable<StructData> { 49 ) -> Cancelable<StructData> {
50 let name = struct_def 50 let name = struct_def.name().map(|n| n.text());
51 .name()
52 .map(|n| n.text())
53 .unwrap_or(SmolStr::new("[error]"));
54 let variant_data = VariantData::new(db, module, struct_def.flavor())?; 51 let variant_data = VariantData::new(db, module, struct_def.flavor())?;
55 let variant_data = Arc::new(variant_data); 52 let variant_data = Arc::new(variant_data);
56 Ok(StructData { name, variant_data }) 53 Ok(StructData { name, variant_data })
57 } 54 }
58 55
59 pub fn name(&self) -> &SmolStr { 56 pub fn name(&self) -> Option<&SmolStr> {
60 &self.name 57 self.name.as_ref()
61 } 58 }
62 59
63 pub fn variant_data(&self) -> &Arc<VariantData> { 60 pub fn variant_data(&self) -> &Arc<VariantData> {
@@ -78,14 +75,14 @@ impl Enum {
78 self.def_id 75 self.def_id
79 } 76 }
80 77
81 pub fn name(&self, db: &impl HirDatabase) -> Cancelable<SmolStr> { 78 pub fn name(&self, db: &impl HirDatabase) -> Cancelable<Option<SmolStr>> {
82 Ok(db.enum_data(self.def_id)?.name.clone()) 79 Ok(db.enum_data(self.def_id)?.name.clone())
83 } 80 }
84} 81}
85 82
86#[derive(Debug, Clone, PartialEq, Eq)] 83#[derive(Debug, Clone, PartialEq, Eq)]
87pub struct EnumData { 84pub struct EnumData {
88 name: SmolStr, 85 name: Option<SmolStr>,
89 variants: Vec<(SmolStr, Arc<VariantData>)>, 86 variants: Vec<(SmolStr, Arc<VariantData>)>,
90} 87}
91 88
@@ -95,10 +92,7 @@ impl EnumData {
95 module: &Module, 92 module: &Module,
96 enum_def: ast::EnumDef, 93 enum_def: ast::EnumDef,
97 ) -> Cancelable<Self> { 94 ) -> Cancelable<Self> {
98 let name = enum_def 95 let name = enum_def.name().map(|n| n.text());
99 .name()
100 .map(|n| n.text())
101 .unwrap_or(SmolStr::new("[error]"));
102 let variants = if let Some(evl) = enum_def.variant_list() { 96 let variants = if let Some(evl) = enum_def.variant_list() {
103 evl.variants() 97 evl.variants()
104 .map(|v| { 98 .map(|v| {