aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/hir/src/code_model.rs15
-rw-r--r--crates/ide/src/syntax_highlighting.rs4
2 files changed, 3 insertions, 16 deletions
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs
index fadd010e2..30a5e4580 100644
--- a/crates/hir/src/code_model.rs
+++ b/crates/hir/src/code_model.rs
@@ -41,7 +41,7 @@ use rustc_hash::FxHashSet;
41use stdx::impl_from; 41use stdx::impl_from;
42use syntax::{ 42use syntax::{
43 ast::{self, AttrsOwner, NameOwner}, 43 ast::{self, AttrsOwner, NameOwner},
44 AstNode, SmolStr, SyntaxKind, 44 AstNode, SmolStr,
45}; 45};
46use tt::{Ident, Leaf, Literal, TokenTree}; 46use tt::{Ident, Leaf, Literal, TokenTree};
47 47
@@ -787,19 +787,6 @@ impl Function {
787 pub fn has_body(self, db: &dyn HirDatabase) -> bool { 787 pub fn has_body(self, db: &dyn HirDatabase) -> bool {
788 db.function_data(self.id).has_body 788 db.function_data(self.id).has_body
789 } 789 }
790
791 /// whether this function is associated with some trait/impl
792 pub fn is_assoc_item(self, db: &dyn HirDatabase) -> bool {
793 let fn_parent_kind = self
794 .source(db)
795 .value
796 .syntax()
797 .parent()
798 .and_then(|s| s.parent())
799 .and_then(|s| Some(s.kind()));
800
801 matches!(fn_parent_kind, Some(SyntaxKind::IMPL) | Some(SyntaxKind::TRAIT))
802 }
803} 790}
804 791
805// Note: logically, this belongs to `hir_ty`, but we are not using it there yet. 792// Note: logically, this belongs to `hir_ty`, but we are not using it there yet.
diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs
index 41fd36edf..4a01097df 100644
--- a/crates/ide/src/syntax_highlighting.rs
+++ b/crates/ide/src/syntax_highlighting.rs
@@ -6,7 +6,7 @@ pub(crate) mod tags;
6#[cfg(test)] 6#[cfg(test)]
7mod tests; 7mod tests;
8 8
9use hir::{Local, Name, Semantics, VariantDef}; 9use hir::{AsAssocItem, Local, Name, Semantics, VariantDef};
10use ide_db::{ 10use ide_db::{
11 defs::{Definition, NameClass, NameRefClass}, 11 defs::{Definition, NameClass, NameRefClass},
12 RootDatabase, 12 RootDatabase,
@@ -746,7 +746,7 @@ fn highlight_def(db: &RootDatabase, def: Definition) -> Highlight {
746 if func.is_unsafe(db) { 746 if func.is_unsafe(db) {
747 h |= HighlightModifier::Unsafe; 747 h |= HighlightModifier::Unsafe;
748 } 748 }
749 if func.is_assoc_item(db) && func.self_param(db).is_none() { 749 if func.as_assoc_item(db).is_some() && func.self_param(db).is_none() {
750 h |= HighlightModifier::Static; 750 h |= HighlightModifier::Static;
751 } 751 }
752 return h; 752 return h;