]> git.lizzy.rs Git - rust.git/commitdiff
Fix syntax-highlighting for fields (`NAMED_FIELD_DEF`)
authorcynecx <me@cynecx.net>
Wed, 21 Aug 2019 22:39:18 +0000 (00:39 +0200)
committercynecx <me@cynecx.net>
Wed, 21 Aug 2019 22:39:18 +0000 (00:39 +0200)
crates/ra_ide_api/src/syntax_highlighting.rs

index 878a94f061fb27d46cfc5a396b7445a3de70846e..448acffc86ffa656eb216eda27812a14480f5ca0 100644 (file)
@@ -158,21 +158,17 @@ fn hash<T: std::hash::Hash + std::fmt::Debug>(x: T) -> u64 {
                         } else {
                             "variable"
                         }
-                    } else if name
-                        .syntax()
-                        .parent()
-                        .map(|x| {
-                            x.kind() == TYPE_PARAM
-                                || x.kind() == STRUCT_DEF
-                                || x.kind() == ENUM_DEF
-                                || x.kind() == TRAIT_DEF
-                                || x.kind() == TYPE_ALIAS_DEF
-                        })
-                        .unwrap_or(false)
-                    {
-                        "type"
                     } else {
-                        "function"
+                        name.syntax()
+                            .parent()
+                            .map(|x| match x.kind() {
+                                TYPE_PARAM | STRUCT_DEF | ENUM_DEF | TRAIT_DEF | TYPE_ALIAS_DEF => {
+                                    "type"
+                                }
+                                NAMED_FIELD_DEF => "field",
+                                _ => "function",
+                            })
+                            .unwrap_or("function")
                     }
                 } else {
                     "text"