aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/data.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-27 20:27:01 +0000
committerGitHub <[email protected]>2019-11-27 20:27:01 +0000
commit922ec610d19aef7fb8b4df389ac318f4f2a0202c (patch)
treef94102d2fd9431abaa5447315f152838db5bf9fc /crates/ra_hir_def/src/data.rs
parentc0bb667a7dfaecfefacf0b3b6cb1e483aac6747a (diff)
parent1d14fd17372b42c3343daf6adc9a520fdf5e9810 (diff)
Merge #2433
2433: Use Name::missing consistently r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
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}