diff --git a/CHANGES.md b/CHANGES.md
index ac117f3bf2..3c044274c5 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -20,6 +20,7 @@ New Grammars:
Core Grammars:
+- fix(rust) added negative-lookahead for callable keywords `if` `while` `for` [Omar Hussein][]
- enh(armasm) added `x0-x30` and `w0-w30` ARMv8 registers [Nicholas Thompson][]
- enh(haxe) added `final`, `is`, `macro` keywords and `$` identifiers [Robert Borghese][]
- enh(haxe) support numeric separators and suffixes [Robert Borghese][]
diff --git a/src/languages/rust.js b/src/languages/rust.js
index 54b59a1423..12ac07193c 100644
--- a/src/languages/rust.js
+++ b/src/languages/rust.js
@@ -14,7 +14,7 @@ export default function(hljs) {
relevance: 0,
begin: regex.concat(
/\b/,
- /(?!let\b)/,
+ /(?!let|for|while|if|else|match\b)/,
hljs.IDENT_RE,
regex.lookahead(/\s*\(/))
};
diff --git a/test/detect/rust/default.txt b/test/detect/rust/default.txt
index 5388d8f988..29ceb466e4 100644
--- a/test/detect/rust/default.txt
+++ b/test/detect/rust/default.txt
@@ -12,5 +12,12 @@ impl From<&'a str> for State {
"closed" => State::Closed,
_ => unreachable!(),
}
+
+ if (str == "trans") {
+ State::Transient;
+ }
+ else if str == "start" {
+ State::Start;
+ }
}
}
diff --git a/test/markup/rust/invoked-keywords.expect.txt b/test/markup/rust/invoked-keywords.expect.txt
new file mode 100644
index 0000000000..aeaf02206a
--- /dev/null
+++ b/test/markup/rust/invoked-keywords.expect.txt
@@ -0,0 +1,9 @@
+if (true) {}
+if true {}
+else if (true) {}
+while (true) {}
+while true {}
+for (a, b) in (0..10).enumerate() {}
+for a in 0..10 {}
+match str {}
+match (str) {}
diff --git a/test/markup/rust/invoked-keywords.txt b/test/markup/rust/invoked-keywords.txt
new file mode 100644
index 0000000000..504d9f8636
--- /dev/null
+++ b/test/markup/rust/invoked-keywords.txt
@@ -0,0 +1,9 @@
+if (true) {}
+if true {}
+else if (true) {}
+while (true) {}
+while true {}
+for (a, b) in (0..10).enumerate() {}
+for a in 0..10 {}
+match str {}
+match (str) {}