]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #103651 - Alexendoo:parse-format-unicode-escapes, r=wesleywiser
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>
Tue, 8 Nov 2022 05:53:51 +0000 (11:23 +0530)
committerGitHub <noreply@github.com>
Tue, 8 Nov 2022 05:53:51 +0000 (11:23 +0530)
Fix `rustc_parse_format` spans following escaped utf-8 multibyte chars

Currently too many skips are created for char escapes that are larger than 1 byte when encoded in UTF-8, [playground:](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=c77a9dc669b69b167271b59ed2c8d88c)

```rust
fn main() {
    format!("\u{df}{a}");
    format!("\u{211d}{a}");
    format!("\u{1f4a3}{a}");
}
```
```
error[[E0425]](https://doc.rust-lang.org/stable/error-index.html#E0425): cannot find value `a` in this scope
 --> src/main.rs:2:22
  |
2 |     format!("\u{df}{a}");
  |                      ^ not found in this scope

error[[E0425]](https://doc.rust-lang.org/stable/error-index.html#E0425): cannot find value `a` in this scope
 --> src/main.rs:3:25
  |
3 |     format!("\u{211d}{a}");
  |                         ^ not found in this scope

error[[E0425]](https://doc.rust-lang.org/stable/error-index.html#E0425): cannot find value `a` in this scope
 --> src/main.rs:4:27
  |
4 |     format!("\u{1f4a3}{a}");
  |                           ^ not found in this scope
```

This reduces the number of skips to account for that

Fixes https://github.com/rust-lang/rust-clippy/issues/9727


Trivial merge