-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
I-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied
Description
Using the following flags
--force-warn clippy::ptr-as-ptr
this code:
pub fn main() {
unsafe {
let _: fn() = std::mem::transmute(std::ptr::null::<()>() as *const u8);
}
}
caused the following diagnostics:
Checking _a v0.1.0 (/tmp/icemaker_global_tempdir.RlzFTnosKj1Z/icemaker_clippyfix_tempdir.tE6mKU77D3m6/_a)
warning: `as` casting between raw pointers without changing their constness
--> src/main.rs:3:43
|
3 | let _: fn() = std::mem::transmute(std::ptr::null::<()>() as *const u8);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try call directly: `std::ptr::null<()>::<u8>()`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_as_ptr
= note: requested on the command line with `--force-warn clippy::ptr-as-ptr`
warning: `_a` (bin "_a") generated 1 warning (run `cargo clippy --fix --bin "_a"` to apply 1 suggestion)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.35s
However after applying these diagnostics, the resulting code:
pub fn main() {
unsafe {
let _: fn() = std::mem::transmute(std::ptr::null::<()>::<u8>());
}
}
no longer compiled:
Checking _a v0.1.0 (/tmp/icemaker_global_tempdir.RlzFTnosKj1Z/icemaker_clippyfix_tempdir.tE6mKU77D3m6/_a)
error: expected identifier, found `<`
--> src/main.rs:3:65
|
3 | let _: fn() = std::mem::transmute(std::ptr::null::<()>::<u8>());
| ^ expected identifier
error: could not compile `_a` (bin "_a" test) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `_a` (bin "_a") due to 1 previous error
Version:
rustc 1.90.0-nightly (3014e79f9 2025-07-15)
binary: rustc
commit-hash: 3014e79f9c8d5510ea7b3a3b70d171d0948b1e96
commit-date: 2025-07-15
host: x86_64-unknown-linux-gnu
release: 1.90.0-nightly
LLVM version: 20.1.8
Metadata
Metadata
Assignees
Labels
I-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied