Description
The basic issue is that in certain contexts it's deemed very important to enforce that all allocation errors are handled explicitly so there are no unanticipated failure modes. For en example of this, see Linus's response in https://lore.kernel.org/lkml/CAHk-=wh_sNLoz84AUUzuqXEsYH35u=8HV3vK-jbRbJ_B-JjGrg@mail.gmail.com/.
The Rust standard library doesn't help help one keep track of errors, because many functions call the global handle_alloc_error
to abort the thread/program. Note that this affects not only functions dealing with allocated data (Box, Vec, etc.), but also more innocent-looking functions like slice::sort
, which just allocate temporaries so there's no hint in the type signature.
I would like to see the problem solved, but not in a way that just means such programs ignore alloc
and hand-roll their own abstractions, because I think that would result in unnecessary and tragic ecosystem fragmentation.
My tentative plan is just add a enabled-by-default Cargo feature, without which handle_alloc_error
and friends simply don't exist. I have started implanting that in rust-lang/rust#84266.