relicensing: Remove fn_to_numeric_cast, fn_to_numeric_cast_with_truncation
This removes the code added in https://github.com/rust-lang-nursery/rust-clippy/pull/2814
This commit is contained in:
parent
902aca70bd
commit
fffcd093b2
4 changed files with 0 additions and 159 deletions
|
|
@ -697,8 +697,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
|
|||
types::CAST_LOSSLESS,
|
||||
types::CAST_PTR_ALIGNMENT,
|
||||
types::CHAR_LIT_AS_U8,
|
||||
types::FN_TO_NUMERIC_CAST,
|
||||
types::FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
|
||||
types::IMPLICIT_HASHER,
|
||||
types::LET_UNIT_VALUE,
|
||||
types::OPTION_OPTION,
|
||||
|
|
@ -791,7 +789,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
|
|||
returns::LET_AND_RETURN,
|
||||
returns::NEEDLESS_RETURN,
|
||||
strings::STRING_LIT_AS_BYTES,
|
||||
types::FN_TO_NUMERIC_CAST,
|
||||
types::IMPLICIT_HASHER,
|
||||
types::LET_UNIT_VALUE,
|
||||
unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
|
||||
|
|
@ -921,7 +918,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry<'_>, conf: &Conf) {
|
|||
transmute::WRONG_TRANSMUTE,
|
||||
types::ABSURD_EXTREME_COMPARISONS,
|
||||
types::CAST_PTR_ALIGNMENT,
|
||||
types::FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
|
||||
types::UNIT_CMP,
|
||||
unicode::ZERO_WIDTH_SPACE,
|
||||
unused_io_amount::UNUSED_IO_AMOUNT,
|
||||
|
|
|
|||
|
|
@ -700,40 +700,6 @@ declare_clippy_lint! {
|
|||
"cast to the same type, e.g. `x as i32` where `x: i32`"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for casts of a function pointer to a numeric type not enough to store address.
|
||||
///
|
||||
/// **Why is this bad?** Casting a function pointer to not eligible type could truncate the address value.
|
||||
///
|
||||
/// **Known problems:** None.
|
||||
///
|
||||
/// **Example:**
|
||||
/// ```rust
|
||||
/// fn test_fn() -> i16;
|
||||
/// let _ = test_fn as i32
|
||||
/// ```
|
||||
declare_clippy_lint! {
|
||||
pub FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
|
||||
correctness,
|
||||
"cast function pointer to the numeric type with value truncation"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for casts of a function pointer to a numeric type except `usize`.
|
||||
///
|
||||
/// **Why is this bad?** Casting a function pointer to something other than `usize` is not a good style.
|
||||
///
|
||||
/// **Known problems:** None.
|
||||
///
|
||||
/// **Example:**
|
||||
/// ```rust
|
||||
/// fn test_fn() -> i16;
|
||||
/// let _ = test_fn as i128
|
||||
/// ```
|
||||
declare_clippy_lint! {
|
||||
pub FN_TO_NUMERIC_CAST,
|
||||
style,
|
||||
"cast function pointer to the numeric type"
|
||||
}
|
||||
|
||||
/// **What it does:** Checks for casts from a less-strictly-aligned pointer to a
|
||||
/// more-strictly-aligned pointer
|
||||
///
|
||||
|
|
@ -947,8 +913,6 @@ impl LintPass for CastPass {
|
|||
CAST_LOSSLESS,
|
||||
UNNECESSARY_CAST,
|
||||
CAST_PTR_ALIGNMENT,
|
||||
FN_TO_NUMERIC_CAST,
|
||||
FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -1033,37 +997,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CastPass {
|
|||
}
|
||||
}
|
||||
|
||||
match &cast_from.sty {
|
||||
ty::FnDef(..) |
|
||||
ty::FnPtr(..) => {
|
||||
if cast_to.is_numeric() && cast_to.sty != ty::Uint(UintTy::Usize){
|
||||
let to_nbits = int_ty_to_nbits(cast_to, cx.tcx);
|
||||
let pointer_nbits = cx.tcx.data_layout.pointer_size.bits();
|
||||
if to_nbits < pointer_nbits || (to_nbits == pointer_nbits && cast_to.is_signed()) {
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
|
||||
expr.span,
|
||||
&format!("casting a `{}` to `{}` may truncate the function address value.", cast_from, cast_to),
|
||||
"if you need the address of the function, consider",
|
||||
format!("{} as usize", &snippet(cx, ex.span, "x"))
|
||||
);
|
||||
} else {
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
FN_TO_NUMERIC_CAST,
|
||||
expr.span,
|
||||
&format!("casting a `{}` to `{}` is bad style.", cast_from, cast_to),
|
||||
"if you need the address of the function, consider",
|
||||
format!("{} as usize", &snippet(cx, ex.span, "x"))
|
||||
);
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
|
||||
if_chain!{
|
||||
if let ty::RawPtr(from_ptr_ty) = &cast_from.sty;
|
||||
if let ty::RawPtr(to_ptr_ty) = &cast_to.sty;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue