rust/tests
Nilstrieb 7a4006cc52
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
2023-05-30 12:57:38 +02:00
..
assembly
auxiliary
codegen Add SafeStack support to rustc 2023-05-26 15:18:54 -04:00
codegen-units
debuginfo
incremental Add a test for issue 110457 2023-05-29 13:49:20 +00:00
mir-opt Make TrustedStep require Copy 2023-05-29 13:19:47 -07:00
pretty
run-make Auto merge of #86844 - bjorn3:global_alloc_improvements, r=pnkfelix 2023-05-25 16:59:57 +00:00
run-make-fulldeps
run-pass-valgrind
rustdoc Rollup merge of #111997 - GuillaumeGomez:re-export-doc-hidden-macros, r=notriddle 2023-05-27 13:38:33 +02:00
rustdoc-gui Rollup merge of #112042 - GuillaumeGomez:migrate-gui-test-color-8, r=notriddle 2023-05-29 04:03:03 +02:00
rustdoc-js
rustdoc-js-std
rustdoc-json
rustdoc-ui rustdoc: get unnormalized link destination for suggestions 2023-05-26 18:38:46 -07:00
ui Rollup merge of #111543 - Urgau:uplift_invalid_utf8_in_unchecked, r=WaffleLapkin 2023-05-30 12:57:38 +02:00
ui-fulldeps Use Cow in {D,Subd}iagnosticMessage. 2023-05-29 09:23:43 +10:00
COMPILER_TESTS.md