diff --git a/crates/ra_ide/src/snapshots/highlighting.html b/crates/ra_ide/src/snapshots/highlighting.html
index c67df5c39a..635fe5cf9d 100644
--- a/crates/ra_ide/src/snapshots/highlighting.html
+++ b/crates/ra_ide/src/snapshots/highlighting.html
@@ -33,6 +33,16 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
pub y: i32,
}
+trait Bar {
+ fn bar(&self) -> i32;
+}
+
+impl Bar for Foo {
+ fn bar(&self) -> i32 {
+ self.x
+ }
+}
+
static mut STATIC_MUT: i32 = 0;
fn foo<'a, T>() -> T {
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 16123c5cb4..be57eeb0ab 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -403,13 +403,13 @@ fn highlight_element(
T![break]
| T![continue]
| T![else]
- | T![for]
| T![if]
| T![loop]
| T![match]
| T![return]
| T![while]
| T![in] => h | HighlightModifier::ControlFlow,
+ T![for] if !is_child_of_impl(element) => h | HighlightModifier::ControlFlow,
T![unsafe] => h | HighlightModifier::Unsafe,
_ => h,
}
@@ -433,6 +433,13 @@ fn highlight_element(
}
}
+fn is_child_of_impl(element: SyntaxElement) -> bool {
+ match element.parent() {
+ Some(e) => e.kind() == IMPL_DEF,
+ _ => false,
+ }
+}
+
fn highlight_name(db: &RootDatabase, def: Definition) -> Highlight {
match def {
Definition::Macro(_) => HighlightTag::Macro,
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs
index 7975755b29..eb43a23da6 100644
--- a/crates/ra_ide/src/syntax_highlighting/tests.rs
+++ b/crates/ra_ide/src/syntax_highlighting/tests.rs
@@ -17,6 +17,16 @@ struct Foo {
pub y: i32,
}
+trait Bar {
+ fn bar(&self) -> i32;
+}
+
+impl Bar for Foo {
+ fn bar(&self) -> i32 {
+ self.x
+ }
+}
+
static mut STATIC_MUT: i32 = 0;
fn foo<'a, T>() -> T {