diff options
| author | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2023-05-30 12:57:38 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-30 12:57:38 +0200 |
| commit | faf2e5db0c4beb6419e6b473bfbd4b26710363cc (patch) | |
| tree | 64287c051c7b9edb0c4b449ba32f7837302f7ce2 /tests/rustdoc-js-std/parser-errors.js | |
| parent | 53f1e6b7ef705467faeff60f85db613e82c9b224 (diff) | |
| parent | 5a2094319b56b7caeb39ce08626ab9e4b79681dc (diff) | |
| download | rust-faf2e5db0c4beb6419e6b473bfbd4b26710363cc.tar.gz rust-faf2e5db0c4beb6419e6b473bfbd4b26710363cc.zip | |
Rollup merge of #111543 - Urgau:uplift_invalid_utf8_in_unchecked, r=WaffleLapkin
Uplift `clippy::invalid_utf8_in_unchecked` lint
This PR aims at uplifting the `clippy::invalid_utf8_in_unchecked` lint into two lints.
## `invalid_from_utf8_unchecked`
(deny-by-default)
The `invalid_from_utf8_unchecked` lint checks for calls to `std::str::from_utf8_unchecked` and `std::str::from_utf8_unchecked_mut` with an invalid UTF-8 literal.
### Example
```rust
unsafe {
std::str::from_utf8_unchecked(b"cl\x82ippy");
}
```
### Explanation
Creating such a `str` would result in undefined behavior as per documentation for `std::str::from_utf8_unchecked` and `std::str::from_utf8_unchecked_mut`.
## `invalid_from_utf8`
(warn-by-default)
The `invalid_from_utf8` lint checks for calls to `std::str::from_utf8` and `std::str::from_utf8_mut` with an invalid UTF-8 literal.
### Example
```rust
std::str::from_utf8(b"ru\x82st");
```
### Explanation
Trying to create such a `str` would always return an error as per documentation for `std::str::from_utf8` and `std::str::from_utf8_mut`.
-----
Mostly followed the instructions for uplifting a clippy lint described here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751
````@rustbot```` label: +I-lang-nominated
r? compiler
-----
For Clippy:
changelog: Moves: Uplifted `clippy::invalid_utf8_in_unchecked` into rustc
Diffstat (limited to 'tests/rustdoc-js-std/parser-errors.js')
0 files changed, 0 insertions, 0 deletions
