Closed
Description
Summary
.
Lint Name
transmutes_expressible_as_ptr_casts
Reproducer
I tried this code:
fn main() {
fn f() {}
let _x: u8 = unsafe {
*std::mem::transmute::<fn(), *const u8>(f)
};
}
I saw this happen:
warning: transmute from `fn()` to `*const u8` which could be expressed as a pointer cast instead
--> src/main.rs:5:10
|
5 | *std::mem::transmute::<fn(), *const u8>(f)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `f as *const u8`
|
Suggestion does not compile:
The following errors were reported:
error[E0614]: type `fn() {main::f}` cannot be dereferenced
--> src/main.rs:5:9
|
5 | *f as *const u8
| ^^
error: aborting due to previous error
Version
rustc 1.69.0-nightly (44cfafe2f 2023-03-03)
binary: rustc
commit-hash: 44cfafe2fafe816395d3acc434663a45d5178c41
commit-date: 2023-03-03
host: x86_64-unknown-linux-gnu
release: 1.69.0-nightly
LLVM version: 15.0.7
Additional Labels
No response