padlock-macros
Compile-time struct layout assertions for padlock.
This crate provides two proc-macro attributes that turn layout regressions into compile errors.
#[padlock::assert_no_padding]
Fails to compile if the struct contains any padding bytes:
use assert_no_padding;
If you add a field that causes padding, the build fails with a clear message.
#[padlock::assert_size(N)]
Fails to compile if the struct size is not exactly N bytes. Use this to prevent accidental growth or shrinkage:
use assert_size;
Both macros pass the struct definition through unchanged — they only append a hidden const assertion block. No runtime cost.
Part of padlock
padlock-cli— CLI (padlock+cargo-padlockbinaries)padlock-core— IR, analysis passes, findingspadlock-source— Source analysis (C/C++/Rust/Go)padlock-dwarf— Binary analysis (DWARF/PDB)padlock-output— Output formatters (terminal/JSON/SARIF/diff)padlock-macros— Compile-time layout assertions (this crate)