3 ms·
It's not unsafe that causes unsafety, it's how you wield it. - Do you know your invariants? - Have you documented them? - If using unsafe block, have you ass
by Ygg2 2y ago
It's not unsafe that causes unsafety, it's how you wield it.
- Do you know your invariants?
- Have you documented them?
- If using unsafe block, have you asserted them or guaranteed that they hold for any input?
Granted, Rust is kind of mediocre at teaching you this. It raises warning for unsafe fn without safety documentation block, but not when omittin safety comments in unsafe blocks.
- gpm 2y agoFor what it's worth, clippy has an optional lint to detect undocumented unsafe blocks: https://rust-lang.github.io/rust-clippy/master/index.html#undocumented_unsafe_blocks https://rust-lang.github.io/rust-clippy/master/index.html#un... Edit: And it turns out it's enabled as a warning in this repo.