117 releases

new 0.0.212 Apr 22, 2024
0.0.207 Mar 25, 2024
0.0.190 Dec 18, 2023
0.0.187 Nov 27, 2023
0.0.66 Jul 26, 2021

#133 in Programming languages

Download history 725/week @ 2023-12-25 1433/week @ 2024-01-01 2188/week @ 2024-01-08 2032/week @ 2024-01-15 1696/week @ 2024-01-22 1573/week @ 2024-01-29 1779/week @ 2024-02-05 1343/week @ 2024-02-12 1675/week @ 2024-02-19 3736/week @ 2024-02-26 1786/week @ 2024-03-04 1860/week @ 2024-03-11 2117/week @ 2024-03-18 1803/week @ 2024-03-25 1874/week @ 2024-04-01 1291/week @ 2024-04-08

7,320 downloads per month
Used in 10 crates (via ra_ap_ide)

MIT/Apache

335KB
12K SLoC

Diagnostics rendering and fixits.

Most of the diagnostics originate from the dark depth of the compiler, and are originally expressed in term of IR. When we emit the diagnostic, we are usually not in the position to decide how to best "render" it in terms of user-authored source code. We are especially not in the position to offer fixits, as the compiler completely lacks the infrastructure to edit the source code.

Instead, we "bubble up" raw, structured diagnostics until the hir crate, where we "cook" them so that each diagnostic is formulated in terms of hir types. Well, at least that's the aspiration, the "cooking" is somewhat ad-hoc at the moment. Anyways, we get a bunch of ide-friendly diagnostic structs from hir, and we want to render them to unified serializable representation (span, level, message) here. If we can, we also provide fixits. By the way, that's why we want to keep diagnostics structured internally -- so that we have all the info to make fixes.

We have one "handler" module per diagnostic code. Such a module contains rendering, optional fixes and tests. It's OK if some low-level compiler functionality ends up being tested via a diagnostic.

There are also a couple of ad-hoc diagnostics implemented directly here, we don't yet have a great pattern for how to do them properly.

Dependencies

~15–26MB
~394K SLoC