]> git.lizzy.rs Git - rust.git/commitdiff
Simplify
authorAleksey Kladov <aleksey.kladov@gmail.com>
Wed, 19 Aug 2020 15:37:19 +0000 (17:37 +0200)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Wed, 19 Aug 2020 15:37:19 +0000 (17:37 +0200)
crates/ide/src/syntax_highlighting.rs

index 38546ead3ca48b94349064948f2cbfc8cf89106d..0a5f7a247af354d14833b3bf06484c89dc52a197 100644 (file)
@@ -455,15 +455,10 @@ fn macro_call_range(macro_call: &ast::MacroCall) -> Option<TextRange> {
 }
 
 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(