Idea: global static variables extendable at compile-time

I haven't done anything with this since my last post!

If you're interested in going further with this, I think both seeing how well linkme works in practice (the inventory crate currently uses ctor, but it should be able to use linkme instead, hopefully?), and going ahead writing a (pre) RFC for including something like linkme::distributed_slice in std are good next steps.

I previously wrote Pre-RFC: Add language support for global constructor functions, and a lot of the background information and motivation could probably be copied into a Pre-RFC for adding this.

I'm interested in working on this as well, but I've done very little since that last thread finished (with the conclusion that this is a safer and more minimal way to go). If you're willing to carry this further, that would be awesome! I probably won't initiate or write much, but if you've got any questions I can try and help.


Edit: After writing this, I've looked into the current state of things a bit more. Looks like linkme is intended as an alternative to inventory, not as a new backend for it.

This is a tracking issue for switching typetag to use linkme over inventory, then: https://github.com/dtolnay/typetag/issues/15

And a partial implementation: https://github.com/dtolnay/typetag/pull/16

I think the best ways to help this forward now would either be to contribute to that (and thus add further proof that linkme is a good enough interface to add to rustc), or to work on a new Pre-RFC for adding the feature.

1 Like