How to prevent rust from removing a dead function?
⚓ Rust 📅 2026-02-18 👤 surdeus 👁️ 1Hey,
I have a dprint function, that basically only does println!("{:?}", self). The reason for it is, that one can't println!() in GDB, so, I want to be able to at least be able to do my_struct.dprint() (for debug print). However, Rust evidently, admittedly correctly, sees that dprint() is never used in the binary and keeps removnig it, how can I stop that?
I have lto="off", debug=true, opt-level=0 and it is still getting removed.
Thanks!
10 posts - 5 participants
🏷️ Rust_feed