Stream: t-lang/wg-unsafe-code-guidelines

Topic: custom DST size/align/etc. as const fns?

rkruppe (May 24 2019 at 15:45, on Zulip):

In @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.

RalfJ (May 24 2019 at 15:58, on Zulip):

that is an interesting idea!

RalfJ (May 24 2019 at 15:58, on Zulip):

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

Last update: Jul 02 2020 at 12:40UTC