34e4c9fa4a
Add new lint: `ref_as_ptr` Fixes #10130 Added new lint `ref_as_ptr` that checks for conversions from references to pointers and suggests using `std::ptr::from_{ref, mut}` instead. The name is different than suggested in the issue (`as_ptr_cast`) since there were some other lints with similar names (`ptr_as_ptr`, `borrow_as_ptr`) and I wanted to follow the convention. Note that this lint conflicts with the `borrow_as_ptr` lint in the sense that it recommends changing `&foo as *const _` to `std::ptr::from_ref(&foo)` instead of `std::ptr::addr_of!(foo)`. Personally, I think the former is more readable and, in contrast to `addr_of` macro, can be also applied to temporaries (cf. #9884). --- changelog: New lint: [`ref_as_ptr`] [#12087](https://github.com/rust-lang/rust-clippy/pull/12087) |
||
---|---|---|
.. | ||
as_ptr_cast_mut.rs | ||
as_underscore.rs | ||
borrow_as_ptr.rs | ||
cast_abs_to_unsigned.rs | ||
cast_enum_constructor.rs | ||
cast_lossless.rs | ||
cast_nan_to_int.rs | ||
cast_possible_truncation.rs | ||
cast_possible_wrap.rs | ||
cast_precision_loss.rs | ||
cast_ptr_alignment.rs | ||
cast_sign_loss.rs | ||
cast_slice_different_sizes.rs | ||
cast_slice_from_raw_parts.rs | ||
char_lit_as_u8.rs | ||
fn_to_numeric_cast_any.rs | ||
fn_to_numeric_cast_with_truncation.rs | ||
fn_to_numeric_cast.rs | ||
mod.rs | ||
ptr_as_ptr.rs | ||
ptr_cast_constness.rs | ||
ref_as_ptr.rs | ||
unnecessary_cast.rs | ||
utils.rs | ||
zero_ptr.rs |