rust/tests/ui/lint/function_casts_as_integer.fixed
2025-11-10 16:38:28 +01:00

22 lines
619 B
Rust

//@ run-rustfix
#![deny(function_casts_as_integer)]
#![allow(unused_variables, dead_code)] // For the rustfix-ed code.
fn foo() {}
enum MyEnum {
Variant(u32),
}
struct MyStruct(u32);
fn main() {
let x = foo as *const () as usize; //~ ERROR: function_casts_as_integer
let x = String::len as *const () as usize; //~ ERROR: function_casts_as_integer
let x = MyEnum::Variant as *const () as usize; //~ ERROR: function_casts_as_integer
let x = MyStruct as *const () as usize; //~ ERROR: function_casts_as_integer
// Ok.
let x = foo as fn() as usize;
let x = foo as *const () as usize;
}