Repository navigation
Run element destructors on refcount map iterator erase - #585
Open
perfloop-agent wants to merge 2 commits into
Open
perfloop-agent wants to merge 2 commits into
perfloop-agent wants to merge 2 commits into
Conversation
Signed-off-by: Perfloop Agent <agent@perfloop.ai> Signed-off-by: Tomás Senart <ts@perfloop.ai>
Signed-off-by: Perfloop Agent <agent@perfloop.ai> Signed-off-by: Tomás Senart <ts@perfloop.ai>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refcount map iterator erase now calls the stored key and mapped-value C++ destructors before returning. Releasing Rust storage is not a substitute for these explicit callbacks, and unused iterator copies can keep that storage alive.
Both mutable and const iterator rules pass a finalizer to
Map::erase. The runtime removes the entry from its links and ordered index and ends its borrows before invoking the finalizer. The rules reuse the existing destructor dispatch, so trivial key and value types need no new trait bounds. The rule-writing documentation explains this boundary.Testing
On Linux Release and Debug, lit reports 1057 passed and 15 expected failures for
tests/unit, 76 passed fortests/ub, and 20 passed fortests/multi-fileper build, with no unexpected failures or skips. With only the new test files added to the base commit, unit lit reports 1056 passed, 15 expected failures and 1 failure:map_erase_destructor.cpp/refcount, whose generated output lacks the destructor hooks.In both builds, the runtime tests report 70 passed, 0 failed and 0 ignored; the macro tests report 1 passed in the compile-fail runner and 22 passed in the control-flow runner, with 0 failed or ignored in either runner. Both crates report 0 doctests.
ninja formatcompleted successfully without changing tracked files.tests/unit/map_erase_destructor.cppcompares native C++ with generated code for record/record, record/int, int/record and int/int entries. It checks callbacks at return and after unused iterator copies leave scope, plus successor, size, remaining element order and untouched live positions. The existing map fixtures check trivial-type behavior and key-copy counts.tests/unit/map_erase_destructor.cppremains an expected failure in the unsafe model; this repair is limited to refcount iterator erase. Whole-map destruction is unchanged. Unused iterator copies may still retain Rust storage.Case and evidence
Made by Perfloop. Human sponsor: Tomás Senart. To ask for a change, comment or review in plain words. How Perfloop handles pull requests.