Closed
Description
Summary
In ffi code, sometimes std defines types that may have incompatible layout with third-party codes (windows-sys).
To be more safe, one has to check the layout of a std type and another correspond type has the same layout.
Lint Name
assertions_on_constants
Reproducer
I tried this code:
const _: () = {
assert!(8 == (7+1));
// let std_layout = Layout::new::<RawHandle>();
// let win_sys_layout = Layout::new::<HANDLE>();
// assert!(std_layout.size() == win_sys_layout.size())
// assert!(std_layout.align() == win_sys_layout.align())
};
I saw this happen:
error: `assert!(true)` will be optimized out by the compiler
--> src/internals/c.rs:53:5
|
53 | assert!(8 == (7+1));
| ^^^^^^^^^^^^^^^^^^^
|
= help: remove it
I expected to see this happen: Don't lint.
Version
rustc 1.80.0-nightly (1a7397988 2024-05-17)
binary: rustc
commit-hash: 1a7397988684934ae01a71f524bdfff24895d8cc
commit-date: 2024-05-17
host: x86_64-unknown-linux-gnu
release: 1.80.0-nightly
LLVM version: 18.1.4
Additional Labels
No response