run cargo dev new_lint then move transmutes_expressible_as_ptr_casts into transmute module

This commit is contained in:
Ryan1729 2020-08-02 18:41:50 -06:00
parent 24a6130da2
commit 5e84b8c2fb
5 changed files with 39 additions and 0 deletions

View file

@ -1730,6 +1730,7 @@ Released 2018-09-13
[`transmute_int_to_float`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_int_to_float
[`transmute_ptr_to_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_ptr_to_ptr
[`transmute_ptr_to_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_ptr_to_ref
[`transmutes_expressible_as_ptr_casts`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmutes_expressible_as_ptr_casts
[`transmuting_null`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmuting_null
[`trivial_regex`]: https://rust-lang.github.io/rust-clippy/master/index.html#trivial_regex
[`trivially_copy_pass_by_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref

View file

@ -798,6 +798,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
&transmute::UNSOUND_COLLECTION_TRANSMUTE,
&transmute::USELESS_TRANSMUTE,
&transmute::WRONG_TRANSMUTE,
&transmute::TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS,
&transmuting_null::TRANSMUTING_NULL,
&trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF,
&try_err::TRY_ERR,
@ -1426,6 +1427,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&transmute::TRANSMUTE_PTR_TO_REF),
LintId::of(&transmute::UNSOUND_COLLECTION_TRANSMUTE),
LintId::of(&transmute::WRONG_TRANSMUTE),
LintId::of(&transmute::TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS),
LintId::of(&transmuting_null::TRANSMUTING_NULL),
LintId::of(&try_err::TRY_ERR),
LintId::of(&types::ABSURD_EXTREME_COMPARISONS),
@ -1624,6 +1626,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
LintId::of(&transmute::TRANSMUTE_INT_TO_FLOAT),
LintId::of(&transmute::TRANSMUTE_PTR_TO_PTR),
LintId::of(&transmute::TRANSMUTE_PTR_TO_REF),
LintId::of(&transmute::TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS),
LintId::of(&types::BORROWED_BOX),
LintId::of(&types::CHAR_LIT_AS_U8),
LintId::of(&types::TYPE_COMPLEXITY),

View file

@ -269,6 +269,28 @@ declare_clippy_lint! {
correctness,
"transmute between collections of layout-incompatible types"
}
declare_clippy_lint! {
/// **What it does:**
///
/// **Why is this bad?**
///
/// **Known problems:** None.
///
/// **Example:**
///
/// ```rust
/// // example code where clippy issues a warning
/// ```
/// Use instead:
/// ```rust
/// // example code which does not raise clippy warning
/// ```
pub TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS,
complexity,
"default lint description"
}
declare_lint_pass!(Transmute => [
CROSSPOINTER_TRANSMUTE,
TRANSMUTE_PTR_TO_REF,
@ -281,6 +303,7 @@ declare_lint_pass!(Transmute => [
TRANSMUTE_INT_TO_FLOAT,
TRANSMUTE_FLOAT_TO_INT,
UNSOUND_COLLECTION_TRANSMUTE,
TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS,
]);
// used to check for UNSOUND_COLLECTION_TRANSMUTE

View file

@ -2215,6 +2215,13 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
deprecation: None,
module: "transmute",
},
Lint {
name: "transmutes_expressible_as_ptr_casts",
group: "complexity",
desc: "default lint description",
deprecation: None,
module: "transmute",
},
Lint {
name: "transmuting_null",
group: "correctness",

View file

@ -0,0 +1,5 @@
#![warn(clippy::transmutes_expressible_as_ptr_casts)]
fn main() {
// test code goes here
}