Currently custom allocators and custom panic runtimes must provide their code to rustc in a different and type-unsafe way.
I suggest that rust should provide the possibility to provide them with for example:
AFAICT, these are basically traits? I’d much prefer to just keep the trait keyword in that case. Is the only difference that they can be implemented only once? You could say something like unique trait or api trait.
Mechanisms similar to the here proposed providable have been mentioned in context of the std refactoring. There where mentioned ideas of some think like a header for a crates interface (possible automatic generated), creates with “parameters” allowing part of them to be specified out side and the singular (module?) interfaces I mentioned (kind of a more general approach to your pre-RFC).
All of them have in common that they want to help with situations of dependency inversion, like this pre-RFC
Wrt. to the discussion @susurrus asked if it isn’t possible with a annotation like #[privides(item.path)] and #[providables] which I think makes a lot of sense. While the approach of having a “providable” trait makes sense for e.g. alloc, it might be to limited for some parts (where you want to abstract over platform specific code, but this platform specific code currently provides a struct/enum (e.g. through having multiple #![cfg(plattform)] branches). Additionally there is the “problem” that a additional context dependent keyword(1) is needed which not everyone likes.
(1) in addition to union, whichs RFC was recently approved if I’m not mistaken
I just noticed hat a annotation works fine with specifing structs, enums, impl but not with specifing that e.g. some other trait has to be implemented for it. Also it won’t work with sized/unsized wrt. cases where there is a public struct where the fileds determining this are all private (aka they won’t be part of the definition marked with #![providable]).