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

Diagnostics Revamp Roadmap #51528

Closed
4 tasks
oli-obk opened this issue Jun 13, 2018 · 12 comments
Closed
4 tasks

Diagnostics Revamp Roadmap #51528

oli-obk opened this issue Jun 13, 2018 · 12 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC S-tracking-impl-incomplete Status: The implementation is incomplete. S-tracking-needs-summary Status: It's hard to tell what's been done and what hasn't! Someone should do some investigation. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Jun 13, 2018

The current diagnostics APIs are very unergonomic and can result in various verbose, repetitive and annoying code snippets.

cc @estebank

  • Ensure that diagnostics have been emitted at compile-time (must-use and consuming emit method
  • Improve/expand --teach API
    • Applicable to user code -> show hints for user code
    • else -> show hints for error code example
  • Diagnostics builder API
  • Emitter API
    • allow builder API to set span labels in subdiagnostics
    • multiple spans in a subdiagnostic
    • suggestions and notes in arbitrary order
    • terminal width support
    • (windows only) background color check
@oli-obk oli-obk added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 13, 2018
@kennytm kennytm added the C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC label Jun 13, 2018
@GuillaumeGomez
Copy link
Member

Just when I added support for the current API in rustdoc... 😢

@estebank

This comment has been minimized.

@csmoe
Copy link
Member

csmoe commented Jun 16, 2018

I think the way to introduce next generation systems like chalk for trait-sys and polonius for borrowck is a great model of upgrading: create a independent crate then port into rustc, this will be easier for the future diag-api ‘s self-updating and more friendly to downstream tools like rustdoc,rustfix.

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 17, 2018

That... is an absolutely awesome idea.

We can totally recreate the diagnostics API in an external crate. Even better: we can also do that for the diagnostics emitter!

@euclio
Copy link
Contributor

euclio commented Jul 9, 2018

Factoring out the diagnostics emitter has a real use-case in cargo. There have been a few attempts at making a nicer build progress bar (rust-lang/cargo#3451, rust-lang/cargo#5620), but issues like rust-lang/cargo#5695 prevent the feature from being a nice user experience: the progress bar output gets interleaved with rustc output. This could be fixed if cargo were able to capture output from rustc and print it itself, but as it stands, cargo cannot capture output from rustc without losing formatting.

However, if the diagnostics emitter were factored out into a third-party crate, it might be possible for cargo to recreate the errors and output them with full formatting.

cc @alexcrichton

@estebank
Copy link
Contributor

@euclio that would require rustc to produce enough metadata to recreate the exact output (which I believe it is not possible at the moment, the json output is slightly lossy). That doesn't mean it's not a worthwhile objective to aim for.

@nikomatsakis
Copy link
Contributor

Over on Zulip we were recently discussing the idea of having a fallback "footnote" mode to use for overlapping, adjacent, or malordered labels. I wrote up the idea in this gist:

https://gist.github.com/nikomatsakis/80866d4407f1cc38fba0c2da7175dcf7

Example might be like:

15 |     };
   |     - (1)
   |      - (2)
   |
   | 1: `heap_ref` dropped here while still borrowed
   | 2: borrowed value needs to live until here

instead of

15 |     };
   |     -- borrowed value needs to live until here
   |     |
   |     `heap_ref` dropped here while still borrowed

(The proposal also includes a way to indicate labels that have an "ordering" to them that you would like the renderer to enforce.)

@Centril
Copy link
Contributor

Centril commented May 25, 2019

Does the WG have any plans for internationalization support?

@estebank
Copy link
Contributor

estebank commented May 25, 2019

We haven't discussed it but I feel that at this point we won't be able to maintain the level of quality we want while also scaffolding i10n support. I would love to hear others opinions.

Cc @rust-lang/wg-diagnostics

@Centril
Copy link
Contributor

Centril commented May 25, 2019

I think extracting diagnostics logic to structs and such is a great move for internationalization. Beyond that, the only think I would suggest is that you consider what i10n support in the future might take and try to avoid doing things that would make i10n harder in the future. Perhaps consider future-proofing traits and such today if possible.

@Manishearth
Copy link
Member

We discussed i18n in the wg-diagnostics Zulip channel.

It becomes quite easy to migrate if we use a custom derive (or other plugin) to autogenerate AsError impls for diagnostics structs. We should start looking into getting that derive working and convert diagnostics to it.

Once a significant portion of the codebase is using AsError, we can start playing with Fluent.

@crlf0710 crlf0710 added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 11, 2020
@jackh726 jackh726 added S-tracking-impl-incomplete Status: The implementation is incomplete. S-tracking-needs-summary Status: It's hard to tell what's been done and what hasn't! Someone should do some investigation. labels Jun 3, 2022
@wesleywiser
Copy link
Member

Visited during the compiler team tracking issue triage meeting. We believe most of this work has been completed already and there are various other WG-diagnostics issues that more accurately capture the current roadmap. I'm therefore closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC S-tracking-impl-incomplete Status: The implementation is incomplete. S-tracking-needs-summary Status: It's hard to tell what's been done and what hasn't! Someone should do some investigation. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests