Skip to content

remove superseded lints #14703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions clippy_lints/src/declared_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,10 +705,7 @@ pub static LINTS: &[&crate::LintInfo] = &[
crate::transmute::MISSING_TRANSMUTE_ANNOTATIONS_INFO,
crate::transmute::TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS_INFO,
crate::transmute::TRANSMUTE_BYTES_TO_STR_INFO,
crate::transmute::TRANSMUTE_FLOAT_TO_INT_INFO,
crate::transmute::TRANSMUTE_INT_TO_BOOL_INFO,
crate::transmute::TRANSMUTE_INT_TO_CHAR_INFO,
crate::transmute::TRANSMUTE_INT_TO_FLOAT_INFO,
crate::transmute::TRANSMUTE_INT_TO_NON_ZERO_INFO,
crate::transmute::TRANSMUTE_NULL_TO_FN_INFO,
crate::transmute::TRANSMUTE_NUM_TO_BYTES_INFO,
Expand Down
6 changes: 6 additions & 0 deletions clippy_lints/src/deprecated_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,5 +187,11 @@ declare_with_version! { RENAMED(RENAMED_VERSION): &[(&str, &str)] = &[
("clippy::vtable_address_comparisons", "ambiguous_wide_pointer_comparisons"),
#[clippy::version = ""]
("clippy::reverse_range_loop", "clippy::reversed_empty_ranges"),
#[clippy::version = "1.88.0"]
("clippy::transmute_int_to_float", "unnecessary_transmutes"),
#[clippy::version = "1.88.0"]
("clippy::transmute_int_to_char", "unnecessary_transmutes"),
#[clippy::version = "1.88.0"]
("clippy::transmute_float_to_int", "unnecessary_transmutes"),
// end renamed lints. used by `cargo dev rename_lint`
]}
91 changes: 0 additions & 91 deletions clippy_lints/src/transmute/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
mod crosspointer_transmute;
mod eager_transmute;
mod missing_transmute_annotations;
mod transmute_float_to_int;
mod transmute_int_to_bool;
mod transmute_int_to_char;
mod transmute_int_to_float;
mod transmute_int_to_non_zero;
mod transmute_null_to_fn;
mod transmute_num_to_bytes;
mod transmute_ptr_to_ptr;
mod transmute_ptr_to_ref;
mod transmute_ref_to_ref;
Expand Down Expand Up @@ -141,40 +137,6 @@ declare_clippy_lint! {
"transmutes from a pointer to a reference type"
}

declare_clippy_lint! {
/// ### What it does
/// Checks for transmutes from an integer to a `char`.
///
/// ### Why is this bad?
/// Not every integer is a Unicode scalar value.
///
/// ### Known problems
/// - [`from_u32`] which this lint suggests using is slower than `transmute`
/// as it needs to validate the input.
/// If you are certain that the input is always a valid Unicode scalar value,
/// use [`from_u32_unchecked`] which is as fast as `transmute`
/// but has a semantically meaningful name.
/// - You might want to handle `None` returned from [`from_u32`] instead of calling `unwrap`.
///
/// [`from_u32`]: https://doc.rust-lang.org/std/char/fn.from_u32.html
/// [`from_u32_unchecked`]: https://doc.rust-lang.org/std/char/fn.from_u32_unchecked.html
///
/// ### Example
/// ```no_run
/// let x = 1_u32;
/// unsafe {
/// let _: char = std::mem::transmute(x); // where x: u32
/// }
///
/// // should be:
/// let _ = std::char::from_u32(x).unwrap();
/// ```
#[clippy::version = "pre 1.29.0"]
pub TRANSMUTE_INT_TO_CHAR,
complexity,
"transmutes from an integer to a `char`"
}

