Skip to content

Commit 112874d

Browse files
authored
Merge pull request #182 from Muscraft/continue-annotate-snippets
Continue annotate-snippets goal from 2024H2
2 parents 12db6c9 + 3bde9ea commit 112874d

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

src/2025h1/annotate-snippets.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Use annotate-snippets for rustc diagnostic output
2+
3+
| Metadata | |
4+
| --- | --- |
5+
| Owner(s) | @estebank, @Muscraft |
6+
| Teams | [compiler] |
7+
| Status | Proposed |
8+
9+
10+
## Summary
11+
12+
Switch to annotate-snippets for rendering rustc's output, with no loss of functionality or visual regressions.
13+
14+
## Motivation
15+
16+
Cargo has been [adding its own linting system][cargo-lints], where it has been using annotate-snippets to try and match Rust's output. This has led to duplicate code between the two, increasing the overall maintenance load. Having one renderer that produces Rust-like diagnostics will make it so there is a consistent style between Rust and Cargo, as well as any other tools with similar requirements like miri, and should lower the overall maintenance burden by rallying behind a single unified solution.
17+
18+
### The status quo
19+
20+
Currently rustc has its own Emitter that encodes the theming properties of compiler diagnostics. It has handle all of the intricacies of terminal support (optional color, terminal width querying and adapting of output), layout (span and label rendering logic), and the presentation of different levels of information. Any tool that wants to approximate rustc's output for their own purposes, needs to use a third-party tool that diverges from rustc's output, like annotate-snippets or miette. Any improvements or bugfixes contributed to those libraries are not propagated back to rustc. Because the emitter is part of the rustc codebase, the barrier to entry for new contributors is artificially kept high than it otherwise would be.
21+
22+
annotate-snippets is already part of the rustc codebase, but it is disabled by default, doesn't have extensive testing and there's no way of enabling this output through cargo, which limits how many users can actually make use of it.
23+
24+
### The next 6 months
25+
26+
- annotate-snippets rendered output reaches full parity (modulo reasonable non-significant divergences) with rustc's output
27+
- A call for testing is made to the community to gather feedback on annotate-snippets
28+
29+
### The "shiny future" we are working towards
30+
31+
The outputs of rustc and cargo are fully using annotate-snippets, with no regressions to the rendered output. annotate-snippets grows its feature set, like support for more advanced rendering formats or displaying diagnostics with more than ASCII-art, independently of the compiler development cycle.
32+
33+
## Design axioms
34+
35+
- **Match rustc's output**: The output of annotate-snippets should match rustc, modulo reasonable non-significant divergences
36+
- **Works for Cargo (and other tools)**: annotate-snippets is meant to be used by any project that would like "Rust-style" output, so it should be designed to work with any project, not just rustc.
37+
38+
39+
[da]: https://rust-lang.github.io/rust-project-goals/about/design_axioms.html
40+
41+
## Ownership and team asks
42+
43+
**Owner:** @estebank, @Muscraft
44+
45+
| Subgoal | Owner(s) or team(s) | Notes |
46+
| ----------------------------------------------- | ------------------------------ | ------------------------------ |
47+
| Reach output parity of rustc/annotate-snippets | | |
48+
| ↳ add suggestions | @Muscraft | |
49+
| ↳ Port a subset of rustc's UI tests | @Muscraft | |
50+
| ↳ address divergences | @Muscraft | |
51+
| Initial use of annotate-snippets | | |
52+
| ↳ update annotate-snippets to latest version | | |
53+
| ↳ teach cargo to pass annotate-snippets flag | @estebank | |
54+
| ↳ add ui test mode comparing new output | | |
55+
| ↳ switch default nightly rustc output | | |
56+
| Production use of annotate-snippets | | |
57+
| ↳ switch default rustc output | | |
58+
| ↳ release notes | | |
59+
| ↳ switch ui tests to only check new output | | |
60+
| ↳ dedicated reviewer | ![Team][] [compiler] | @estebank will be the reviewer |
61+
| Standard reviews | ![Team][] [compiler] | |
62+
| Top-level Rust blog post inviting feedback | | |
63+
64+
[cargo-lints]: https://github.com/rust-lang/cargo/issues/12235

0 commit comments

Comments
 (0)