Skip to content

Commit 6f5bf0f

Browse files
committed
rename
1 parent 3cbd27b commit 6f5bf0f

File tree

8 files changed

+16
-163
lines changed

8 files changed

+16
-163
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

-83
Original file line numberDiff line numberDiff line change
@@ -137,40 +137,6 @@ declare_clippy_lint! {
137137
"transmutes from a pointer to a reference type"
138138
}
139139

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

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

279-
declare_clippy_lint! {
280-
/// ### What it does
281-
/// Checks for transmutes from a float to an integer.
282-
///
283-
/// ### Why is this bad?
284-
/// Transmutes are dangerous and error-prone, whereas `to_bits` is intuitive
285-
/// and safe.
286-
///
287-
/// ### Example
288-
/// ```no_run
289-
/// unsafe {
290-
/// let _: u32 = std::mem::transmute(1f32);
291-
/// }
292-
///
293-
/// // should be:
294-
/// let _: u32 = 1f32.to_bits();
295-
/// ```
296-
#[clippy::version = "1.41.0"]
297-
pub TRANSMUTE_FLOAT_TO_INT,
298-
complexity,
299-
"transmutes from a float to an integer"
300-
}
301-
302222
declare_clippy_lint! {
303223
/// ### What it does
304224
/// Checks for transmutes from a number to an array of `u8`
@@ -577,12 +497,9 @@ impl_lint_pass!(Transmute => [
577497
TRANSMUTE_PTR_TO_PTR,
578498
USELESS_TRANSMUTE,
579499
WRONG_TRANSMUTE,
580-
TRANSMUTE_INT_TO_CHAR,
581500
TRANSMUTE_BYTES_TO_STR,
582501
TRANSMUTE_INT_TO_BOOL,
583-
TRANSMUTE_INT_TO_FLOAT,
584502
TRANSMUTE_INT_TO_NON_ZERO,
585-
TRANSMUTE_FLOAT_TO_INT,
586503
TRANSMUTE_NUM_TO_BYTES,
587504
UNSOUND_COLLECTION_TRANSMUTE,
588505
TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS,

tests/ui/rename.fixed

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@
133133
#![warn(unused_labels)] //~ ERROR: lint `clippy::unused_label`
134134
#![warn(ambiguous_wide_pointer_comparisons)] //~ ERROR: lint `clippy::vtable_address_comparisons`
135135
#![warn(clippy::reversed_empty_ranges)] //~ ERROR: lint `clippy::reverse_range_loop`
136-
#![warn(unnecessary_transmutes)] //~ ERROR: lint `clippy::transmute_float_to_int`
137-
#![warn(unnecessary_transmutes)] //~ ERROR: lint `clippy::transmute_int_to_char`
138136
#![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`
139139

140140
fn main() {}

tests/ui/rename.rs

+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_letter_range)] //~ ERROR: lint `clippy::almost_complete_letter_range`
6768
#![warn(clippy::blacklisted_name)] //~ ERROR: lint `clippy::blacklisted_name`
6869
#![warn(clippy::block_in_if_condition_expr)] //~ ERROR: lint `clippy::block_in_if_condition_expr`
@@ -132,5 +133,8 @@
132133
#![warn(clippy::unused_label)] //~ ERROR: lint `clippy::unused_label`
133134
#![warn(clippy::vtable_address_comparisons)] //~ ERROR: lint `clippy::vtable_address_comparisons`
134135
#![warn(clippy::reverse_range_loop)] //~ ERROR: lint `clippy::reverse_range_loop`
136+
#![warn(clippy::transmute_int_to_float)] //~ ERROR: lint `clippy::transmute_int_to_float`
137+
#![warn(clippy::transmute_int_to_char)] //~ ERROR: lint `clippy::transmute_int_to_char`
138+
#![warn(clippy::transmute_float_to_int)] //~ ERROR: lint `clippy::transmute_float_to_int`
135139

136140
fn main() {}

tests/ui/rename.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -415,10 +415,10 @@ error: lint `clippy::reverse_range_loop` has been renamed to `clippy::reversed_e
415415
LL | #![warn(clippy::reverse_range_loop)]
416416
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::reversed_empty_ranges`
417417

418-
error: lint `clippy::transmute_float_to_int` has been renamed to `unnecessary_transmutes`
418+
error: lint `clippy::transmute_int_to_float` has been renamed to `unnecessary_transmutes`
419419
--> tests/ui/rename.rs:136:9
420420
|
421-
LL | #![warn(clippy::transmute_float_to_int)]
421+
LL | #![warn(clippy::transmute_int_to_float)]
422422
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unnecessary_transmutes`
423423

424424
error: lint `clippy::transmute_int_to_char` has been renamed to `unnecessary_transmutes`
@@ -427,10 +427,10 @@ error: lint `clippy::transmute_int_to_char` has been renamed to `unnecessary_tra
427427
LL | #![warn(clippy::transmute_int_to_char)]
428428
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unnecessary_transmutes`
429429

430-
error: lint `clippy::transmute_int_to_float` has been renamed to `unnecessary_transmutes`
430+
error: lint `clippy::transmute_float_to_int` has been renamed to `unnecessary_transmutes`
431431
--> tests/ui/rename.rs:138:9
432432
|
433-
LL | #![warn(clippy::transmute_int_to_float)]
433+
LL | #![warn(clippy::transmute_float_to_int)]
434434
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unnecessary_transmutes`
435435

436436
error: aborting due to 72 previous errors

tests/ui/transmute_float_to_int.fixed

-60
This file was deleted.

tests/ui/transmute_float_to_int.stderr

-11
This file was deleted.

0 commit comments

Comments
 (0)