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

From: Vincenzo Pupillo <[email-masked]>
Date: Tue, 22 Apr 2025 21:24:42 +0200

Yes, I add here the result returned by tree-sitter command line with rust 
grammar v0.23.2:

(ERROR [0, 0] - [1105, 0]
 (line_comment [0, 0] - [1, 0]
 inner: (inner_doc_comment_marker [0, 2] - [0, 3])
 doc: (doc_comment [0, 3] - [1, 0]))
 (line_comment [1, 0] - [2, 0]
 inner: (inner_doc_comment_marker [1, 2] - [1, 3])
 doc: (doc_comment [1, 3] - [2, 0]))
 (line_comment [2, 0] - [3, 0]
 inner: (inner_doc_comment_marker [2, 2] - [2, 3])
 doc: (doc_comment [2, 3] - [3, 0])
 (line_comment [3, 0] - [4, 0]
.....

This tool also marks the entire buffer as incorrect.

Vincenzo

In data martedì 22 aprile 2025 20:30:04 Ora legale dell’Europa centrale, Juri 
Linkov ha scritto:
> > 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 ) * ))
>      ?)
>     ) => { $)