about summary refs log tree commit diff
diff options
context:
space:
mode:
authorflip1995 <hello@philkrones.com>2020-03-23 20:08:07 +0100
committerflip1995 <hello@philkrones.com>2020-03-23 20:32:04 +0100
commit13fcee51e7bcaff23694d845146c6ede2e7834c2 (patch)
treec542405863550604c4bbfa63cdcbac61230422f7
parent1ff81c1b6d7abdcc9ee47f4a8ab175082cad4421 (diff)
downloadrust-13fcee51e7bcaff23694d845146c6ede2e7834c2.tar.gz
rust-13fcee51e7bcaff23694d845146c6ede2e7834c2.zip
Move useless_transmute to nursery
-rw-r--r--clippy_lints/src/lib.rs3
-rw-r--r--clippy_lints/src/transmute.rs3
-rw-r--r--src/lintlist/mod.rs2
-rw-r--r--tests/ui/transmute_ptr_to_ptr.stderr28
4 files changed, 5 insertions, 31 deletions
diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs
index 1c81d78a2b9..e3e833000f7 100644
--- a/clippy_lints/src/lib.rs
+++ b/clippy_lints/src/lib.rs
@@ -1351,7 +1351,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
         LintId::of(&transmute::TRANSMUTE_PTR_TO_PTR),
         LintId::of(&transmute::TRANSMUTE_PTR_TO_REF),
         LintId::of(&transmute::UNSOUND_COLLECTION_TRANSMUTE),
-        LintId::of(&transmute::USELESS_TRANSMUTE),
         LintId::of(&transmute::WRONG_TRANSMUTE),
         LintId::of(&transmuting_null::TRANSMUTING_NULL),
         LintId::of(&trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF),
@@ -1553,7 +1552,6 @@ 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::USELESS_TRANSMUTE),
         LintId::of(&types::BORROWED_BOX),
         LintId::of(&types::CHAR_LIT_AS_U8),
         LintId::of(&types::OPTION_OPTION),
@@ -1670,6 +1668,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
         LintId::of(&mutex_atomic::MUTEX_INTEGER),
         LintId::of(&needless_borrow::NEEDLESS_BORROW),
         LintId::of(&path_buf_push_overwrite::PATH_BUF_PUSH_OVERWRITE),
+        LintId::of(&transmute::USELESS_TRANSMUTE),
         LintId::of(&use_self::USE_SELF),
     ]);
 }
diff --git a/clippy_lints/src/transmute.rs b/clippy_lints/src/transmute.rs
index 4d1996ffcef..6dad9eef522 100644
--- a/clippy_lints/src/transmute.rs
+++ b/clippy_lints/src/transmute.rs
@@ -28,6 +28,7 @@ declare_clippy_lint! {
     "transmutes that are confusing at best, undefined behaviour at worst and always useless"
 }
 
+// FIXME: Move this to `complexity` again, after #5343 is fixed
 declare_clippy_lint! {
     /// **What it does:** Checks for transmutes to the original type of the object
     /// and transmutes that could be a cast.
@@ -42,7 +43,7 @@ declare_clippy_lint! {
     /// core::intrinsics::transmute(t); // where the result type is the same as `t`'s
     /// ```
     pub USELESS_TRANSMUTE,
-    complexity,
+    nursery,
     "transmutes that have the same to and from types or could be a cast/coercion"
 }
 
diff --git a/src/lintlist/mod.rs b/src/lintlist/mod.rs
index fd948953ea2..bc5bad401a4 100644
--- a/src/lintlist/mod.rs
+++ b/src/lintlist/mod.rs
@@ -2375,7 +2375,7 @@ pub const ALL_LINTS: [Lint; 361] = [
     },
     Lint {
         name: "useless_transmute",
-        group: "complexity",
+        group: "nursery",
         desc: "transmutes that have the same to and from types or could be a cast/coercion",
         deprecation: None,
         module: "transmute",
diff --git a/tests/ui/transmute_ptr_to_ptr.stderr b/tests/ui/transmute_ptr_to_ptr.stderr
index 61fbea1c164..4d1b8fcc199 100644
--- a/tests/ui/transmute_ptr_to_ptr.stderr
+++ b/tests/ui/transmute_ptr_to_ptr.stderr
@@ -1,17 +1,3 @@
-error: transmute from a type (`&T`) to itself
-  --> $DIR/transmute_ptr_to_ptr.rs:8:5
-   |
-LL |     std::mem::transmute::<&'a T, &'static T>(t)
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: `-D clippy::useless-transmute` implied by `-D warnings`
-
-error: transmute from a type (`&T`) to itself
-  --> $DIR/transmute_ptr_to_ptr.rs:13:5
-   |
-LL |     std::mem::transmute::<&'a T, &'b T>(t)
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
 error: transmute from a pointer to a pointer
   --> $DIR/transmute_ptr_to_ptr.rs:29:29
    |
@@ -50,17 +36,5 @@ error: transmute from a reference to a reference
 LL |         let _: &GenericParam<f32> = std::mem::transmute(&GenericParam { t: 1u32 });
    |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&GenericParam { t: 1u32 } as *const GenericParam<u32> as *const GenericParam<f32>)`
 
-error: transmute from a type (`&LifetimeParam`) to itself
-  --> $DIR/transmute_ptr_to_ptr.rs:50:47
-   |
-LL |     let _: &LifetimeParam<'static> = unsafe { std::mem::transmute(&lp) };
-   |                                               ^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: transmute from a type (`&GenericParam<&LifetimeParam>`) to itself
-  --> $DIR/transmute_ptr_to_ptr.rs:51:62
-   |
-LL |     let _: &GenericParam<&LifetimeParam<'static>> = unsafe { std::mem::transmute(&GenericParam { t: &lp }) };
-   |                                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to 10 previous errors
+error: aborting due to 6 previous errors