Actually if one were to make enum variants first class types, then this special casing could be done cleanly, and even let x = Err(1); x?
would be a terminator, as x
would be inferred of type Result::Err instead of Result, and then Result::Err could implement a new "TryResidual" trait that would trigger the behavior.
I think this requires a new edition though as I think it's not backward compatible to make this inference change in general, but it might actually be a viable solution, perhaps (for older editions, macros or functions could be provided that produces the enum variant explicitly).