In https://github.com/rust-lang/rust/pull/61114#issuecomment-495676864 @RalfJ wrote:
The desired interaction with unsized types is not really clear. One custom DST are a thing, I doubt we want Stacked Borrows to run the arbitrary user code to compute the size...
While I can't comment on the stacked borrows interaction, it made me wonder whether the hooks provided by custom DSTs (size_of_val in this case, but others too) should be const fns? That would make them reasonable to evaluate in a stacked borrows, I'd think. It is somewhat close to the "using const fn to enforce code to be well-behaved" school of design which I've never been a big fan of, but it really doesn't seem so unreasonable to say that
size_of_val should always be const fn.
that is an interesting idea!
it'd still be a huge pain to "call back" to the interpreter in the middle of, say, doing a type-based traversal of some value