Files
rust/library/alloc
Jonathan Brouwer 37403cbad6 Rollup merge of #161791 - jakedrew:fix/Making_and_dropping_an_empty_BTreeMap_is_not_free_161375, r=clarfonthey
Make dropping an empty BTreeMap free

rust-lang/rust#161375 ([code example](https://godbolt.org/z/v594PEsr7)) shows that drop of an empty BTree map walks the dying_next path and so is not free. I tracked this down to 7b28036c63 in 1.56.0 using godbolt’s version comparison.

When the Btree map has no root we use the ManuallyDrop to safely drop the allocator early resulting in a free drop and a `ret` instead of the `dying_next` path.

Includes codegen test which correctly catches the prior dying_next case, which I based on `uninit-aggregate-field.rs`.

Fixes rust-lang/rust#161375
2026-09-26 17:17:30 +02:00
..