summaryrefslogtreecommitdiff
path: root/rust-mode.el
diff options
context:
space:
mode:
authorChristophe Troestler <Christophe.Troestler@umons.ac.be>2022-01-19 10:44:15 +0100
committerChristophe Troestler <Christophe.Troestler@umons.ac.be>2022-01-30 14:24:17 +0100
commit32718d4b166e9ee439e2b15b5e4d8e4fa783a4c5 (patch)
treed6a10df29ce35846602a1d34a9b3239995a227f7 /rust-mode.el
parent2da2e7f08a83fbec381c8604d3e00c4ee2c02855 (diff)
downloadrust-mode-32718d4b166e9ee439e2b15b5e4d8e4fa783a4c5.tar.gz
Highlight the (optional) type suffix of numbers with the type face
Diffstat (limited to 'rust-mode.el')
-rw-r--r--rust-mode.el12
1 files changed, 12 insertions, 0 deletions
diff --git a/rust-mode.el b/rust-mode.el
index 6da7db5..09eefed 100644
--- a/rust-mode.el
+++ b/rust-mode.el
@@ -361,6 +361,16 @@ See `prettify-symbols-compose-predicate'."
"bool"
"str" "char"))
+(defconst rust-number-with-type
+ (eval-when-compile
+ (concat
+ "\\_<\\(?:0[box]?\\|[1-9]\\)[[:digit:]a-fA-F_.]*\\(?:[eE][+-]?[[:digit:]_]\\)?"
+ (regexp-opt '("u8" "i8" "u16" "i16" "u32" "i32" "u64" "i64"
+ "u128" "i128" "usize" "isize" "f32" "f64")
+ t)
+ "\\_>"))
+ "Regular expression matching a number with a type suffix.")
+
(defvar rust-builtin-formatting-macros
'("eprint"
"eprintln"
@@ -470,6 +480,8 @@ Does not match type annotations of the form \"foo::<\"."
("\\?" . 'rust-question-mark)
("\\(&+\\)\\(?:'\\(?:\\<\\|_\\)\\|\\<\\|[[({:*_|]\\)"
1 'rust-ampersand-face)
+ ;; Numbers with type suffix
+ (,rust-number-with-type 1 font-lock-type-face)
)
;; Ensure we highlight `Foo` in `struct Foo` as a type.