rust-lang / rust-mode

Emacs configuration for Rust
Apache License 2.0
1.1k stars 176 forks source link

Font-lock confused by apparent float suffix in non-decimal literal #540

Open timmc opened 2 months ago

timmc commented 2 months ago

The string 0xf64 is a hex literal (for the number 3940), but rust-mode highlights the f64 as a type suffix, making it appear to be a floating point number. This also happens when there are leading digits, such as in 0x1234f64.

Not a huge deal, but maybe something that you want to fix.

psibi commented 2 months ago

Can you check if it works with tree sitter mode: https://github.com/rust-lang/rust-mode?tab=readme-ov-file#tree-sitter ?

timmc commented 2 months ago

I got tree-sitter mode working, but... the syntax highlighting colors the entire number the same way and no longer highlights the prefix! So technically this fixes the bug, but not in the desired way. :-P

psibi commented 2 months ago

Ah, I see. :-) I see the same behavior using LSP's semantic tokens too. I would recommend opening a bug report in Emacs for this.

timmc commented 2 months ago

Can you tell me more about why this would be an Emacs bug? It seems specific to Rust syntax. (As it's a minor thing, I'm not super likely to file another bug, but I'm curious.)

psibi commented 2 months ago

IIUC, Tree sitter is part of Emacs: https://www.gnu.org/software/emacs/manual/html_node/elisp/Language-Grammar.html