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

Move to using annotate-snippets-rs for producing snippets #59346

Open
Manishearth opened this issue Mar 21, 2019 · 10 comments

Comments

@Manishearth
Copy link
Member

commented Mar 21, 2019

@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

@oli-obk

This comment has been minimized.

Copy link
Contributor

commented Mar 22, 2019

@oli-obk

This comment has been minimized.

Copy link
Contributor

commented May 24, 2019

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 ui tests with the new backend and see how the output changes and circle back to changing annotate-snippets until we are happy.

And once we are all happy, we can get rid of the old human emitter and replace it with the new annotate-snippets based one.

@zbraniecki in order to be able to use this in rustc, we'd need to move your crate into the rust-lang organization and give publish rights to some compiler devs so that we have quick access to it if anything needs doing. Are you ok with that?

@zbraniecki

This comment has been minimized.

Copy link

commented May 24, 2019

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!)

@Manishearth

This comment has been minimized.

Copy link
Member Author

commented May 24, 2019

@zbraniecki if you give me admin access to the repo I can migrate it.

@zbraniecki

This comment has been minimized.

Copy link

commented May 25, 2019

Invited!

@Manishearth

This comment has been minimized.

Copy link
Member Author

commented May 25, 2019

I can push but I can't move. Hmm.

Maybe transfer the repo to me and then I can transfer it to rust-lang?

@zbraniecki

This comment has been minimized.

Copy link

commented May 25, 2019

I tried to transfer to you

@Manishearth

This comment has been minimized.

Copy link
Member Author

commented May 25, 2019

@phansch

This comment has been minimized.

Copy link
Contributor

commented May 25, 2019

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.

@zbraniecki

This comment has been minimized.

Copy link

commented May 25, 2019

I'm happy to help you brainstorm, or review or whatever is needed. :)

phansch added a commit to phansch/rust that referenced this issue May 25, 2019

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 re-use in a separate
EmitterWriter.

phansch added a commit to phansch/rust that referenced this issue May 28, 2019

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 re-use in a separate
EmitterWriter.

Centril added a commit to Centril/rust that referenced this issue May 29, 2019

Rollup merge of rust-lang#61191 - phansch:annotate_snippet_refactorin…
…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.

Centril added a commit to Centril/rust that referenced this issue May 29, 2019

Rollup merge of rust-lang#61191 - phansch:annotate_snippet_refactorin…
…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.

Centril added a commit to Centril/rust that referenced this issue May 29, 2019

Rollup merge of rust-lang#61191 - phansch:annotate_snippet_refactorin…
…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.

Centril added a commit to Centril/rust that referenced this issue May 29, 2019

Rollup merge of rust-lang#61191 - phansch:annotate_snippet_refactorin…
…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.

bors added a commit that referenced this issue Jun 4, 2019

Auto merge of #61407 - phansch:annotate_snippet_refactoring1, r=oli-obk
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.