Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 5565c1a

Browse files
committed
run cargo dev new_lint then move transmutes_expressible_as_ptr_casts into transmute module
1 parent ef29161 commit 5565c1a

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

src/tools/clippy/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,7 @@ Released 2018-09-13
17301730
[`transmute_int_to_float`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_int_to_float
17311731
[`transmute_ptr_to_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_ptr_to_ptr
17321732
[`transmute_ptr_to_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_ptr_to_ref
1733+
[`transmutes_expressible_as_ptr_casts`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmutes_expressible_as_ptr_casts
17331734
[`transmuting_null`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmuting_null
17341735
[`trivial_regex`]: https://rust-lang.github.io/rust-clippy/master/index.html#trivial_regex
17351736
[`trivially_copy_pass_by_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref

src/tools/clippy/clippy_lints/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
798798
&transmute::UNSOUND_COLLECTION_TRANSMUTE,
799799
&transmute::USELESS_TRANSMUTE,
800800
&transmute::WRONG_TRANSMUTE,
801+
&transmute::TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS,
801802
&transmuting_null::TRANSMUTING_NULL,
802803
&trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF,
803804
&try_err::TRY_ERR,
@@ -1426,6 +1427,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
14261427
LintId::of(&transmute::TRANSMUTE_PTR_TO_REF),
14271428
LintId::of(&transmute::UNSOUND_COLLECTION_TRANSMUTE),
14281429
LintId::of(&transmute::WRONG_TRANSMUTE),
1430+
LintId::of(&transmute::TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS),
14291431
LintId::of(&transmuting_null::TRANSMUTING_NULL),
14301432
LintId::of(&try_err::TRY_ERR),
14311433
LintId::of(&types::ABSURD_EXTREME_COMPARISONS),
@@ -1624,6 +1626,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
16241626
LintId::of(&transmute::TRANSMUTE_INT_TO_FLOAT),
16251627
LintId::of(&transmute::TRANSMUTE_PTR_TO_PTR),
16261628
LintId::of(&transmute::TRANSMUTE_PTR_TO_REF),
1629+
LintId::of(&transmute::TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS),
16271630
LintId::of(&types::BORROWED_BOX),
16281631
LintId::of(&types::CHAR_LIT_AS_U8),
16291632
LintId::of(&types::TYPE_COMPLEXITY),

src/tools/clippy/clippy_lints/src/transmute.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,28 @@ declare_clippy_lint! {
269269
correctness,
270270
"transmute between collections of layout-incompatible types"
271271
}
272+
273+
declare_clippy_lint! {
274+
/// **What it does:**
275+
///
276+
/// **Why is this bad?**
277+
///
278+
/// **Known problems:** None.
279+
///
280+
/// **Example:**
281+
///
282+
/// ```rust
283+
/// // example code where clippy issues a warning
284+
/// ```
285+
/// Use instead:
286+
/// ```rust
287+
/// // example code which does not raise clippy warning
288+
/// ```
289+
pub TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS,
290+
complexity,
291+
"default lint description"
292+
}
293+
272294
declare_lint_pass!(Transmute => [
273295
CROSSPOINTER_TRANSMUTE,
274296
TRANSMUTE_PTR_TO_REF,
@@ -281,6 +303,7 @@ declare_lint_pass!(Transmute => [
281303
TRANSMUTE_INT_TO_FLOAT,
282304
TRANSMUTE_FLOAT_TO_INT,
283305
UNSOUND_COLLECTION_TRANSMUTE,
306+
TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS,
284307
]);
285308

286309
// used to check for UNSOUND_COLLECTION_TRANSMUTE

src/tools/clippy/src/lintlist/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,6 +2215,13 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
22152215
deprecation: None,
22162216
module: "transmute",
22172217
},
2218+
Lint {
2219+
name: "transmutes_expressible_as_ptr_casts",
2220+
group: "complexity",
2221+
desc: "default lint description",
2222+
deprecation: None,
2223+
module: "transmute",
2224+
},
22182225
Lint {
22192226
name: "transmuting_null",
22202227
group: "correctness",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#![warn(clippy::transmutes_expressible_as_ptr_casts)]
2+
3+
fn main() {
4+
// test code goes here
5+
}

0 commit comments

Comments
 (0)