Skip to content

Commit 5170dc7

Browse files
Update the description of alloc error handling
Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
1 parent 03d6ee9 commit 5170dc7

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

posts/2023-03-09-Rust-1.68.0.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,12 @@ subject to the normal borrow checker to make sure it can't outlive that local.
9595

9696
When allocation fails in Rust, APIs like `Box::new` and `Vec::push` have no way
9797
to indicate that failure, so some divergent execution path needs to be taken.
98-
When using the `std` crate, the program will print to `stderr` and abort. But
99-
with `#![no_std]` and the `alloc` crate, it was required to provide a
100-
`#[alloc_error_handler]` function, similar to `#[panic_handler]`, but that
101-
attribute is still unstable.
98+
When using the `std` crate, the program will print to `stderr` and abort.
99+
As of Rust 1.68.0, binaries which include `std` will continue to have
100+
this behavior. Binaries which do not include `std`, only including `alloc`, will now `panic!`
101+
on allocation failure, which may be further adjusted via a `#[panic_handler]` if desired.
102102

103-
Now in Rust 1.68.0, a default handler is provided which turns that `alloc` error
104-
into a `panic!`, which may be processed in a `#[panic_handler]` like any other.
103+
In the future, it's likely that the behavior for `std` will also be changed to match that of `alloc`-only binaries.
105104

106105
### Stabilized APIs
107106

0 commit comments

Comments
 (0)