]> git.lizzy.rs Git - rust.git/commit
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)
commit4946ee7c8fd9a6b5b7e506373950cac57a4e8015
tree7fed610bfab0aebbd6df7c16f391be76c9fbb502
parentb695ed3f2032d349a5cb9f26a8df67936943c075
parentf5e390e8631a759579674b0899087a51bb073dd3
Rollup merge of #103651 - Alexendoo:parse-format-unicode-escapes, r=wesleywiser

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