RS.CLIPPY.FN_TO_NUMERIC_CAST
Casting a function pointer to a numeric type other than `usize`
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: fn_to_numeric_cast. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for casts of function pointers to something other than usize.
Why is this bad?
Casting a function pointer to anything other than usize/isize is
not portable across architectures. If the target type is too small the
address would be truncated, and target types larger than usize are
unnecessary.
Casting to isize also doesn't make sense, since addresses are never
signed.
Example
fn fun() -> i32 { 1 }
let _ = fun as i64;
Use instead:
let _ = fun as usize;