- Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Summary
Docs says "Checks for casts of a function pointer to any integer type", but it actually warns cast to pointer too.
It may make sense to have a separate lint that warns against casts to arbitrary types, but I believe it is wrong anyway for a lint that is intended to warn against casts to integers to warn against casts to pointers.
Lint Name
fn_to_numeric_cast_any
Reproducer
I tried this code:
#![warn(clippy::fn_to_numeric_cast_any)] fn fn1() {} fn main() { let _ = fn1 as *const (); let _ = fn1 as *mut (); }I saw this happen:
warning: casting function pointer `fn1` to `*const ()` --> src/main.rs:5:13 | 5 | let _ = fn1 as *const (); | ^^^^^^^^^^^^^^^^ help: did you mean to invoke the function?: `fn1() as *const ()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#fn_to_numeric_cast_any note: the lint level is defined here --> src/main.rs:1:9 | 1 | #![warn(clippy::fn_to_numeric_cast_any)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: casting function pointer `fn1` to `*mut ()` --> src/main.rs:6:13 | 6 | let _ = fn1 as *mut (); | ^^^^^^^^^^^^^^ help: did you mean to invoke the function?: `fn1() as *mut ()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#fn_to_numeric_cast_any I expected to see this happen: no warning
Version
rustc -vV rustc 1.79.0-nightly (9d79cd5f7 2024-04-05) binary: rustc commit-hash: 9d79cd5f79e75bd0d2083260271307ce9acd9081 commit-date: 2024-04-05 host: aarch64-apple-darwin release: 1.79.0-nightly LLVM version: 18.1.2 Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have