70 releases

0.0.149 Jan 16, 2023
0.0.145 Dec 26, 2022
0.0.141 Nov 28, 2022
0.0.122 Jul 25, 2022
0.0.66 Jul 26, 2021
Download history 1300/week @ 2022-12-07 992/week @ 2022-12-14 1791/week @ 2022-12-21 1416/week @ 2022-12-28 1406/week @ 2023-01-04 1256/week @ 2023-01-11 1302/week @ 2023-01-18 1452/week @ 2023-01-25 1350/week @ 2023-02-01 1464/week @ 2023-02-08 1887/week @ 2023-02-15 1680/week @ 2023-02-22 1410/week @ 2023-03-01 1421/week @ 2023-03-08 1313/week @ 2023-03-15 1060/week @ 2023-03-22

5,404 downloads per month
Used in 7 crates (via ra_ap_ide)



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.


~366K SLoC