Skip to content

Commit 13fcee5

Browse files
committed
Move useless_transmute to nursery
1 parent 1ff81c1 commit 13fcee5

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
@@ -1351,7 +1351,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
13511351
LintId::of(&transmute::TRANSMUTE_PTR_TO_PTR),
13521352
LintId::of(&transmute::TRANSMUTE_PTR_TO_REF),
13531353
LintId::of(&transmute::UNSOUND_COLLECTION_TRANSMUTE),
1354-
LintId::of(&transmute::USELESS_TRANSMUTE),
13551354
LintId::of(&transmute::WRONG_TRANSMUTE),
13561355
LintId::of(&transmuting_null::TRANSMUTING_NULL),
13571356
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:
15531552
LintId::of(&transmute::TRANSMUTE_INT_TO_FLOAT),
15541553
LintId::of(&transmute::TRANSMUTE_PTR_TO_PTR),
15551554
LintId::of(&transmute::TRANSMUTE_PTR_TO_REF),
1556-
LintId::of(&transmute::USELESS_TRANSMUTE),
15571555
LintId::of(&types::BORROWED_BOX),
15581556
LintId::of(&types::CHAR_LIT_AS_U8),
15591557
LintId::of(&types::OPTION_OPTION),
@@ -1670,6 +1668,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
16701668
LintId::of(&mutex_atomic::MUTEX_INTEGER),
16711669
LintId::of(&needless_borrow::NEEDLESS_BORROW),
16721670
LintId::of(&path_buf_push_overwrite::PATH_BUF_PUSH_OVERWRITE),
1671+
LintId::of(&transmute::USELESS_TRANSMUTE),
16731672
LintId::of(&use_self::USE_SELF),
16741673
]);
16751674
}

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
@@ -2375,7 +2375,7 @@ pub const ALL_LINTS: [Lint; 361] = [
23752375
},
23762376
Lint {
23772377
name: "useless_transmute",
2378-
group: "complexity",
2378+
group: "nursery",
23792379
desc: "transmutes that have the same to and from types or could be a cast/coercion",
23802380
deprecation: None,
23812381
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)