aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/data.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src/data.rs')
-rw-r--r--crates/ra_hir_def/src/data.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs
index 813099a05..fee10b237 100644
--- a/crates/ra_hir_def/src/data.rs
+++ b/crates/ra_hir_def/src/data.rs
@@ -86,7 +86,7 @@ impl TypeAliasData {
86 86
87#[derive(Debug, Clone, PartialEq, Eq)] 87#[derive(Debug, Clone, PartialEq, Eq)]
88pub struct TraitData { 88pub struct TraitData {
89 pub name: Option<Name>, 89 pub name: Name,
90 pub items: Vec<(Name, AssocItemId)>, 90 pub items: Vec<(Name, AssocItemId)>,
91 pub auto: bool, 91 pub auto: bool,
92} 92}
@@ -94,7 +94,7 @@ pub struct TraitData {
94impl TraitData { 94impl TraitData {
95 pub(crate) fn trait_data_query(db: &impl DefDatabase, tr: TraitId) -> Arc<TraitData> { 95 pub(crate) fn trait_data_query(db: &impl DefDatabase, tr: TraitId) -> Arc<TraitData> {
96 let src = tr.source(db); 96 let src = tr.source(db);
97 let name = src.value.name().map(|n| n.as_name()); 97 let name = src.value.name().map_or_else(Name::missing, |n| n.as_name());
98 let auto = src.value.is_auto(); 98 let auto = src.value.is_auto();
99 let ast_id_map = db.ast_id_map(src.file_id); 99 let ast_id_map = db.ast_id_map(src.file_id);
100 100
@@ -104,7 +104,7 @@ impl TraitData {
104 .impl_items() 104 .impl_items()
105 .map(|item_node| match item_node { 105 .map(|item_node| match item_node {
106 ast::ImplItem::FnDef(it) => { 106 ast::ImplItem::FnDef(it) => {
107 let name = it.name().map(|it| it.as_name()).unwrap_or_else(Name::missing); 107 let name = it.name().map_or_else(Name::missing, |it| it.as_name());
108 let def = FunctionLoc { 108 let def = FunctionLoc {
109 container, 109 container,
110 ast_id: AstId::new(src.file_id, ast_id_map.ast_id(&it)), 110 ast_id: AstId::new(src.file_id, ast_id_map.ast_id(&it)),
@@ -114,7 +114,7 @@ impl TraitData {
114 (name, def) 114 (name, def)
115 } 115 }
116 ast::ImplItem::ConstDef(it) => { 116 ast::ImplItem::ConstDef(it) => {
117 let name = it.name().map(|it| it.as_name()).unwrap_or_else(Name::missing); 117 let name = it.name().map_or_else(Name::missing, |it| it.as_name());
118 let def = ConstLoc { 118 let def = ConstLoc {
119 container, 119 container,
120 ast_id: AstId::new(src.file_id, ast_id_map.ast_id(&it)), 120 ast_id: AstId::new(src.file_id, ast_id_map.ast_id(&it)),
@@ -124,7 +124,7 @@ impl TraitData {
124 (name, def) 124 (name, def)
125 } 125 }
126 ast::ImplItem::TypeAliasDef(it) => { 126 ast::ImplItem::TypeAliasDef(it) => {
127 let name = it.name().map(|it| it.as_name()).unwrap_or_else(Name::missing); 127 let name = it.name().map_or_else(Name::missing, |it| it.as_name());
128 let def = TypeAliasLoc { 128 let def = TypeAliasLoc {
129 container, 129 container,
130 ast_id: AstId::new(src.file_id, ast_id_map.ast_id(&it)), 130 ast_id: AstId::new(src.file_id, ast_id_map.ast_id(&it)),
@@ -214,6 +214,7 @@ impl ImplData {
214 214
215#[derive(Debug, Clone, PartialEq, Eq)] 215#[derive(Debug, Clone, PartialEq, Eq)]
216pub struct ConstData { 216pub struct ConstData {
217 /// const _: () = ();
217 pub name: Option<Name>, 218 pub name: Option<Name>,
218 pub type_ref: TypeRef, 219 pub type_ref: TypeRef,
219} 220}