Table of Contents
Fetching ...

An Interactive Debugger for Rust Trait Errors

Gavin Gray, Will Crichton, Shriram Krishnamurthi

TL;DR

Argus addresses the difficulty of diagnosing and debugging Rust trait inference failures by providing an interactive visualization of the trait inference tree inside the IDE. It introduces an abstract Trait Model, two complementary views (bottom-up and top-down), and the inertia heuristic to rank root causes, enabling targeted debugging beyond static compiler messages. In a study with $N=25$ participants, Argus localized faults 2.2× more often and reduced localization time by 3.3× compared with standard diagnostics, demonstrating substantial gains in debugging productivity. The work suggests that UI-centric representations of type-class search can meaningfully augment compiler diagnostics and may generalize to other languages and type-class-based systems.

Abstract

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\times$ as many faults and localized $3.3\times$ faster compared to not using Argus.

An Interactive Debugger for Rust Trait Errors

TL;DR

Argus addresses the difficulty of diagnosing and debugging Rust trait inference failures by providing an interactive visualization of the trait inference tree inside the IDE. It introduces an abstract Trait Model, two complementary views (bottom-up and top-down), and the inertia heuristic to rank root causes, enabling targeted debugging beyond static compiler messages. In a study with participants, Argus localized faults 2.2× more often and reduced localization time by 3.3× compared with standard diagnostics, demonstrating substantial gains in debugging productivity. The work suggests that UI-centric representations of type-class search can meaningfully augment compiler diagnostics and may generalize to other languages and type-class-based systems.

Abstract

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 participants debugged type inference failures in realistic Rust programs, finding that participants using Argus correctly localized as many faults and localized faster compared to not using Argus.

Paper Structure

This paper contains 37 sections, 5 equations, 11 figures.

Figures (11)

  • Figure 1: An example of a trait error where the compiler elides key information for brevity. This is noted by the phrase "2 redundant requirements hidden."
  • Figure 2: An example of a trait error where the interleaving of information in the diagnostic obscures the logical structure of the problem.
  • Figure 3: An example of a trait error where a branch point in the inference process causes the diagnostic to omit information deeper in the search tree.
  • Figure 4: A grammar for ${\mathcal{L}_\textsc{Trait}}$, the essence of Rust's trait language and inference.
  • Figure 5: Interactions in Argus for iteratively expanding inference steps.
  • ...and 6 more figures