Type-level programming - how to provide better compiler errors?

I have put this under “compiler”, but feel free to move it elsewhere if it suits better.

There are several crates in the Rust ecosystem who are currently leveraging the expressiveness of the type system to move certain checks or computations from the runtime phase to the compilation phase. This is also part of a more general trend, with efforts like const generics currently being pursued as one of the area of focus for 2019.

This category of crates includes typenum and Frunk.

Both of them are seen as double-edge swords: they unlock fantastic compile-time guarantees (Frunk's HList, for example), but given that you are failing at compile time, the error messages you are dealing with are compiler error messages and they are… obscure. This significantly hinders their usability, especially when it comes to users who are not very familiar with Rust and its compiler - they would reasonably be scared away from these very long, opaque errors.

Is there any way, either using a compiler plugin or other metaprogramming features, to provide better error messages for these crates? For example, intercepting a compiler error message and converting it into something that is more insightful for the end user?

I am speaking from a position of very little knowledge when it comes to the compiler internals, so excuse me if this question has already been answered (either positively or negatively) in the past.


I think a large part of the blame here can be attributed to:


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.