Skip to content

Commit f51c29b

Browse files
committed
remove superseded lints
1 parent f88f9a9 commit f51c29b

21 files changed

+106
-1066
lines changed

clippy_lints/src/declared_lints.rs

-3
Original file line numberDiff line numberDiff line change
@@ -705,10 +705,7 @@ 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,
714711
crate::transmute::TRANSMUTE_NUM_TO_BYTES_INFO,

clippy_lints/src/deprecated_lints.rs

+6
Original file line numberDiff line numberDiff line change
@@ -187,5 +187,11 @@ 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"),
190196
// end renamed lints. used by `cargo dev rename_lint`
191197
]}

clippy_lints/src/transmute/mod.rs

-91
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,29 +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-
306222
declare_clippy_lint! {
307223
/// ### What it does
308224
/// Checks for transmutes from a number to an array of `u8`
@@ -581,12 +497,9 @@ impl_lint_pass!(Transmute => [
581497
TRANSMUTE_PTR_TO_PTR,
582498
USELESS_TRANSMUTE,
583499
WRONG_TRANSMUTE,
584-
TRANSMUTE_INT_TO_CHAR,
585500
TRANSMUTE_BYTES_TO_STR,
586501
TRANSMUTE_INT_TO_BOOL,
587-
TRANSMUTE_INT_TO_FLOAT,
588502
TRANSMUTE_INT_TO_NON_ZERO,
589-
TRANSMUTE_FLOAT_TO_INT,
590503
TRANSMUTE_NUM_TO_BYTES,
591504
UNSOUND_COLLECTION_TRANSMUTE,
592505
TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS,
@@ -632,14 +545,10 @@ impl<'tcx> LateLintPass<'tcx> for Transmute {
632545
| transmute_null_to_fn::check(cx, e, arg, to_ty)
633546
| transmute_ptr_to_ref::check(cx, e, from_ty, to_ty, arg, path, self.msrv)
634547
| 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)
636548
| transmute_ref_to_ref::check(cx, e, from_ty, to_ty, arg, const_context)
637549
| transmute_ptr_to_ptr::check(cx, e, from_ty, to_ty, arg, self.msrv)
638550
| 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)
640551
| 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)
643552
| (unsound_collection_transmute::check(cx, e, from_ty, to_ty)
644553
|| transmute_undefined_repr::check(cx, e, from_ty, to_ty))
645554
| (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.

clippy_lints/src/transmute/transmute_num_to_bytes.rs

-50
This file was deleted.

tests/ui/rename.fixed

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#![allow(unused_labels)]
6464
#![allow(ambiguous_wide_pointer_comparisons)]
6565
#![allow(clippy::reversed_empty_ranges)]
66+
#![allow(unnecessary_transmutes)]
6667
#![warn(clippy::almost_complete_range)] //~ ERROR: lint `clippy::almost_complete_letter_range`
6768
#![warn(clippy::disallowed_names)] //~ ERROR: lint `clippy::blacklisted_name`
6869
#![warn(clippy::blocks_in_conditions)] //~ ERROR: lint `clippy::block_in_if_condition_expr`
@@ -132,5 +133,8 @@
132133
#![warn(unused_labels)] //~ ERROR: lint `clippy::unused_label`
133134
#![warn(ambiguous_wide_pointer_comparisons)] //~ ERROR: lint `clippy::vtable_address_comparisons`
134135
#![warn(clippy::reversed_empty_ranges)] //~ ERROR: lint `clippy::reverse_range_loop`
136+
#![warn(unnecessary_transmutes)] //~ ERROR: lint `clippy::transmute_int_to_float`
137+
#![warn(unnecessary_transmutes)] //~ ERROR: lint `clippy::transmute_int_to_char`
138+
#![warn(unnecessary_transmutes)] //~ ERROR: lint `clippy::transmute_float_to_int`
135139

136140
fn main() {}

0 commit comments

Comments
 (0)