aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2020-06-23 17:28:47 +0100
committerJonas Schievink <[email protected]>2020-06-24 15:53:56 +0100
commita0ad457575bdde24d65c3fbcd4b2819459ad0291 (patch)
tree3d17fc09c2257d367d8f5d328eea31a29450cadd /crates/ra_hir_def/src
parentae7a296c85bba6ab279dd17b193f86db22ec3437 (diff)
if let else -> match
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r--crates/ra_hir_def/src/item_tree/lower.rs40
1 files changed, 21 insertions, 19 deletions
diff --git a/crates/ra_hir_def/src/item_tree/lower.rs b/crates/ra_hir_def/src/item_tree/lower.rs
index 88530af74..b97927f27 100644
--- a/crates/ra_hir_def/src/item_tree/lower.rs
+++ b/crates/ra_hir_def/src/item_tree/lower.rs
@@ -278,17 +278,18 @@ impl Ctx {
278 let mut has_self_param = false; 278 let mut has_self_param = false;
279 if let Some(param_list) = func.param_list() { 279 if let Some(param_list) = func.param_list() {
280 if let Some(self_param) = param_list.self_param() { 280 if let Some(self_param) = param_list.self_param() {
281 let self_type = if let Some(type_ref) = self_param.ascribed_type() { 281 let self_type = match self_param.ascribed_type() {
282 TypeRef::from_ast(&self.body_ctx, type_ref) 282 Some(type_ref) => TypeRef::from_ast(&self.body_ctx, type_ref),
283 } else { 283 None => {
284 let self_type = TypeRef::Path(name![Self].into()); 284 let self_type = TypeRef::Path(name![Self].into());
285 match self_param.kind() { 285 match self_param.kind() {
286 ast::SelfParamKind::Owned => self_type, 286 ast::SelfParamKind::Owned => self_type,
287 ast::SelfParamKind::Ref => { 287 ast::SelfParamKind::Ref => {
288 TypeRef::Reference(Box::new(self_type), Mutability::Shared) 288 TypeRef::Reference(Box::new(self_type), Mutability::Shared)
289 } 289 }
290 ast::SelfParamKind::MutRef => { 290 ast::SelfParamKind::MutRef => {
291 TypeRef::Reference(Box::new(self_type), Mutability::Mut) 291 TypeRef::Reference(Box::new(self_type), Mutability::Mut)
292 }
292 } 293 }
293 } 294 }
294 }; 295 };
@@ -583,20 +584,21 @@ impl Ctx {
583 } 584 }
584 585
585 fn lower_type_bounds(&mut self, node: &impl ast::TypeBoundsOwner) -> Vec<TypeBound> { 586 fn lower_type_bounds(&mut self, node: &impl ast::TypeBoundsOwner) -> Vec<TypeBound> {
586 if let Some(bound_list) = node.type_bound_list() { 587 match node.type_bound_list() {
587 bound_list.bounds().map(|it| TypeBound::from_ast(&self.body_ctx, it)).collect() 588 Some(bound_list) => {
588 } else { 589 bound_list.bounds().map(|it| TypeBound::from_ast(&self.body_ctx, it)).collect()
589 Vec::new() 590 }
591 None => Vec::new(),
590 } 592 }
591 } 593 }
592 594
593 fn lower_visibility(&self, item: &impl ast::VisibilityOwner) -> RawVisibility { 595 fn lower_visibility(&self, item: &impl ast::VisibilityOwner) -> RawVisibility {
594 if let Some(vis) = self.forced_visibility.as_ref() { 596 match &self.forced_visibility {
595 vis.clone() 597 Some(vis) => vis.clone(),
596 } else { 598 None => RawVisibility::from_ast_with_hygiene(item.visibility(), &self.hygiene),
597 RawVisibility::from_ast_with_hygiene(item.visibility(), &self.hygiene)
598 } 599 }
599 } 600 }
601
600 fn lower_type_ref(&self, type_ref: &ast::TypeRef) -> TypeRef { 602 fn lower_type_ref(&self, type_ref: &ast::TypeRef) -> TypeRef {
601 TypeRef::from_ast(&self.body_ctx, type_ref.clone()) 603 TypeRef::from_ast(&self.body_ctx, type_ref.clone())
602 } 604 }