It's important for AllocError to be a ZST, so Result<NonNull<u8>, AllocError> is just a nullable *mut u8. Whenever you use the GlobalAlloc/Allocator APIs, which are those that return AllocError, you necessarily have the layout already in order to provide it.
Rather, this is an argument that try_new should also return TryReserveError (or a similar error) which wraps AllocError with a Layout. Modulo naming being hard, of course.
Personally, with the (pending) decision to move the isize::MAX limit into Layout, I think the richer error type should be (modulo naming being hard)
enum CollectionAllocError {
/// The requested size is to big for a Rust object.
LayoutError,
/// The requested allocation failed.
AllocError(Layout),
}
There's (in face of custom allocators) not really a difference between "capacity overflow" and an allocation error.
(Disclaimer: this is my own opinion, not that of wg-allocators)
Just report an error or write a log with layout. I want to tell the user or client not only there is an alloc error, but also the required layout when the error occurred.