about summary refs log tree commit diff
path: root/library/alloc/src/alloc.rs
AgeCommit message (Collapse)AuthorLines
2025-07-03Make __rust_alloc_error_handler_should_panic a functionDaniel Paoliello-2/+2
2025-06-16Change __rust_no_alloc_shim_is_unstable to be a functionDaniel Paoliello-3/+4
2025-04-09update cfgsBoxy-7/+7
2025-03-17Mark imports of #[rustc_std_internal_symbol] items with this attributebjorn3-3/+8
This ensures that they will be correctly mangled in a future commit.
2025-03-07Fully test the alloc crate through alloctestsbjorn3-15/+3
For the tests that make use of internal implementation details, we include the module to test using #[path] in alloctests now.
2025-02-25More precisely document `Global::deallocate()`'s safety.Kevin Reid-2/+8
There is a subtlety which "other conditions must be upheld by the caller" does not capture: `GlobalAlloc`/`alloc::dealloc()` require that the provided layout will be *equal*, not just that it "fits", the layout used to allocate. This is always true here due to how `allocate()`, `grow()`, and `shrink()` are implemented (they never return a larger allocation than requested), but that is a non-local property of the implementation, so it should be documented explicitly.
2025-02-09Mark extern blocks as unsafeMichael Goulet-3/+3
2025-01-03turn rustc_box into an intrinsicRalf Jung-1/+1
2024-12-04Move some alloc tests to the alloctests cratebjorn3-3/+0
Unit tests directly inside of standard library crates require a very fragile way of building that is hard to reproduce outside of bootstrap.
2024-11-24fix `Allocator` method names in `alloc` free function docsm-4/+4
2024-11-11Check for null in the `alloc_zeroed` exampleJosh Stone-1/+4
We should demonstrate good behavior, just like #99198 did for `alloc`.
2024-09-17read_volatile __rust_no_alloc_shim_is_unstable in alloc_zeroedBen Kimock-1/+7
2024-09-11make basic allocation functions track_caller in Miri for nicer backtracesRalf Jung-0/+13
2024-08-14apply #[optimize(size)] to #[cold] ones and part of the panick machineryThe 8472-0/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-5/+3
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-26Fix doc nitsJohn Arundel-5/+5
Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits. https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-06-22Replace `WriteCloneIntoRaw` with `CloneToUninit`.Kevin Reid-26/+0
2024-03-20step cfgsMark Rousskov-3/+2
2024-03-05Rollup merge of #122018 - RalfJung:box-custom-alloc, r=oli-obkMatthias Krüger-0/+2
only set noalias on Box with the global allocator As discovered in https://github.com/rust-lang/miri/issues/3341, `noalias` and custom allocators don't go well together. rustc can now check whether a Box uses the global allocator. This replaces the previous ad-hoc and rather unprincipled check for a zero-sized allocator. This is the rustc part of fixing that; Miri will also need a patch.
2024-03-05only set noalias on Box with the global allocatorRalf Jung-0/+2
2024-03-02const_eval_select: make it safe but be careful with what we expose on stable ↵Ralf Jung-0/+1
for now
2024-01-13libs: use `assert_unchecked` instead of intrinsicjoboet-3/+3
2023-11-28Add proper cfgsr0cky-0/+3
2023-10-29Increase the reach of panic_immediate_abortBen Kimock-1/+8
2023-08-28Rollup merge of #115280 - RalfJung:panic-cleanup-triple-backtrace, r=AmanieuMatthias Krüger-3/+4
avoid triple-backtrace due to panic-during-cleanup Supersedes https://github.com/rust-lang/rust/pull/115020 Cc https://github.com/rust-lang/rust/issues/114954 r? ``@Amanieu``
2023-08-27avoid triple-backtrace due to panic-during-cleanupRalf Jung-3/+4
2023-08-19Correct and expand documentation of `handle_alloc_error` and ↵Kevin Reid-6/+19
`set_alloc_error_hook`. Add the following facts: * `handle_alloc_error` may panic instead of aborting. * 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.
2023-07-24remove additional [allow(unused_unsafe)]James Dietz-1/+0
2023-07-12Flip cfg's for bootstrap bumpMark Rousskov-21/+0
2023-06-16remove box_free and replace with drop implDrMeepster-2/+5
2023-05-30Bump to latest beta compilerMark Rousskov-2/+0
2023-05-11Prevent insta-stable no alloc shim supportbjorn3-1/+11
You will need to add the following as replacement for the old __rust_* definitions when not using the alloc shim. #[no_mangle] static __rust_no_alloc_shim_is_unstable: u8 = 0;
2023-04-25Revert "Report allocation errors as panics"Matthias Krüger-75/+9
This reverts commit c9a6e41026d7aa27d897fb83e995447719753076.
2023-04-25Revert "Remove #[alloc_error_handler] from the compiler and library"Matthias Krüger-2/+8
This reverts commit abc0660118cc95f47445fd33502a11dd448f5968.
2023-04-25Revert "Rename -Zoom=panic to -Zoom=unwind"Matthias Krüger-2/+2
This reverts commit 4b981c26487ebe56de6b3000fcd98713804beefc.
2023-04-16Rename -Zoom=panic to -Zoom=unwindAmanieu d'Antras-2/+2
2023-04-16Remove #[alloc_error_handler] from the compiler and libraryAmanieu d'Antras-8/+2
2023-04-16Report allocation errors as panicsAmanieu d'Antras-9/+75
2023-03-28Remove ~const from allocJubilee Young-7/+1
2023-01-14Remove various double spaces in source comments.André Vennberg-2/+2
2023-01-03Rollup merge of #106045 - RalfJung:oom-nounwind-panic, r=AmanieuMichael Goulet-1/+14
default OOM handler: use non-unwinding panic, to match std handler The OOM handler in std will by default abort. This adjusts the default in liballoc to do the same, using the `can_unwind` flag on the panic info to indicate a non-unwinding panic. In practice this probably makes little difference since the liballoc default will only come into play in no-std situations where people write a custom panic handler, which most likely will not implement unwinding. But still, this seems more consistent. Cc `@rust-lang/wg-allocators,` https://github.com/rust-lang/rust/issues/66741
2023-01-02default OOM handler: use non-unwinding panic (unless -Zoom=panic is set), to ↵Ralf Jung-1/+14
match std handler
2022-12-30Replace libstd, libcore, liballoc in line comments.jonathanCogan-1/+1
2022-12-28Update bootstrap cfgPietro Albini-13/+0
2022-11-06cfg-step codeMark Rousskov-8/+4
2022-10-31Rewrite implementation of `#[alloc_error_handler]`Amanieu d'Antras-6/+5
The new implementation doesn't use weak lang items and instead changes `#[alloc_error_handler]` to an attribute macro just like `#[global_allocator]`. The attribute will generate the `__rg_oom` function which is called by the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom` function is defined in any crate then the compiler shim will call `__rdl_oom` in the alloc crate which will simply panic. This also fixes link errors with `-C link-dead-code` with `default_alloc_error_handler`: `__rg_oom` was previously defined in the alloc crate and would attempt to reference the `oom` lang item, even if it didn't exist. This worked as long as `__rg_oom` was excluded from linking since it was not called. This is a prerequisite for the stabilization of `default_alloc_error_handler` (#102318).
2022-10-11rename rustc_allocator_nounwind to rustc_nounwindRalf Jung-4/+8
2022-08-12Adjust cfgsMark Rousskov-3/+3
2022-07-26codegen: use new {re,de,}allocator annotations in llvmAugie Fackler-1/+4
This obviates the patch that teaches LLVM internals about _rust_{re,de}alloc functions by putting annotations directly in the IR for the optimizer. The sole test change is required to anchor FileCheck to the body of the `box_uninitialized` method, so it doesn't see the `allocalign` on `__rust_alloc` and get mad about the string `alloca` showing up. Since I was there anyway, I added some checks on the attributes to prove the right attributes got set. While we're here, we also emit allocator attributes on __rust_alloc_zeroed. This should allow LLVM to perform more optimizations for zeroed blocks, and probably fixes #90032. [This comment](https://github.com/rust-lang/rust/issues/24194#issuecomment-308791157) mentions "weird UB-like behaviour with bitvec iterators in rustc_data_structures" so we may need to back this change out if things go wrong. The new test cases require LLVM 15, so we copy them into LLVM 14-supporting versions, which we can delete when we drop LLVM 14.
2022-07-14add missing null ptr check in alloc exampleRalf Jung-1/+4