Subject: Re: bug#77914: 31.0.50; treesit-font-lock-level set to 4 cause rust-ts-mode lost all color

From: Juri Linkov <[email-masked]>
Date: Tue, 22 Apr 2025 21:30:04 +0300

> To reproduce this: use this rust file:
>
> Then eval:
> 1. (progn  (setq treesit-font-lock-level 4) (revert-buffer))
> all color are lost.
>
> 2. (progn  (setq treesit-font-lock-level 3) (revert-buffer))
> colors are good. !Important, level 3 is good, but level 4 lost colors.
>
> 3. (progn  (setq treesit-font-lock-level 4) (revert-buffer))
> all color are lost again.

The treesit-font-lock-level 4 contains the symbol 'error',
therefore it adds highlighting of the ERROR nodes.
At level 3 there are still errors, but whey are not highlighted.
Removing the macro removes the errors.

So if you are sure that the file is correct,
you can report the issue to the authors of
https://github.com/tree-sitter/tree-sitter-rust

Then they can answer why everything in the first macro
is the error:

  (ERROR
   (ERROR (identifier))
   (identifier) {
   (ERROR ( $ ()
   (attribute_item # [
    (ERROR $ ()
    (attribute (metavariable))
    (ERROR : tt ) *)
    ])
   (ERROR ) * (metavariable) : ident)
   (identifier)
   (ERROR $ ( { $ ( (metavariable) :
    (try_expression (identifier)
     (ERROR ) * } ))
     ?)
    (metavariable) : (identifier)
    (ERROR $)
    (
    (ERROR , $)
    ( (metavariable))
   :
   (ERROR
    (try_expression (identifier)
     (ERROR ) * ))
     ?)
    ) => { $)