Skip to content

Commit 100a24d

Browse files
committed
Auto merge of #5364 - flip1995:useless_transmute_quarantine, r=Manishearth
Move useless_transmute to nursery cc #5343 @rust-lang/clippy anyone against moving this to nursery? changelog: Move [`useless_transmute`] to nursery
2 parents d3989ee + 13fcee5 commit 100a24d

File tree

4 files changed

+5
-31
lines changed

4 files changed

+5
-31
lines changed

clippy_lints/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1355,7 +1355,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
13551355
LintId::of(&transmute::TRANSMUTE_PTR_TO_PTR),
13561356
LintId::of(&transmute::TRANSMUTE_PTR_TO_REF),
13571357
LintId::of(&transmute::UNSOUND_COLLECTION_TRANSMUTE),
1358-
LintId::of(&transmute::USELESS_TRANSMUTE),
13591358
LintId::of(&transmute::WRONG_TRANSMUTE),
13601359
LintId::of(&transmuting_null::TRANSMUTING_NULL),
13611360
LintId::of(&trivially_copy_pass_by_ref::TRIVIALLY_COPY_PASS_BY_REF),
@@ -1558,7 +1557,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
15581557
LintId::of(&transmute::TRANSMUTE_INT_TO_FLOAT),
15591558
LintId::of(&transmute::TRANSMUTE_PTR_TO_PTR),
15601559
LintId::of(&transmute::TRANSMUTE_PTR_TO_REF),
1561-
LintId::of(&transmute::USELESS_TRANSMUTE),
15621560
LintId::of(&types::BORROWED_BOX),
15631561
LintId::of(&types::CHAR_LIT_AS_U8),
15641562
LintId::of(&types::OPTION_OPTION),
@@ -1675,6 +1673,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
16751673
LintId::of(&mutex_atomic::MUTEX_INTEGER),
16761674
LintId::of(&needless_borrow::NEEDLESS_BORROW),
16771675
LintId::of(&path_buf_push_overwrite::PATH_BUF_PUSH_OVERWRITE),
1676+
LintId::of(&transmute::USELESS_TRANSMUTE),
16781677
LintId::of(&use_self::USE_SELF),
16791678
]);
16801679
}

clippy_lints/src/transmute.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ declare_clippy_lint! {
2828
"transmutes that are confusing at best, undefined behaviour at worst and always useless"
2929
}
3030

31+
// FIXME: Move this to `complexity` again, after #5343 is fixed
3132
declare_clippy_lint! {
3233
/// **What it does:** Checks for transmutes to the original type of the object
3334
/// and transmutes that could be a cast.
@@ -42,7 +43,7 @@ declare_clippy_lint! {
4243
/// core::intrinsics::transmute(t); // where the result type is the same as `t`'s
4344
/// ```
4445
pub USELESS_TRANSMUTE,
45-
complexity,
46+
nursery,
4647
"transmutes that have the same to and from types or could be a cast/coercion"
4748
}
4849

src/lintlist/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2382,7 +2382,7 @@ pub const ALL_LINTS: [Lint; 362] = [
23822382
},
23832383
Lint {
23842384
name: "useless_transmute",
2385-
group: "complexity",
2385+
group: "nursery",
23862386
desc: "transmutes that have the same to and from types or could be a cast/coercion",
23872387
deprecation: None,
23882388
module: "transmute",

tests/ui/transmute_ptr_to_ptr.stderr

+1-27
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
error: transmute from a type (`&T`) to itself
2-
--> $DIR/transmute_ptr_to_ptr.rs:8:5
3-
|
4-
LL | std::mem::transmute::<&'a T, &'static T>(t)
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6-
|
7-
= note: `-D clippy::useless-transmute` implied by `-D warnings`
8-
9-
error: transmute from a type (`&T`) to itself
10-
--> $DIR/transmute_ptr_to_ptr.rs:13:5
11-
|
12-
LL | std::mem::transmute::<&'a T, &'b T>(t)
13-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14-
151
error: transmute from a pointer to a pointer
162
--> $DIR/transmute_ptr_to_ptr.rs:29:29
173
|
@@ -50,17 +36,5 @@ error: transmute from a reference to a reference
5036
LL | let _: &GenericParam<f32> = std::mem::transmute(&GenericParam { t: 1u32 });
5137
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*(&GenericParam { t: 1u32 } as *const GenericParam<u32> as *const GenericParam<f32>)`
5238

53-
error: transmute from a type (`&LifetimeParam`) to itself
54-
--> $DIR/transmute_ptr_to_ptr.rs:50:47
55-
|
56-
LL | let _: &LifetimeParam<'static> = unsafe { std::mem::transmute(&lp) };
57-
| ^^^^^^^^^^^^^^^^^^^^^^^^
58-
59-
error: transmute from a type (`&GenericParam<&LifetimeParam>`) to itself
60-
--> $DIR/transmute_ptr_to_ptr.rs:51:62
61-
|
62-
LL | let _: &GenericParam<&LifetimeParam<'static>> = unsafe { std::mem::transmute(&GenericParam { t: &lp }) };
63-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
64-
65-
error: aborting due to 10 previous errors
39+
error: aborting due to 6 previous errors
6640

0 commit comments

Comments
 (0)