Make dropping an empty BTreeMap free - #161791
Conversation
|
r? @mati865 rustbot has assigned @mati865. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Nice, but that requires libs review. r? rust-lang/libs |
|
Hmm, maybe not https://godbolt.org/z/Wzhqh9jre. |
| use std::collections::BTreeMap; | ||
|
|
||
| // CHECK-LABEL: @drop_btree | ||
| // CHECK-NOT: dying_next |
There was a problem hiding this comment.
I personally would rather this check for calls to dealloc rather than dying_next, since I this test could easily become worthless if this method is renamed.
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
|
☔ The latest upstream changes (presumably #161990) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
#161375 (code example) shows that drop of an empty BTree map walks the dying_next path and so is not free. I tracked this down to 7b28036 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
retinstead of thedying_nextpath.Includes codegen test which correctly catches the prior dying_next case, which I based on
uninit-aggregate-field.rs.Fixes #161375