pub static INVALID_FROM_UTF8_UNCHECKED: &Lint
Expand description

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

ⓘ
unsafe {
    std::str::from_utf8_unchecked(b"Ru\x82st");
}

{{produces}}

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.