I was wondering how feasible would it be to add an additional metadata value to the allocate() call of the Allocator trait, something like
meta: Option<&'static str>`
(alternatively the type could be *const () to be more general...)
This would be quite useful for example for a custom memory-leak detecting allocator to keep track of the allocation context - Box::new() could pass the type name here.
Apologies if this has been discussed before, I haven't been keeping up with the talks around custom allocators...
In practice, I think the way this is typically solved is by recording the stack trace at the point of allocation. The stack-trace implicitly includes type information (Vec::<MyType>::grow).
Yeah, getting it from the backtrace also occurred to me (and tracking allocator needs to save it anyway), but it seemed a bit clunky (different for various containers). But I guess it ends up being a better solution than additions to the alloc api...