First of all, even if that solved the problem of how to lay out these smart pointers and the like (it doesn’t for Arc and Rc), that doesn’t explain how you would construct a Box<RST>. (more on this below in reply to @duanebyer)
But there’s an even more fundamental problem with any smart pointer that isn’t a newtype around a pointer-to-T. Rc, for example, isn’t a *const T, it’s a *const RcBox<T> (I’m glossing over non-nullness for exposition), where RcBox<T> is roughly { strong_count: usize, weak_count: usize, value: T }. If you only specified what *const RST means, how do make sense of *const RcBox<RST>? The right answer is to “float out” the metadata (storing the unsized value in the RcBox and putting the metadata into Rc), but how could you arrive at that conclusion under this proposal. If anything, I would expect that the author of RcBox can specify a completely different and incompatible “reference specialization” for &RcBox<_> (and therefore, for *const RcBox<T>), but that would completely break Rc (and Arc, btw).
The only way I can see all this working out is if we analyze the definition of the RST and extract the metadata from that and apply it to every kind of pointer as usual – but
- if that worked, we wouldn’t need separate definitions of &RST and &mut RST either, and
- if we do that, we’re back to the usual custom-DST proposals, we just invented special magic “by-example” syntax for describing the metadata instead of using e.g. the trait system as previously proposed
I don’t see how that works. Box needs to own heap-allocated memory, constructing values behind references doesn’t give you that. You can of course manually and unsafely allocate some memory and initialize it, but then how do you construct the metadata to go along with the pointer? (The custom DST proposals has some way to construct a fat raw pointer from a data pointer and metadata, and it’s completely natural. I don’t see how that carries over to RSTs.)
Granted, existing DSTs have a similar problem, e.g. Box<str> or Rc<str> only work because there’s unsafe code in the standard library for those specific combinations of types. But at least the DST perspective makes it obvious what AnySmartPointer<AnyDst> should mean, and the custom DST proposals make it more feasible to do such constructions in user code.
Yeah the memory layout is very different (see above).
I don’t really understand this distinction. All the examples in the RFC fall under the umbrella of custom DSTs. I guess this is referring to the briefly-mentioned “extension” of allowing &RST and &mut RST to have very different representations? I don’t see motivating use cases or even many details (the section titled “extension” instead discusses reborrowing), but that road does not seem promising to me at all. It’s the complete opposite of DSTs (which make all pointers to the same type alike), and thus suffers from all the problems DSTs solve, such as enabling a wide array of smart pointers to be used automatically.