diff options
| author | bors <bors@rust-lang.org> | 2025-03-03 03:41:03 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-03-03 03:41:03 +0000 |
| commit | 81d8edc2000aa38b08ad09fce22d90f1990b6459 (patch) | |
| tree | 5d8ec74d6b4e87f59d322a08c024abb94ddcae75 /library/alloc/src/alloc.rs | |
| parent | daf59857d6d2b87af4b846316bf1561a6083ed51 (diff) | |
| parent | 59fe0c77bb87da1b42cbb6bcc81c2ca90a8e6493 (diff) | |
Auto merge of #137900 - matthiaskrgr:rollup-rvan5ao, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #137375 (Minor internal comments fix for `BufRead::read_line`) - #137641 (More precisely document `Global::deallocate()`'s safety.) - #137755 (doc: update Wasmtime flags) - #137851 (improve `simd_select` error message when used with invalid mask type) - #137860 (rustc_target: Add msync target feature and enable it on powerpcspe targets) - #137871 (fix `RangeBounds::is_empty` documentation) - #137873 (Disable `f16` on Aarch64 without `neon`) - #137876 (Adjust triagebot.toml entries for `rustc_mir_build/src/builder/`) - #137883 (edit mailmap) - #137886 (`name()` and `trimmed_name()` for `stable_mir::crate_def::DefId`) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/alloc/src/alloc.rs')
| -rw-r--r-- | library/alloc/src/alloc.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index e686a02f29b..3bfdc68dcda 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -264,8 +264,14 @@ unsafe impl Allocator for Global { #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) { if layout.size() != 0 { - // SAFETY: `layout` is non-zero in size, - // other conditions must be upheld by the caller + // SAFETY: + // * We have checked that `layout` is non-zero in size. + // * The caller is obligated to provide a layout that "fits", and in this case, + // "fit" always means a layout that is equal to the original, because our + // `allocate()`, `grow()`, and `shrink()` implementations never returns a larger + // allocation than requested. + // * Other conditions must be upheld by the caller, as per `Allocator::deallocate()`'s + // safety documentation. unsafe { dealloc(ptr.as_ptr(), layout) } } } |
