diff --git a/clippy_lints/src/transmute.rs b/clippy_lints/src/transmute.rs index cc8c6d28445..eec633953c7 100644 --- a/clippy_lints/src/transmute.rs +++ b/clippy_lints/src/transmute.rs @@ -96,11 +96,20 @@ declare_lint! { "transmutes from an integer to a `char`" } -/// **What it does:** Checks for transmutes from a `&[u8] to a `&str`. +/// **What it does:** Checks for transmutes from a `&[u8]` to a `&str`. /// /// **Why is this bad?** Not every byte slice is a valid UTF-8 string. /// -/// **Known problems:** None. +/// **Known problems:** +/// - [`from_utf8`] which this lint suggests using is slower than `transmute` +/// as it needs to validate the input. +/// If you are certain that the input is always a valid UTF-8, +/// use [`from_utf8_unchecked`] which is as fast as `transmute` +/// but has a semantically meaningful name. +/// - You might want to handle errors returned from [`from_utf8`] instead of calling `unwrap`. +/// +/// [`from_utf8`]: https://doc.rust-lang.org/std/str/fn.from_utf8.html +/// [`from_utf8_unchecked`]: https://doc.rust-lang.org/std/str/fn.from_utf8_unchecked.html /// /// **Example:** /// ```rust