@@ -700,40 +700,6 @@ declare_clippy_lint! {
700
700
"cast to the same type, e.g. `x as i32` where `x: i32`"
701
701
}
702
702
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
-
737
703
/// **What it does:** Checks for casts from a less-strictly-aligned pointer to a
738
704
/// more-strictly-aligned pointer
739
705
///
@@ -947,8 +913,6 @@ impl LintPass for CastPass {
947
913
CAST_LOSSLESS ,
948
914
UNNECESSARY_CAST ,
949
915
CAST_PTR_ALIGNMENT ,
950
- FN_TO_NUMERIC_CAST ,
951
- FN_TO_NUMERIC_CAST_WITH_TRUNCATION ,
952
916
)
953
917
}
954
918
}
@@ -1033,37 +997,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CastPass {
1033
997
}
1034
998
}
1035
999
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
-
1067
1000
if_chain ! {
1068
1001
if let ty:: RawPtr ( from_ptr_ty) = & cast_from. sty;
1069
1002
if let ty:: RawPtr ( to_ptr_ty) = & cast_to. sty;
0 commit comments