4 ms·
This exists, provided you compile with the (default) unwinding panics https://doc.rust-lang.org/std/panic/fn.catch_unwind.html https://doc.rust-lang.org/std/pa
by gpm 6y ago
This exists, provided you compile with the (default) unwinding panics
https://doc.rust-lang.org/std/panic/fn.catch_unwind.html https://doc.rust-lang.org/std/panic/fn.catch_unwind.html
- estebank 6y agoThat is still something that happens at runtime, not compile-time. What the kernel would need is not only for the fallible alloc APIs (like Box::try_new) to be expanded to cover all their needs, but also to be able to remove the ability to use the infallible/panicky ones (like Box::new) to ensure, at compile time, that panic will never be called.
- chrismorgan 6y ago> Note that this function may not catch all panics in Rust. A panic in Rust is not always implemented via unwinding, but can be implemented by aborting the process as well. This function only catches unwinding panics, not those that abort the process. The most notable way this can go wrong in pure Rust code is that panic-while-panicking aborts. So you have to be careful that your destructor can never panic.