Lobsters2 min readintermediate
Rust's derive often implies inline
Summary
Rust's `#[derive]` macros automatically add `#[inline]` to generated trait implementations. While helpful for trivial code, large derived `Debug` impls can bloat binaries, and you can suppress this with a custom proc macro that uses `#[inline(never)]`.
- `#[derive]` generated impls are annotated with `#[inline]` by the compiler.
- Inlining large derived `Debug` implementations can noticeably increase binary size (e.g., ~160 KB).
- The compiler does not cap inlining of derived code, so the hint may be counter‑productive.
- A custom proc macro that adds `#[inline(never)]` can prevent the unwanted size growth.
Rust developers who care about binary size and compile‑time performance should know that derived inlining isn’t always beneficial.
6/10