Rust: Use Unicode line drawing characters for spans

Created on 13 Apr 2015  Â·  23Comments  Â·  Source: rust-lang/rust

example

See discussion on old PR #21406. @Manishearth expressed interest in reviving this.

A-frontend

Most helpful comment

Always prefer ASCII characters.

All 23 comments

+1 sounds nice.

Would this work on any windows terminals, such as the shell that comes with mingw?

Oh just read through the thread again, WGL4. cool!

Always prefer ASCII characters.

The plan, from before was to have both a flag --output-plain-ascii, as well as environment variables which can be set to always, auto or never, for each of color, having underlines at all, and having unicode underlines.

Alternatively, we could use U+203E OVERLINE (‾, also part of WGL4) to create a simpler underline effect:

U+202E OVERLINE in a warning

This is different from using an ANSI escape code such as \x1b[4m because it allows the underline colour to be different from the text’s colour.

I'm a noob, can I give it a try? I could try writing a unicode version, then implement the --output-plain-ascii flag.

@shinglyu sure! You can borrow a lot of stuff from Keegan's impl here, feel free to ask me if you have more questions!

@Manishearth : nice to see you again :)

@Manishearth : I tried to read the patch https://github.com/rust-lang/rust/pull/21406, but I had a hard time understanding the codebase. Is there any document/blog post/diagram/etc that explains the folder structure and runtime behavior? Most of the docs I found are explaining the Rust language syntax.

Or should I start by reading the llvm tutorial?

src/librustc/session/config.rs contains the stuff for sorting out command line arguments

src/libsyntax/diagnostic.rs has the stuff for printing out a span.

You don't need to understand the rest at this stage, really :)

@Manishearth : thanks! I'll take a look.

@Manishearth @kmcallister : Changing ascii to UTF-8 is pretty straight forward. But I want to clarify the spec.

From what I understand in the closed PR,

  • We have 3 environment variables for output capability

    • RUSTC_OUTPUT_COLOR = always | auto | never

    • RUSTC_OUTPUT_CURSOR_POS = always | auto | never

    • RUSTC_OUTPUT_UTF8 = always | auto | never

    • If any of the three is un-set or is invalid value, use auto

  • There are 2 way to set the above three as never:

    • --output-plain-ascii flag

    • RUSTC_OUTPUT_PLAIN_ASCII =

I have some questions:

  • If cursor positioning is not enabled, what do we do?
  • What are all those flag stability and warning thing?

Thanks!

Most programs will check against LC_CTYPE (i.e. the locale's encoding setting) to see what they can emit. If it's not a UTF-8 locale, just emit ascii.

Is this going anywhere?

I like the idea, but Rust still doesn't do this.

@shinglyu how is this going?

Sorry I claimed it but didn't finish it on time. Give me one week to work on this. If I can't make it, anyone if free to take it.

OK, @shinglyu , if you see you won't make it, can you please post your progress so someone can pick it up where you left off instead of starting from scratch? Thanks!

Uh @shinglyu @pmatos do note there is https://github.com/rust-lang/rust/pull/28902

Oh ok, so look like the old PR is being revived. Let's go with #28902 then.

With the recent churn in error reporting, this will probably need to start from scratch. Still a cool idea.

cc @jonathandturner maybe you have ideas about how to beautify new error reporting with unicode.

We've got an RFC going here: https://github.com/rust-lang/rfcs/pull/1644

We opted not to use Unicode because we did a look at what was generally available across platforms and Windows doesn't use Unicode by default in the terminal. I know that they're working on a better terminal experience, so things might change there.

The error format RFC ended up explicitly deciding against this: https://github.com/rust-lang/rfcs/blob/master/text/1644-default-and-expanded-rustc-errors.md#format-of-error-messages So I'm going to give it a close.

Was this page helpful?
0 / 5 - 0 ratings