-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Move to using annotate-snippets-rs for producing snippets #59346
Comments
cc @rust-lang/wg-diagnostics |
We just had our first wg-diagnostics meeting and think that a good first step would be to create a new (unstable) diagnostics renderer (we have json, short and human right now). Basically it would use the existing diagnostics backend to call into annotate-snippets. We can then create a way to run And once we are all happy, we can get rid of the old @zbraniecki in order to be able to use this in rustc, we'd need to move your crate into the |
Yes! I'd love to hand it over to the Rust team and would be happy to see contributions or hand over to new maintainer if that's better for you! I will continue using it for fluent-rs, but I feel like the crate supports all my direct needs while it will need more features for Rust I believe (since Rust errors are more complex!) |
@zbraniecki if you give me admin access to the repo I can migrate it. |
Invited! |
I can push but I can't move. Hmm. Maybe transfer the repo to me and then I can transfer it to rust-lang? |
I tried to transfer to you |
If no one else has picked this up yet, I'd be interested in working on this. I'm currently working on adding the new diagnostics error-format. |
I'm happy to help you brainstorm, or review or whatever is needed. :) |
Extracted from work on rust-lang#59346. This moves the annotation collection to the `FileWithAnnotatedLines` impl to allow re-use in a separate EmitterWriter.
…gs1, r=estebank librustc_errors: Move annotation collection to own impl Extracted from work on rust-lang#59346. This moves the annotation collection to the `FileWithAnnotatedLines` impl to allow easier re-use in a separate EmitterWriter. Even without that new EmitterWriter present, I think it makes sense to have this as an associated function.
…gs1, r=estebank librustc_errors: Move annotation collection to own impl Extracted from work on rust-lang#59346. This moves the annotation collection to the `FileWithAnnotatedLines` impl to allow easier re-use in a separate EmitterWriter. Even without that new EmitterWriter present, I think it makes sense to have this as an associated function.
…gs1, r=estebank librustc_errors: Move annotation collection to own impl Extracted from work on rust-lang#59346. This moves the annotation collection to the `FileWithAnnotatedLines` impl to allow easier re-use in a separate EmitterWriter. Even without that new EmitterWriter present, I think it makes sense to have this as an associated function.
…gs1, r=estebank librustc_errors: Move annotation collection to own impl Extracted from work on rust-lang#59346. This moves the annotation collection to the `FileWithAnnotatedLines` impl to allow easier re-use in a separate EmitterWriter. Even without that new EmitterWriter present, I think it makes sense to have this as an associated function.
Add new diagnostic writer using annotate-snippet library This adds a new diagnostic writer `AnnotateRsEmitterWriter` that uses the [`annotate-snippet`][as] library to print out the human readable diagnostics. The goal of #59346 is to eventually switch over to using the library instead of maintaining our own diagnostics output. This PR does **not** add all the required features to the new diagnostics writer. It is only meant as a starting point so that other people can start contributing as well. There are some FIXMEs in `librustc_errors/annotate_rs_emitter.rs` that point at yet to be implemented features of the new diagnostic emitter, however those are most likely not exhaustive. [as]: https://github.com/rust-lang/annotate-snippets-rs
I figured I'd post a small status update as it has been a while since the last changes. We currently have the The main problem with turning rustc annotations into annotate-snippet There's currently two open WIP PRs for annotate-snippet that would make it Once annotation support has landed for the new emitter it would be a good time |
Update annotate-snippets-rs to 0.8.0 rust-lang#59346 I made major changes to this library. In the previous version we worked with owned while in the current one with borrowed. I have adapted it without changing the behavior. I have modified the coverage since the previous one did not return correctly the index of the character in the line.
If @rust-lang has ownership of |
Yes, those permissions should be in sync |
Is rustc now officially using https://github.com/rust-lang/annotate-snippets-rs? We're trying to find the best way to produce rustc-like errors for our own compiler, and we're wondering if https://github.com/rust-lang/annotate-snippets-rs would be the best choice. |
No, we aren't using it right now afaik. Edit: We are actually using it. Must have missed the switch. rust/compiler/rustc_errors/Cargo.toml Line 23 in ee1c3b3
|
It's on nightly behind |
Looks like it still has some bugs. For example compiling an empty bin crate should give
but it doesn't show anything with |
I've been doing a lot of cleanups in diagnostic handling lately and I just stumbled across this annotate-snippets-rs stuff. The entire project appears to be moribund; it looks like no work has been done in more than four years. This has me wondering if it should be abandoned and the relevant code removed from the compiler. If anyone says "is there any harm in keeping the code around" I will pre-emptively say that all code maintenance has a cost. Here is one recent example where this caused some friction. |
I think the goal was to move to this entirely, so that the Rust compiler's annotation machinery is shareable. In general annotate-snippets-rs is not moribund, it's mostly "done" but the Cargo people are looking at using it and have been contributing things they need recently. I think the only thing left here is the decision to switch over by default which should be made by @estebank / @davidtwco / @oli-obk or someone else who works on diagnostics. So I'd actually say we should tend towards removing the existing rustc diagnostic code and switching over to annotate-snippets, rather than removing the annotate-snippets code. |
As of about a month ago, @Muscraft has taken over maintenance of the annotate-snippets library, and Cargo is incorporating it. I can recognize that the current implementation of this option in the compiler is pretty buggy, but I imagine is also a good candidate to have new people try to fix some of the issues. I think it would be great if we could follow through with the plan @Manishearth mentioned. I don't know if @Muscraft is interested in that? |
It sounds like that's not the only thing, that there's also a non-trivial amount of work to ensure the annotate-snippets-rs diagnostics work as well as the existing diagnostics. In general, this pattern gets my spidey-senses tingling:
|
Yea, the way to remove cruft here is to remove the old diagnostics emitter and switch to annotate-snippets. |
Let's see if the Cargo team is willing to help with that, or if the diagnostics team is willing to take this on. Or we could even "shoot first ask questions later" by switching the default now and seeing what breaks (seems like this is what @oli-obk is suggesting). It doesn't seem like the work needed is in critical functionality. I would rather have rustc and Cargo be able to share code for this. There's another bad pattern at play here, rustc tends to often be reluctant to share code; citing maintenance reasons, and the other Rust tools have to reinvent or fork things. We went through this with compiletest. This code in rustc is not touched that often and I'd rather consolidate on something shareable. |
I'm in hard agreement on the idea "we should only have one way to produce human-readable diagnostics". The lack of progress for four years made it seem like annotate-snippets was not a serious contender to be that one way. If I'm wrong about that and someone can pick it up and make the switch in a relatively short period of time, great. I just don't want to be back here restarting this discussion in 18 months. |
This is my goal with my work on
As @ehuss said, I picked up work on All of that being said it seems like there is interest in having |
How's this for a plan:
I think if there is activity then we should not be worried about deadlines, as long as stuff is actually happening. |
@Muscraft I'm interested in contributing to
I'm specifically interested in bringing |
I don't know anything about the internals of
|
@zbraniecki created https://github.com/zbraniecki/annotate-snippets-rs which basically does Rust-style formatting of code snippets for errors, to be used within Fluent.
I think we should try and move our snippet code out of tree, preferably merging it with annotate-snippets-rs (which is already close to what rustc does), so that it's reusable.
@zbraniecki has agreed to make whatever changes necessary to the crate to make it usable within rustc.
cc @estebank
The text was updated successfully, but these errors were encountered: