rust-playground icon indicating copy to clipboard operation
rust-playground copied to clipboard

preserve colors in diagnostics

Open jyn514 opened this issue 1 year ago • 5 comments

rustc uses a lot of colors and highlighting in its errors. sometimes the output is hard to read when those are removed. consider for example this diagnostic, where it's hard to parse that the - is meant to be a highlight: Image

it would be nice if playground preserved the colors.

repro here

jyn514 avatar Nov 08 '24 17:11 jyn514

It might be enough to use anstyle-svg for this, but that would require additional work for the existing links. A likely better option would be to have the json output emit the colored ANSI output and use some other crate to turn the codes into HTML that we can style.

estebank avatar Nov 08 '24 18:11 estebank

rustc uses a lot of colors and highlighting in its errors. sometimes the output is hard to read when those are removed

Should that be a general concern for people who don’t have colors for whatever given reason?

shepmaster avatar Nov 08 '24 18:11 shepmaster

@shepmaster I make an effort to make sure that all output is readable as text only, but undoubtedly color makes the output easier to scan and reduces the likelihood of misreading things. In the screenshot, someone very knowledgeable mistook the - as a connector between the ^^ and help.... With colors, the help appears blue, like the -, making it easier to differentiate from the ^^. That being said, this suggestion in particular is also being changed to be verbose style so that we no longer have this confusion. I want us to move away from inline suggestions entirely (but that requires me building a PR while --blessing stderr files for every platform, which is a bit of a pain), but that will still leave some corner cases where non-suggestion short labels can be misread slightly.

estebank avatar Nov 08 '24 19:11 estebank

Should that be a general concern for people who don’t have colors for whatever given reason?

note that this particular case is being fixed upstream in rustc: https://github.com/rust-lang/rust/pull/132780

but it would be nice to fix it in the general case as well; it's never going to be possible to communicate as much information as visibly with text alone.

jyn514 avatar Nov 08 '24 21:11 jyn514

I tried some time back making all suggestions have the verbose diff output in https://github.com/rust-lang/rust/pull/127282. Landing that change or one like it will be a huge pain in the neck.

estebank avatar Feb 20 '25 20:02 estebank