declare_clippy_lint! {
/// ### What it does
/// Checks for transmutes from a `&[u8]` to a `&str`.
Expand Down Expand Up @@ -232,29 +194,6 @@ declare_clippy_lint! {
"transmutes from an integer to a `bool`"
}

declare_clippy_lint! {
/// ### What it does
/// Checks for transmutes from an integer to a float.
///
/// ### Why is this bad?
/// Transmutes are dangerous and error-prone, whereas `from_bits` is intuitive
/// and safe.
///
/// ### Example
/// ```no_run
/// unsafe {
/// let _: f32 = std::mem::transmute(1_u32); // where x: u32
/// }
///
/// // should be:
/// let _: f32 = f32::from_bits(1_u32);
/// ```
#[clippy::version = "pre 1.29.0"]
pub TRANSMUTE_INT_TO_FLOAT,
complexity,
"transmutes from an integer to a float"
}

declare_clippy_lint! {
/// ### What it does
/// Checks for transmutes from `T` to `NonZero<T>`, and suggests the `new_unchecked`
Expand All @@ -280,29 +219,6 @@ declare_clippy_lint! {
"transmutes from an integer to a non-zero wrapper"
}

declare_clippy_lint! {
/// ### What it does
/// Checks for transmutes from a float to an integer.
///
/// ### Why is this bad?
/// Transmutes are dangerous and error-prone, whereas `to_bits` is intuitive
/// and safe.
///
/// ### Example
/// ```no_run
/// unsafe {
/// let _: u32 = std::mem::transmute(1f32);
/// }
///
/// // should be:
/// let _: u32 = 1f32.to_bits();
/// ```
#[clippy::version = "1.41.0"]
pub TRANSMUTE_FLOAT_TO_INT,
complexity,
"transmutes from a float to an integer"
}

declare_clippy_lint! {
/// ### What it does
/// Checks for transmutes from a number to an array of `u8`
Expand Down Expand Up @@ -581,12 +497,9 @@ impl_lint_pass!(Transmute => [
TRANSMUTE_PTR_TO_PTR,
USELESS_TRANSMUTE,
WRONG_TRANSMUTE,
TRANSMUTE_INT_TO_CHAR,
TRANSMUTE_BYTES_TO_STR,
TRANSMUTE_INT_TO_BOOL,
TRANSMUTE_INT_TO_FLOAT,
TRANSMUTE_INT_TO_NON_ZERO,
TRANSMUTE_FLOAT_TO_INT,
TRANSMUTE_NUM_TO_BYTES,
UNSOUND_COLLECTION_TRANSMUTE,
TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS,
Expand Down Expand Up @@ -632,14 +545,10 @@ impl<'tcx> LateLintPass<'tcx> for Transmute {
| transmute_null_to_fn::check(cx, e, arg, to_ty)
| transmute_ptr_to_ref::check(cx, e, from_ty, to_ty, arg, path, self.msrv)
| missing_transmute_annotations::check(cx, path, from_ty, to_ty, e.hir_id)
| transmute_int_to_char::check(cx, e, from_ty, to_ty, arg, const_context)
| transmute_ref_to_ref::check(cx, e, from_ty, to_ty, arg, const_context)
| transmute_ptr_to_ptr::check(cx, e, from_ty, to_ty, arg, self.msrv)
| transmute_int_to_bool::check(cx, e, from_ty, to_ty, arg)
| transmute_int_to_float::check(cx, e, from_ty, to_ty, arg, const_context, self.msrv)
| transmute_int_to_non_zero::check(cx, e, from_ty, to_ty, arg)
| transmute_float_to_int::check(cx, e, from_ty, to_ty, arg, const_context, self.msrv)
| transmute_num_to_bytes::check(cx, e, from_ty, to_ty, arg, const_context, self.msrv)
| (unsound_collection_transmute::check(cx, e, from_ty, to_ty)
|| transmute_undefined_repr::check(cx, e, from_ty, to_ty))
| (eager_transmute::check(cx, e, arg, from_ty, to_ty));
Expand Down
66 changes: 0 additions & 66 deletions clippy_lints/src/transmute/transmute_float_to_int.rs

This file was deleted.

47 changes: 0 additions & 47 deletions clippy_lints/src/transmute/transmute_int_to_char.rs

This file was deleted.

50 changes: 0 additions & 50 deletions clippy_lints/src/transmute/transmute_int_to_float.rs

This file was deleted.

50 changes: 0 additions & 50 deletions clippy_lints/src/transmute/transmute_num_to_bytes.rs

This file was deleted.

4 changes: 4 additions & 0 deletions tests/ui/rename.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#![allow(unused_labels)]
#![allow(ambiguous_wide_pointer_comparisons)]
#![allow(clippy::reversed_empty_ranges)]
#![allow(unnecessary_transmutes)]
#![warn(clippy::almost_complete_range)] //~ ERROR: lint `clippy::almost_complete_letter_range`
#![warn(clippy::disallowed_names)] //~ ERROR: lint `clippy::blacklisted_name`
#![warn(clippy::blocks_in_conditions)] //~ ERROR: lint `clippy::block_in_if_condition_expr`
Expand Down Expand Up @@ -132,5 +133,8 @@
#![warn(unused_labels)] //~ ERROR: lint `clippy::unused_label`
#![warn(ambiguous_wide_pointer_comparisons)] //~ ERROR: lint `clippy::vtable_address_comparisons`
#![warn(clippy::reversed_empty_ranges)] //~ ERROR: lint `clippy::reverse_range_loop`
#![warn(unnecessary_transmutes)] //~ ERROR: lint `clippy::transmute_int_to_float`
#![warn(unnecessary_transmutes)] //~ ERROR: lint `clippy::transmute_int_to_char`
#![warn(unnecessary_transmutes)] //~ ERROR: lint `clippy::transmute_float_to_int`

fn main() {}
Loading