rust/library/alloc/src
Matthias Krüger 922b827b8c
Rollup merge of #115007 - kpreid:alloc, r=Mark-Simulacrum
Correct and expand documentation of `handle_alloc_error` and `set_alloc_error_hook`.

The primary goal of this change is to remove the false claim that `handle_alloc_error` always aborts; instead, code should be prepared for `handle_alloc_error` to possibly unwind, and be sound under that condition.

I saw other opportunities for improvement, so I have added all the following information:

* `handle_alloc_error` may panic instead of aborting. (Fixes #114898)
* What happens if a hook returns rather than diverging.
* A hook may panic. (This was already demonstrated in an example, but not stated in prose.)
* A hook must be sound to call — it cannot assume that it is only called by the runtime, since its function pointer can be retrieved by safe code.

I've checked these statements against the source code of `alloc` and `std`, but there may be nuances I haven't caught, so a careful review is welcome.
2023-08-27 09:45:18 +02:00
..
alloc run alloc benchmarks in Miri and fix UB 2022-11-07 10:34:04 +01:00
boxed More IS_ZST in library 2023-04-21 16:29:27 -07:00
collections Avoid using ptr::Unique in LinkedList code 2023-07-30 11:21:24 -04:00
ffi fixed documentation of from<CString> for Rc<CStr>: Arc -> Rc 2023-07-02 10:07:52 +06:00
raw_vec Add a unit test for zero-sized types in RawVec. 2021-11-26 19:30:45 +11:00
rc Introduce alloc::::UniqueRc 2023-06-19 12:24:06 -07:00
slice ignore core, alloc and test tests that require unwinding on panic=abort 2023-06-13 15:53:24 +02:00
sync Add Arc::into_inner for safely discarding Arcs without calling the destructor on the inner type. 2023-01-22 01:43:25 +09:00
testing Share testing utilities with non-btree test cases 2022-05-02 10:07:50 +02:00
vec Documentation: Fix Stilted Language in Vec->Indexing 2023-07-29 13:20:45 -07:00
alloc.rs Correct and expand documentation of handle_alloc_error and set_alloc_error_hook. 2023-08-19 13:27:03 -07:00
borrow.rs enable rust_2018_idioms for doctests 2023-05-07 00:12:29 +03:00
boxed.rs avoid transmuting Box when we can just cast raw pointers instead 2023-08-14 10:15:25 +02:00
fmt.rs enable rust_2018_idioms for doctests 2023-05-07 00:12:29 +03:00
lib.rs Bump cfg(bootstrap) 2023-08-23 20:05:14 -04:00
macros.rs Remove or justify use of #[rustc_box] 2023-02-27 20:54:55 -05:00
raw_vec.rs Eliminate ZST allocations in Box and Vec 2023-07-13 15:00:53 +01:00
rc.rs Replace version placeholders with 1.73.0 2023-08-22 06:57:00 -04:00
slice.rs Add suggestion for some #[deprecated] items 2023-08-21 12:51:51 +03:00
str.rs [nit] Fix a comment typo. 2023-08-15 14:26:14 -05:00
string.rs string.rs: remove "Basic usage" text 2023-08-02 11:17:57 +02:00
sync.rs Replace version placeholders with 1.73.0 2023-08-22 06:57:00 -04:00
task.rs Updating Wake example to use new 'pin!' macro 2023-04-25 13:50:50 +02:00
tests.rs fix an alloc test 2023-03-03 17:47:48 +00:00