Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Afaik despite Rust not having exceptions, panic still unwinds the stack and executes 'drop'-s the same way C++ does, which means the code retains much of the machinery necessary to support exceptions.




The panic_immediate_abort feature should prevent this. build-std is the name of the feature that recompiles the Rust standard libraries with your chosen profile, so the combination of these two features should result in no unwinding code bloat.

Are all crates compatible with this feature?

A crate can add a setting in the package that says "hey if you try to build me without unwinding, cause an error, because I need unwinding to work."

I have never run into such a crate in the wild, I don't think.


It's possible for a crate to assume there will be unwinding, but given the Rust communities general attitude to exceptions it's not common.

By default, all it means is that unwinding the stack doesn't happen, so Drop implementations don't get called. Which _can_ result in bugs, but they're a fairly familiar kind: it's the same kind of fault if a process is aborted (crashes?), and it doesn't get a chance to finalise external resources.

EDIT: to clarify, the feature isn't really something crates have to opt in to support




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: