External Publication
Visit Post

Rustc lexer diagnostics feature request: Color highlight acceptable characters

Rust Internals [Unofficial] May 8, 2026
Source

Hi. This applies probably to macro_rules/macro v.2 only (correct me otherwise). When the lexer/tokenizer reports errors like

error: `$r#trait:ty` is followed by `(`, which is not allowed for `ty` fragments
   --> src/lib.rs:174:17
    |
174 |                 ( $(
    |                 ^ not allowed after `ty` fragments
    |
    = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where`

could it be possible to highlight each allowed characters/tokens (in terminals that use colors)? It already makes error red and warning yellow (though that is surely higher up the function call chain).

Discussion in the ATmosphere

Loading comments...