An Interactive Debugger for Rust Trait Errors
Compiler diagnostics for type inference failures are notoriously bad, and type classes only make the problem worse. By introducing a complex search process during inference, type classes can lead to wholly inscrutable or useless errors. We describe a system, Argus, for interactively visualizing type class inferences to help programmers debug inference failures, applied specifically to Rust’s trait system. The core insight of Argus is to avoid the traditional model of compiler diagnostics as one-size-fits-all, instead providing the programmer with different views on the search tree corresponding to different debugging goals. Argus carefully uses defaults to improve debugging productivity, including interface design (e.g., not showing full paths of types by default) and heuristics (e.g., sorting obligations based on the expected complexity of fixing them). We evaluated Argus in a user study where N=25 participants debugged type inference failures in realistic Rust programs, finding that participants using Argus correctly localized 2.2× as many faults and localized 3.3× faster compared to not using Argus.
Here is an example of the Argus interface for a simple program using the Diesel library. (See the related blog post for more details.)
fn get_all_published_posts(
conn: &mut PgConnection
) -> QueryResult<Vec<(i32, String, i32)>> {
users::table
.filter(posts::published.eq(true))
.select((users::id, users::name, posts::id))
.load(conn)
}
Loading...