diff options
| author | bors <bors@rust-lang.org> | 2024-02-04 17:07:18 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-04 17:07:18 +0000 |
| commit | 34e4c9fa4a8bb00ada7671cc922d09d4ed6e4834 (patch) | |
| tree | de478db545d4338960872e081ecbae6f89ddca90 /clippy_lints/src/declared_lints.rs | |
| parent | 9fb41079ca03a68e1ffc63d82643eb0afe68d3a1 (diff) | |
| parent | a3baebcb3147773c9673e4ea166e3419201e8b9f (diff) | |
| download | rust-34e4c9fa4a8bb00ada7671cc922d09d4ed6e4834.tar.gz rust-34e4c9fa4a8bb00ada7671cc922d09d4ed6e4834.zip | |
Auto merge of #12087 - marcin-serwin:ref_as_ptr_cast, r=blyxyas
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)
Diffstat (limited to 'clippy_lints/src/declared_lints.rs')
| -rw-r--r-- | clippy_lints/src/declared_lints.rs | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/clippy_lints/src/declared_lints.rs b/clippy_lints/src/declared_lints.rs index b96a7af9070..4182524581b 100644 --- a/clippy_lints/src/declared_lints.rs +++ b/clippy_lints/src/declared_lints.rs @@ -97,6 +97,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::casts::FN_TO_NUMERIC_CAST_WITH_TRUNCATION_INFO, crate::casts::PTR_AS_PTR_INFO, crate::casts::PTR_CAST_CONSTNESS_INFO, + crate::casts::REF_AS_PTR_INFO, crate::casts::UNNECESSARY_CAST_INFO, crate::casts::ZERO_PTR_INFO, crate::checked_conversions::CHECKED_CONVERSIONS_INFO, |
