What I’d like to see someday is a light-weight effect system by which you could impose constraints on all callees. One of the most important constraints would be nopanic. Neither the callee, nor any transient callees, would be allowed to panic if used:
#[effect(nopanic)]
fn foo() {
... // must not panic directly or, more importantly, indirectly!
}
The above should be uncontroversial, I hope.
A completely separate (and somewhat weird) idea, that I do not endorse btw, is some sort of panic elimination for all callees, direct and indirect. I’ve not given this any thoughts but perhaps this touches on the safe/unsafe distinction in Rust? If you, by means of this hypothetical feature, promise that you adhere to all contracts, and state that you are willing to take the consequences of all errors, then this could be a way out for you in places where you really need the last drop of performance. This means eliminating edge-case detection and resulting panicking. This is probably too weird to support of course, so I’d leave this aside.
By annotating a fn as non-panicking you are really specifying its contract explicitly.