From a9778c6d73c1ae609d9068a5aeb3e225d8154f59 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 19 Aug 2020 17:37:19 +0200 Subject: Simplify --- crates/ide/src/syntax_highlighting.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'crates/ide') diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs index 38546ead3..0a5f7a247 100644 --- a/crates/ide/src/syntax_highlighting.rs +++ b/crates/ide/src/syntax_highlighting.rs @@ -455,15 +455,10 @@ fn macro_call_range(macro_call: &ast::MacroCall) -> Option { } fn is_possibly_unsafe(name_ref: &ast::NameRef) -> bool { - name_ref - .syntax() - .parent() - .and_then(|parent| { - ast::FieldExpr::cast(parent.clone()) - .map(|_| true) - .or_else(|| ast::RecordPatField::cast(parent).map(|_| true)) - }) - .unwrap_or(false) + match name_ref.syntax().parent() { + Some(parent) => matches!(parent.kind(), FIELD_EXPR | RECORD_PAT_FIELD), + None => false, + } } fn highlight_element( -- cgit v1.2.3