Skip to content

Commit fffcd09

Browse files
committed
relicensing: Remove fn_to_numeric_cast, fn_to_numeric_cast_with_truncation
This removes the code added in #2814
1 parent 902aca7 commit fffcd09

File tree

4 files changed

+0
-159
lines changed

4 files changed

+0
-159
lines changed

clippy_lints/src/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
697697
types::CAST_LOSSLESS,
698698
types::CAST_PTR_ALIGNMENT,
699699
types::CHAR_LIT_AS_U8,
700-
types::FN_TO_NUMERIC_CAST,
701-
types::FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
702700
types::IMPLICIT_HASHER,
703701
types::LET_UNIT_VALUE,
704702
types::OPTION_OPTION,
@@ -791,7 +789,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
791789
returns::LET_AND_RETURN,
792790
returns::NEEDLESS_RETURN,
793791
strings::STRING_LIT_AS_BYTES,
794-
types::FN_TO_NUMERIC_CAST,
795792
types::IMPLICIT_HASHER,
796793
types::LET_UNIT_VALUE,
797794
unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
@@ -921,7 +918,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
921918
transmute::WRONG_TRANSMUTE,
922919
types::ABSURD_EXTREME_COMPARISONS,
923920
types::CAST_PTR_ALIGNMENT,
924-
types::FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
925921
types::UNIT_CMP,
926922
unicode::ZERO_WIDTH_SPACE,
927923
unused_io_amount::UNUSED_IO_AMOUNT,

clippy_lints/src/types.rs

-67
Original file line numberDiff line numberDiff line change
@@ -700,40 +700,6 @@ declare_clippy_lint! {
700700
"cast to the same type, e.g. `x as i32` where `x: i32`"
701701
}
702702

703-
/// **What it does:** Checks for casts of a function pointer to a numeric type not enough to store address.
704-
///
705-
/// **Why is this bad?** Casting a function pointer to not eligible type could truncate the address value.
706-
///
707-
/// **Known problems:** None.
708-
///
709-
/// **Example:**
710-
/// ```rust
711-
/// fn test_fn() -> i16;
712-
/// let _ = test_fn as i32
713-
/// ```
714-
declare_clippy_lint! {
715-
pub FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
716-
correctness,
717-
"cast function pointer to the numeric type with value truncation"
718-
}
719-
720-
/// **What it does:** Checks for casts of a function pointer to a numeric type except `usize`.
721-
///
722-
/// **Why is this bad?** Casting a function pointer to something other than `usize` is not a good style.
723-
///
724-
/// **Known problems:** None.
725-
///
726-
/// **Example:**
727-
/// ```rust
728-
/// fn test_fn() -> i16;
729-
/// let _ = test_fn as i128
730-
/// ```
731-
declare_clippy_lint! {
732-
pub FN_TO_NUMERIC_CAST,
733-
style,
734-
"cast function pointer to the numeric type"
735-
}
736-
737703
/// **What it does:** Checks for casts from a less-strictly-aligned pointer to a
738704
/// more-strictly-aligned pointer
739705
///
@@ -947,8 +913,6 @@ impl LintPass for CastPass {
947913
CAST_LOSSLESS,
948914
UNNECESSARY_CAST,
949915
CAST_PTR_ALIGNMENT,
950-
FN_TO_NUMERIC_CAST,
951-
FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
952916
)
953917
}
954918
}
@@ -1033,37 +997,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CastPass {
1033997
}
1034998
}
1035999

1036-
match &cast_from.sty {
1037-
ty::FnDef(..) |
1038-
ty::FnPtr(..) => {
1039-
if cast_to.is_numeric() && cast_to.sty != ty::Uint(UintTy::Usize){
1040-
let to_nbits = int_ty_to_nbits(cast_to, cx.tcx);
1041-
let pointer_nbits = cx.tcx.data_layout.pointer_size.bits();
1042-
if to_nbits < pointer_nbits || (to_nbits == pointer_nbits && cast_to.is_signed()) {
1043-
span_lint_and_sugg(
1044-
cx,
1045-
FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
1046-
expr.span,
1047-
&format!("casting a `{}` to `{}` may truncate the function address value.", cast_from, cast_to),
1048-
"if you need the address of the function, consider",
1049-
format!("{} as usize", &snippet(cx, ex.span, "x"))
1050-
);
1051-
} else {
1052-
span_lint_and_sugg(
1053-
cx,
1054-
FN_TO_NUMERIC_CAST,
1055-
expr.span,
1056-
&format!("casting a `{}` to `{}` is bad style.", cast_from, cast_to),
1057-
"if you need the address of the function, consider",
1058-
format!("{} as usize", &snippet(cx, ex.span, "x"))
1059-
);
1060-
1061-
};
1062-
}
1063-
}
1064-
_ => ()
1065-
}
1066-
10671000
if_chain!{
10681001
if let ty::RawPtr(from_ptr_ty) = &cast_from.sty;
10691002
if let ty::RawPtr(to_ptr_ty) = &cast_to.sty;

tests/ui/types_fn_to_int.rs

-22
This file was deleted.

tests/ui/types_fn_to_int.stderr

-66
This file was deleted.

0 commit comments

Comments
 (0)