> - Rust lets you catch panics at thread boundaries (one of the most controversial decisions in Rust; I think it was the right one, but I definitely acknowledge that it's a big tradeoff).
(Unstable) Rust lets you catch panics anywhere. You have to be able to do that for sane FFI - as you know (but perhaps other readers don't), a panic that unwinds across the Rust/C FFI boundary causes undefined behavior, so AIUI extern functions in Rust should all look like:
(Actually, checking several libraries off the top of my head that expose C APIs, most don't do this -- probably because std::catch_panic is relatively new.)
Let's hope developers don't abuse std::catch_panic for regular Rust code. Maybe a lint that warns about uses outside of an extern fn is worth having.
This has been taken into account on multiple occasions, and the developers have introduced mechanisms to prevent people from treating `recover` as a general error-handling mechanism: https://github.com/rust-lang/rfcs/pull/1323
Yes, I know pcwalton is and was heavily involved in Rust development. That's why I parenthetically stated that he probably already knew these things (catch_panic is actually newer than the bulk of pcwalton' work on Rust's language and standard library, so there is a small chance he doesn't know about it).
It's still worth noting this point though, for the benefit of other readers.
pcwalton has been heavily involved with Rust since long before anyone remembers, but you're confusing him with Graydon Hoare, Rust's true original author.
(Unstable) Rust lets you catch panics anywhere. You have to be able to do that for sane FFI - as you know (but perhaps other readers don't), a panic that unwinds across the Rust/C FFI boundary causes undefined behavior, so AIUI extern functions in Rust should all look like:
(Actually, checking several libraries off the top of my head that expose C APIs, most don't do this -- probably because std::catch_panic is relatively new.)Let's hope developers don't abuse std::catch_panic for regular Rust code. Maybe a lint that warns about uses outside of an extern fn is worth having.