Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use annotate-snippets for rustc diagnostic output #123

Open
13 tasks
nikomatsakis opened this issue Jul 22, 2024 · 5 comments
Open
13 tasks

Use annotate-snippets for rustc diagnostic output #123

nikomatsakis opened this issue Jul 22, 2024 · 5 comments

Comments

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Jul 22, 2024

Metadata
Point of contact @Muscraft
Team(s) compiler
Goal document 2025h1/annotate-snippets

Summary

Switch to annotate-snippets for rendering rustc's output, with no loss of functionality or visual regressions.

Tasks and status

Reach output parity of rustc/annotate-snippets

Initial use of annotate-snippets

  • update annotate-snippets to latest version
  • teach cargo to pass annotate-snippets flag (@estebank)
  • add ui test mode comparing new output
  • switch default nightly rustc output

Production use of annotate-snippets

  • switch default rustc output
  • release notes
  • switch ui tests to only check new output
  • Dedicated reviewer (compiler Team)

Standard reviews

Top-level Rust blog post inviting feedback

  • Top-level Rust blog post inviting feedback
@nikomatsakis nikomatsakis added this to the 2024h2 milestone Jul 22, 2024
@rust-lang rust-lang locked and limited conversation to collaborators Jul 25, 2024
@nikomatsakis
Copy link
Contributor Author

This issue is intended for status updates only.

For general questions or comments, please contact the owner(s) directly.

@Muscraft
Copy link
Member

Muscraft commented Oct 8, 2024

The last few weeks I have been trying to get suggestions working within annotate-snippets, and have been able to match rustc suggestion output in most cases. Most of my time was spent trying to understand the different rendering styles for suggestions, and how they should be adapted to fit within annotate-snippets.

Image
Image

@Muscraft
Copy link
Member

Muscraft commented Dec 9, 2024

I have been a bit busy over the past two months, so I haven't had as much time to work on annotate-snippets as I had hoped. That said, progress was still being made!

I continued working on suggestions, but as I got deeper into the implementation, I realized getting the corner cases correct would be very difficult with the annotate-snippets architecture. I started work on a more direct translation from rustc, and quickly ended up with something that closely matched it at the cost of significant differences from how annotations are rendered. These differences, and some problems I noticed with the API for suggestions, led to a discussion with @epage about how to resolve these problems. During the discussion, I realized it would be beneficial if the internals of annotate-snippets resembled rustc as it would make it easier for contributors to rustc to contribute to annotate-snippets. @epage was helpful enough to design a new API, which resolved my suggestion API concerns and should make it easier for annotate-snippets's internals to resemble rustc. Initial work on the new design has yielded positive results, so I am hopeful this was a good decision. During all of this, I started to work on a tool that should help convert some of rustc's UI tests to be used in annotate-snippet's testsuite.

@nikomatsakis nikomatsakis modified the milestones: 2024h2, 2025h1 Feb 18, 2025
@nikomatsakis
Copy link
Contributor Author

This is a continuing project goal, and the updates below this comment will be for the new period 2025h1

@Muscraft
Copy link
Member

While my time was limited these past few months, lots of progress was made! I was able to align annotate-snippets internals with rustc's HumanEmitter and get the new API implemented. These changes have not been merged yet, but they can be found here. As part of this work, I got rustc using annotate-snippets as its only renderer. During all of this, I started working on making rustc use annotate-snippets as its only renderer, which turned out to be a huge benefit. I was able to get a feel for the new API while addressing rendering divergences. As of the time of writing, all but ~30 tests of the roughly 18,000 UI tests are passing.

test result: FAILED. 18432 passed; 29 failed; 193 ignored; 0 measured; 0 filtered out; finished in 102.32s

Most of the failing tests are caused by a few things:

  • annotate-snippets right aligns numbers, whereas rustc left aligns
  • annotate-snippets doesn't handle multiple suggestions for the same span very well
  • Problems with handling FailureNote
  • annotate-snippets doesn't currently support colored labels and titles, i.e., the magenta highlight rustc uses
  • rustc wants to pass titles similar to error: internal compiler error[E0080], but annotate-snippets doesn't support that well
  • differences in how rustc and annotate-snippets handle term width during tests
    • When testing, rustc uses DEFAULT_COLUMN_WIDTH and does not subtract the code offset, while annotate-snippets does
  • Slight differences in how "newline"/end of line highlighting is handled
  • JSON output rendering contains color escapes

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants