Skip to content

Commit 756de2a

Browse files
remove superseded lints (#14703)
changelog: [`transmute_float_to_int, transmute_int_to_char, transmute_int_to_float`, `transmute_num_to_bytes`]: remove lints, now in rustc these lints are now mostly in rustc, so they dont need to be in clippy anymore rust-lang/rust#136083 (comment) pending rust-lang/rust#140431: transmute_int_to_bool <!-- TRIAGEBOT_START --> <!-- TRIAGEBOT_SUMMARY_START --> ### Summary Notes - ["Rust version of new lints should be checked" by @samueltardieu](#14703 (comment)) Generated by triagebot, see [help](https://forge.rust-lang.org/triagebot/note.html) for how to add more <!-- TRIAGEBOT_SUMMARY_DATA_START$${"entries_by_url":{"https://github.com/rust-lang/rust-clippy/pull/14703#issuecomment-2861982576":{"title":"Rust version of new lints should be checked","comment_url":"https://github.com/rust-lang/rust-clippy/pull/14703#issuecomment-2861982576","author":"samueltardieu"}}}$$TRIAGEBOT_SUMMARY_DATA_END --> <!-- TRIAGEBOT_SUMMARY_END --> <!-- TRIAGEBOT_END -->
2 parents 656b317 + 35bdd25 commit 756de2a

21 files changed

+116
-1091
lines changed

clippy_lints/src/declared_lints.rs

-4
Original file line numberDiff line numberDiff line change
@@ -705,13 +705,9 @@ pub static LINTS: &[&crate::LintInfo] = &[
705705
crate::transmute::MISSING_TRANSMUTE_ANNOTATIONS_INFO,
706706
crate::transmute::TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS_INFO,
707707
crate::transmute::TRANSMUTE_BYTES_TO_STR_INFO,
708-
crate::transmute::TRANSMUTE_FLOAT_TO_INT_INFO,
709708
crate::transmute::TRANSMUTE_INT_TO_BOOL_INFO,
710-
crate::transmute::TRANSMUTE_INT_TO_CHAR_INFO,
711-
crate::transmute::TRANSMUTE_INT_TO_FLOAT_INFO,
712709
crate::transmute::TRANSMUTE_INT_TO_NON_ZERO_INFO,
713710
crate::transmute::TRANSMUTE_NULL_TO_FN_INFO,
714-
crate::transmute::TRANSMUTE_NUM_TO_BYTES_INFO,
715711
crate::transmute::TRANSMUTE_PTR_TO_PTR_INFO,
716712
crate::transmute::TRANSMUTE_PTR_TO_REF_INFO,
717713
crate::transmute::TRANSMUTE_UNDEFINED_REPR_INFO,

clippy_lints/src/deprecated_lints.rs

+8
Original file line numberDiff line numberDiff line change
@@ -187,5 +187,13 @@ declare_with_version! { RENAMED(RENAMED_VERSION): &[(&str, &str)] = &[
187187
("clippy::vtable_address_comparisons", "ambiguous_wide_pointer_comparisons"),
188188
#[clippy::version = ""]
189189
("clippy::reverse_range_loop", "clippy::reversed_empty_ranges"),
190+
#[clippy::version = "1.88.0"]
191+
("clippy::transmute_int_to_float", "unnecessary_transmutes"),
192+
#[clippy::version = "1.88.0"]
193+
("clippy::transmute_int_to_char", "unnecessary_transmutes"),
194+
#[clippy::version = "1.88.0"]
195+
("clippy::transmute_float_to_int", "unnecessary_transmutes"),
196+
#[clippy::version = "1.88.0"]
197+
("clippy::transmute_num_to_bytes", "unnecessary_transmutes"),
190198
// end renamed lints. used by `cargo dev rename_lint`
191199
]}

clippy_lints/src/transmute/mod.rs

-115
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
mod crosspointer_transmute;
22
mod eager_transmute;
33
mod missing_transmute_annotations;
4-
mod transmute_float_to_int;
54
mod transmute_int_to_bool;
6-
mod transmute_int_to_char;
7-
mod transmute_int_to_float;
85
mod transmute_int_to_non_zero;
96
mod transmute_null_to_fn;
10-
mod transmute_num_to_bytes;
117
mod transmute_ptr_to_ptr;
128
mod transmute_ptr_to_ref;
139
mod transmute_ref_to_ref;
@@ -141,40 +137,6 @@ declare_clippy_lint! {
141137
"transmutes from a pointer to a reference type"
142138
}
143139

144-
declare_clippy_lint! {
145-
/// ### What it does
146-
/// Checks for transmutes from an integer to a `char`.
147-
///
148-
/// ### Why is this bad?
149-
/// Not every integer is a Unicode scalar value.
150-
///
151-
/// ### Known problems
152-
/// - [`from_u32`] which this lint suggests using is slower than `transmute`
153-
/// as it needs to validate the input.
154-
/// If you are certain that the input is always a valid Unicode scalar value,
155-
/// use [`from_u32_unchecked`] which is as fast as `transmute`
156-
/// but has a semantically meaningful name.
157-
/// - You might want to handle `None` returned from [`from_u32`] instead of calling `unwrap`.
158-
///
159-
/// [`from_u32`]: https://doc.rust-lang.org/std/char/fn.from_u32.html
160-
/// [`from_u32_unchecked`]: https://doc.rust-lang.org/std/char/fn.from_u32_unchecked.html
161-
///
162-
/// ### Example
163-
/// ```no_run
164-
/// let x = 1_u32;
165-
/// unsafe {
166-
/// let _: char = std::mem::transmute(x); // where x: u32
167-
/// }
168-
///
169-
/// // should be:
170-
/// let _ = std::char::from_u32(x).unwrap();
171-
/// ```
172-
#[clippy::version = "pre 1.29.0"]
173-
pub TRANSMUTE_INT_TO_CHAR,
174-
complexity,
175-
"transmutes from an integer to a `char`"
176-
}
177-
178140
declare_clippy_lint! {
179141
/// ### What it does
180142
/// Checks for transmutes from a `&[u8]` to a `&str`.
@@ -232,29 +194,6 @@ declare_clippy_lint! {
232194
"transmutes from an integer to a `bool`"
233195
}
234196

235-
declare_clippy_lint! {
236-
/// ### What it does
237-
/// Checks for transmutes from an integer to a float.
238-
///
239-
/// ### Why is this bad?
240-
/// Transmutes are dangerous and error-prone, whereas `from_bits` is intuitive
241-
/// and safe.
242-
///
243-
/// ### Example
244-
/// ```no_run
245-
/// unsafe {
246-
/// let _: f32 = std::mem::transmute(1_u32); // where x: u32
247-
/// }
248-
///
249-
/// // should be:
250-
/// let _: f32 = f32::from_bits(1_u32);
251-
/// ```
252-
#[clippy::version = "pre 1.29.0"]
253-
pub TRANSMUTE_INT_TO_FLOAT,
254-
complexity,
255-
"transmutes from an integer to a float"
256-
}
257-
258197
declare_clippy_lint! {
259198
/// ### What it does
260199
/// Checks for transmutes from `T` to `NonZero<T>`, and suggests the `new_unchecked`
@@ -280,52 +219,6 @@ declare_clippy_lint! {
280219
"transmutes from an integer to a non-zero wrapper"
281220
}
282221

283-
declare_clippy_lint! {
284-
/// ### What it does
285-
/// Checks for transmutes from a float to an integer.
286-
///
287-
/// ### Why is this bad?
288-
/// Transmutes are dangerous and error-prone, whereas `to_bits` is intuitive
289-
/// and safe.
290-
///
291-
/// ### Example
292-
/// ```no_run
293-
/// unsafe {
294-
/// let _: u32 = std::mem::transmute(1f32);
295-
/// }
296-
///
297-
/// // should be:
298-
/// let _: u32 = 1f32.to_bits();
299-
/// ```
300-
#[clippy::version = "1.41.0"]
301-
pub TRANSMUTE_FLOAT_TO_INT,
302-
complexity,
303-
"transmutes from a float to an integer"
304-
}
305-
306-
declare_clippy_lint! {
307-
/// ### What it does
308-
/// Checks for transmutes from a number to an array of `u8`
309-
///
310-
/// ### Why this is bad?
311-
/// Transmutes are dangerous and error-prone, whereas `to_ne_bytes`
312-
/// is intuitive and safe.
313-
///
314-
/// ### Example
315-
/// ```no_run
316-
/// unsafe {
317-
/// let x: [u8; 8] = std::mem::transmute(1i64);
318-
/// }
319-
///
320-
/// // should be
321-
/// let x: [u8; 8] = 0i64.to_ne_bytes();
322-
/// ```
323-
#[clippy::version = "1.58.0"]
324-
pub TRANSMUTE_NUM_TO_BYTES,
325-
complexity,
326-
"transmutes from a number to an array of `u8`"
327-
}
328-
329222
declare_clippy_lint! {
330223
/// ### What it does
331224
/// Checks for transmutes from a pointer to a pointer, or
@@ -581,13 +474,9 @@ impl_lint_pass!(Transmute => [
581474
TRANSMUTE_PTR_TO_PTR,
582475
USELESS_TRANSMUTE,
583476
WRONG_TRANSMUTE,
584-
TRANSMUTE_INT_TO_CHAR,
585477
TRANSMUTE_BYTES_TO_STR,
586478
TRANSMUTE_INT_TO_BOOL,
587-
TRANSMUTE_INT_TO_FLOAT,
588479
TRANSMUTE_INT_TO_NON_ZERO,
589-
TRANSMUTE_FLOAT_TO_INT,
590-
TRANSMUTE_NUM_TO_BYTES,
591480
UNSOUND_COLLECTION_TRANSMUTE,
592481
TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS,
593482
TRANSMUTE_UNDEFINED_REPR,
@@ -632,14 +521,10 @@ impl<'tcx> LateLintPass<'tcx> for Transmute {
632521
| transmute_null_to_fn::check(cx, e, arg, to_ty)
633522
| transmute_ptr_to_ref::check(cx, e, from_ty, to_ty, arg, path, self.msrv)
634523
| missing_transmute_annotations::check(cx, path, from_ty, to_ty, e.hir_id)
635-
| transmute_int_to_char::check(cx, e, from_ty, to_ty, arg, const_context)
636524
| transmute_ref_to_ref::check(cx, e, from_ty, to_ty, arg, const_context)
637525
| transmute_ptr_to_ptr::check(cx, e, from_ty, to_ty, arg, self.msrv)
638526
| transmute_int_to_bool::check(cx, e, from_ty, to_ty, arg)
639-
| transmute_int_to_float::check(cx, e, from_ty, to_ty, arg, const_context, self.msrv)
640527
| transmute_int_to_non_zero::check(cx, e, from_ty, to_ty, arg)
641-
| transmute_float_to_int::check(cx, e, from_ty, to_ty, arg, const_context, self.msrv)
642-
| transmute_num_to_bytes::check(cx, e, from_ty, to_ty, arg, const_context, self.msrv)
643528
| (unsound_collection_transmute::check(cx, e, from_ty, to_ty)
644529
|| transmute_undefined_repr::check(cx, e, from_ty, to_ty))
645530
| (eager_transmute::check(cx, e, arg, from_ty, to_ty));

clippy_lints/src/transmute/transmute_float_to_int.rs

-66
This file was deleted.

clippy_lints/src/transmute/transmute_int_to_char.rs

-47
This file was deleted.

clippy_lints/src/transmute/transmute_int_to_float.rs

-50
This file was deleted.

0 commit comments

Comments
 (0)