Rustc lexer diagnostics feature request: Color highlight acceptable characters

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 control chain).

1 Like

Good idea.

Could you report this as a request on Issues · rust-lang/rust · GitHub , with some sample code triggering it, and label it "A-diagnostics" "D-diagnostic-infra"?

Thank you!

4 Likes

Filed as rustc lexer/macro_rules diagnostics feature request: Color highlight acceptable characters · Issue #156458 · rust-lang/rust · GitHub.

3 Likes