diff --git a/clippy_lints/src/casts/mod.rs b/clippy_lints/src/casts/mod.rs index 9a48e8d064a..b8f0dedf5ed 100644 --- a/clippy_lints/src/casts/mod.rs +++ b/clippy_lints/src/casts/mod.rs @@ -608,13 +608,13 @@ declare_clippy_lint! { /// ### Example /// ```rust /// let string = String::with_capacity(1); - /// let ptr = string.as_ptr() as *mut _; + /// let ptr = string.as_ptr() as *mut u8; /// unsafe { ptr.write(4) }; // UNDEFINED BEHAVIOUR /// ``` /// Use instead: /// ```rust /// let mut string = String::with_capacity(1); - /// let string = string.as_mut_ptr(); + /// let ptr = string.as_mut_ptr(); /// unsafe { ptr.write(4) }; /// ``` #[clippy::version = "1.66.0"] diff --git a/src/docs/as_ptr_cast_mut.txt b/src/docs/as_ptr_cast_mut.txt index 83332a2559d..228dde996bb 100644 --- a/src/docs/as_ptr_cast_mut.txt +++ b/src/docs/as_ptr_cast_mut.txt @@ -8,12 +8,12 @@ mutability is used, making it unlikely that having it as a mutable pointer is co ### Example ``` let string = String::with_capacity(1); -let ptr = string.as_ptr() as *mut _; +let ptr = string.as_ptr() as *mut u8; unsafe { ptr.write(4) }; // UNDEFINED BEHAVIOUR ``` Use instead: ``` let mut string = String::with_capacity(1); -let string = string.as_mut_ptr(); +let ptr = string.as_mut_ptr(); unsafe { ptr.write(4) }; ``` \ No newline at end of file