Pre-RFC improved ergonomics for `!`
MusicalNinjaDad:
Or rather, the implicit conversion will only take effect if it is safe to do so.
How is this determined? Imagine that someone had UninhabitedErr<T, E>(Result<T, E>) whose safety invariant is that E is an uninhabited 1-aligned ZST, as enforced by unsafe constructors?
Yes, this is an absurd scenario with a useless type, but it would then be unsound to coerce UninhabitedErr<T, !> to a general Uninhabited<T, E> where E may be a non-ZST or inhabited type.
I worry that determining whether adding a new coercion of this sort which affects existing code could be unsound, so it’d probably need to be opt-in… in which case I’m not sure that the solution would address all your wishes.
(Maybe UninhabitedErr could be seen as unsound for relying on negative reasoning about what coercions will be possible in future Rust versions.)
(Note: I have my “library author” hat on, I’m not a compiler dev. So, I’m used to being very paranoid to attempt to write bulletproof unsafe code, while the compiler devs probably have a better grasp of what sorts of code actually exist out there, and the language does occasionally make breaking changes after a lot of communication.)
Discussion in the ATmosphere