From a1aa8212effd87cc04a912a23c46340c74070da9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 27 Nov 2021 18:18:00 +0300 Subject: [PATCH] minor: if-let-else to shorter match --- crates/hir_def/src/item_tree.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/crates/hir_def/src/item_tree.rs b/crates/hir_def/src/item_tree.rs index 12fa34b73ab..db2398fbdee 100644 --- a/crates/hir_def/src/item_tree.rs +++ b/crates/hir_def/src/item_tree.rs @@ -105,15 +105,14 @@ pub struct ItemTree { impl ItemTree { pub(crate) fn file_item_tree_query(db: &dyn DefDatabase, file_id: HirFileId) -> Arc { let _p = profile::span("item_tree_query").detail(|| format!("{:?}", file_id)); - let syntax = if let Some(node) = db.parse_or_expand(file_id) { - if node.kind() == SyntaxKind::ERROR { - // FIXME: not 100% sure why these crop up, but return an empty tree to avoid a panic - return Default::default(); - } - node - } else { - return Default::default(); + let syntax = match db.parse_or_expand(file_id) { + Some(node) => node, + None => return Default::default(), }; + if syntax.kind() == SyntaxKind::ERROR { + // FIXME: not 100% sure why these crop up, but return an empty tree to avoid a panic + return Default::default(); + } let hygiene = Hygiene::new(db.upcast(), file_id); let ctx = lower::Ctx::new(db, hygiene.clone(), file_id);