Named struct metadata

Hi everyone,

It'd be useful for our purposes if we could attach metadata to named structs. In particular, in Rust we're looking to use this information to communicate information about our discriminated unions to the garbage collector. (We could, and are at the moment, using the metadata argument to the gcroot intrinsic, but this seems to inhibit optimizations and adds a fair amount of noise to the generated IR, so we'd like to transition to an addrspace-based GC solution at some point.)

It seems to me that attaching metadata to named structs could generally be useful as a way to communicate additional ad-hoc type information to optimizers, codegen, etc., in much the same way as GCC and Clang use __attribute__ on structs.

Does anyone have opinions as to whether this is a good idea?


If you’ll search back a few months you will see that I’ve made pretty much the exact same complaint (although far less succinctly), for exactly the same use case (apparently Rust and Tart are similar in their approach to discriminated unions. :slight_smile: