Object safety is a (necessary) thorn in my side, because I work with unsized types regularly (so using
where Self: Sized to make a trait object-safe means these unsized types do not have these trait methods). These types are not trait objects. They are unsized types like
[T], and most importantly, extern types.
My understanding of object safety is that
where Self: Sized is really just a blunt hammer for checking whether or not
Self is a trait object. If some trait existed (say,
IsNotTraitObject) that was (auto) implemented for all non-trait objects, this could be relaxed to
where Self: IsNotTraitObject. This would allow unsized types (that aren’t trait objects, like extern types) to implement trait methods, and would really simplify my life (and hopefully the lives of my fellow FFI developers).
I don’t want to get hung up on the bikeshed-able details (e.g., naming, whether this should be an
IsNotTraitObject trait (with a negative or positive where clause), etc.).
Have there been any past attempts at pursuing something like this? Are there any pitfalls I’m overlooking? I’d like to draft an RFC for this, but I’d like to test the waters first…