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.rs25
1 files changed, 11 insertions, 14 deletions
diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs
index c6463235c..b75adda84 100644
--- a/crates/ra_hir/src/adt.rs
+++ b/crates/ra_hir/src/adt.rs
@@ -42,7 +42,7 @@ pub struct StructData {
42} 42}
43 43
44impl StructData { 44impl StructData {
45 pub(crate) fn new(struct_def: ast::StructDef) -> StructData { 45 pub(crate) fn new(struct_def: &ast::StructDef) -> StructData {
46 let name = struct_def.name().map(|n| n.as_name()); 46 let name = struct_def.name().map(|n| n.as_name());
47 let variant_data = VariantData::new(struct_def.flavor()); 47 let variant_data = VariantData::new(struct_def.flavor());
48 let variant_data = Arc::new(variant_data); 48 let variant_data = Arc::new(variant_data);
@@ -87,7 +87,7 @@ pub struct EnumData {
87} 87}
88 88
89impl EnumData { 89impl EnumData {
90 pub(crate) fn new(enum_def: ast::EnumDef) -> Self { 90 pub(crate) fn new(enum_def: &ast::EnumDef) -> Self {
91 let name = enum_def.name().map(|n| n.as_name()); 91 let name = enum_def.name().map(|n| n.as_name());
92 let variants = if let Some(evl) = enum_def.variant_list() { 92 let variants = if let Some(evl) = enum_def.variant_list() {
93 evl.variants() 93 evl.variants()
@@ -171,24 +171,21 @@ impl VariantData {
171 } 171 }
172 } 172 }
173 pub fn is_struct(&self) -> bool { 173 pub fn is_struct(&self) -> bool {
174 if let VariantData::Struct(..) = *self { 174 match self {
175 true 175 VariantData::Struct(..) => true,
176 } else { 176 _ => false,
177 false
178 } 177 }
179 } 178 }
180 pub fn is_tuple(&self) -> bool { 179 pub fn is_tuple(&self) -> bool {
181 if let VariantData::Tuple(..) = *self { 180 match self {
182 true 181 VariantData::Tuple(..) => true,
183 } else { 182 _ => false,
184 false
185 } 183 }
186 } 184 }
187 pub fn is_unit(&self) -> bool { 185 pub fn is_unit(&self) -> bool {
188 if let VariantData::Unit = *self { 186 match self {
189 true 187 VariantData::Unit => true,
190 } else { 188 _ => false,
191 false
192 } 189 }
193 } 190 }
194} 191}