]> git.lizzy.rs Git - rust.git/commit - compiler/rustc_borrowck/src/session_diagnostics.rs
Rollup merge of #104193 - TaKO8Ki:fix-104142, r=cjgillot
authorMatthias Krüger <matthias.krueger@famsik.de>
Wed, 16 Nov 2022 07:36:11 +0000 (08:36 +0100)
committerGitHub <noreply@github.com>
Wed, 16 Nov 2022 07:36:11 +0000 (08:36 +0100)
commit88a19197b9f57b84a091c34d59c3d9ae72f03511
tree3ce9f8c94c0ad22433de9f93c38a3bc0e5e5de60
parent91963cc244f4986818dadbb2c73dd6f67e779802
parent9857de218f10cfbe750d4c8165d960ae0da63cf4
Rollup merge of #104193 - TaKO8Ki:fix-104142, r=cjgillot

Shift no characters when using raw string literals

Fixes #104142

Given the following code:

```rust
fn main() {
    println!(r#"\'\'\'\'\'\'\'\'\'\'\'\'\'\'}"#);
}
```

The current output is:

```
error: invalid format string: unmatched `}` found
 --> src/main.rs:2:59
  |
2 |     println!(r#"\'\'\'\'\'\'\'\'\'\'\'\'\'\'}"#); //~ ERROR invalid format string: unmatched `}` found
  |                                                           ^ unmatched `}` in format string
  |
  = note: if you intended to print `}`, you can escape it using `}}`

error: could not compile `debug_playground` due to previous error
```

The output should look like:

```
error: invalid format string: unmatched `}` found
 --> src/main.rs:2:45
  |
2 |     println!(r#"\'\'\'\'\'\'\'\'\'\'\'\'\'\'}"#); //~ ERROR invalid format string: unmatched `}` found
  |                                             ^ unmatched `}` in format string
  |
  = note: if you intended to print `}`, you can escape it using `}}`

error: could not compile `debug_playground` due to previous error
```

This pull request fixes the wrong span for `invalid format string` error and also solves the ICE.