Weird ASCII art in error message

When compiling the following snippet

fn main() {
    println!("hello world\
    hello world",x);
    
}

I get the following error message:

   Compiling playground v0.0.1 (/playground)
error: argument never used
 --> src/main.rs:5:18
  |
4 |       println!("hello world\
  |  ______________-
5 | |     hello world",x);
  | |                - ^ argument never used
  | |________________|
  |                  formatting specifier missing

I am a bit surprised by the ascii art that is supposed to underline the string literal. Is this expected? What is the rationale behind this design? It must show the first position of the span and the last one?

It also must connect to the message about the specific error, and support multiple annotations, which you can't do in general with just a standard squiggle.

It does look a bit silly in this case though!

Here's the PR and some conversation beforehand.

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.