1 #![warn(clippy::fn_to_numeric_cast_any)]
2 #![allow(clippy::fn_to_numeric_cast, clippy::fn_to_numeric_cast_with_truncation)]
8 fn generic_foo<T>(x: T) -> T {
13 fn static_method() -> u32 {
20 impl Trait for Struct {}
22 fn fn_pointer_to_integer() {
38 fn static_method_to_integer() {
39 let _ = Struct::static_method as usize;
42 fn fn_with_fn_arg(f: fn(i32) -> u32) -> usize {
46 fn fn_with_generic_static_trait_method<T: Trait>() -> usize {
47 T::static_method as usize
50 fn closure_to_fn_to_integer() {
51 let clos = |x| x * 2_u32;
53 let _ = (clos as fn(u32) -> u32) as usize;
57 let _ = foo as *const ();
60 fn cast_fn_to_self() {
61 // Casting to the same function pointer type should be permitted.
62 let _ = foo as fn() -> u8;
65 fn cast_generic_to_concrete() {
66 // Casting to a more concrete function pointer type should be permitted.
67 let _ = generic_foo as fn(usize) -> usize;
70 fn cast_closure_to_fn() {
71 // Casting a closure to a function pointer should be permitted.
73 let _ = id as fn(usize) -> usize;