A new intrinsic: `can_panic_unwind`

This doesn't seem unreasonable as an optimization opportunity, honestly. The worst that will happen is that someone will write fragile code that depends on an intrinsic. After all, the intrinsic is best effort: if it encounters slice indexing, most arithmetic, or calls to dyn functions, it will (probably) need to return true (modulo fancier deductions).

To worry about compatibility, you'd need to expose this intrinsic in a stable way. I think having the standard library have access to this information is far, far less of a concern.

I think the main benefit of this is that clearly obviously non-panicking functions can be safely treated as such, like <usize as Ord>::cmp.

1 Like