Skip to content

Rollup of 4 pull requests #140735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 7, 2025
Merged
14 changes: 7 additions & 7 deletions compiler/rustc_lint/src/autorefs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ declare_lint! {
///
/// ```rust
/// unsafe fn fun(ptr: *mut [u8]) -> *mut [u8] {
/// &raw mut (*ptr)[..16]
/// // ^^^^^^ this calls `IndexMut::index_mut(&mut ..., ..16)`,
/// // implicitly creating a reference
/// unsafe { &raw mut (*ptr)[..16] }
/// // ^^^^^^ this calls `IndexMut::index_mut(&mut ..., ..16)`,
/// // implicitly creating a reference
/// }
/// ```
///
Expand All @@ -34,17 +34,17 @@ declare_lint! {
///
/// ```rust
/// unsafe fn fun(ptr: *mut [u8]) -> *mut [u8] {
/// &raw mut (&mut *ptr)[..16]
/// unsafe { &raw mut (&mut *ptr)[..16] }
/// }
/// ```
///
/// Otherwise try to find an alternative way to achive your goals using only raw pointers:
///
/// ```rust
/// use std::slice;
/// use std::ptr;
///
/// unsafe fn fun(ptr: *mut [u8]) -> *mut [u8] {
/// slice::from_raw_parts_mut(ptr.cast(), 16)
/// fn fun(ptr: *mut [u8]) -> *mut [u8] {
/// ptr::slice_from_raw_parts_mut(ptr.cast(), 16)
/// }
/// ```
pub DANGEROUS_IMPLICIT_AUTOREFS,
Expand Down