Skip to content

Fix retain_mut panic and drop behavior - #446

Closed
LunaMeerkats wants to merge 1 commit into
servo:v2from
LunaMeerkats:agent/fix-retain-mut-panic-safety
Closed

Fix retain_mut panic and drop behavior#446
LunaMeerkats wants to merge 1 commit into
servo:v2from
LunaMeerkats:agent/fix-retain-mut-panic-safety

Conversation

@LunaMeerkats

Copy link
Copy Markdown

Summary

  • make SmallVec::retain_mut reuse ExtractIf's existing panic backshift guard
  • preserve unprocessed elements when the predicate panics
  • stop visiting later elements and repair the vector when dropping a rejected element panics
  • cover both inline and spilled storage for predicate and destructor panics

The issue claim mentioned a direct port of Vec::retain_mut's guard. During review I found that ExtractIf already implements the required unwind repair, so this version reuses that guard instead of adding a second unsafe implementation.

Reproduction and validation

All four new tests fail independently on pinned base b675995e70144f03fd5c5e0ce56d3f98115d0950 and pass with this change.

  • cargo build --verbose
  • cargo test --verbose — 68 unit + 1 integration + 6 doctests passed
  • cargo test --verbose --features serde — 69 unit + 1 integration + 6 doctests passed
  • cargo test --verbose --features malloc_size_of — 68 unit + 1 integration + 6 doctests passed
  • cargo check --verbose --no-default-features
  • cargo fmt --all -- --check
  • git diff HEAD^ --check

A strict all-target Clippy run is blocked by warnings/lints also reproduced on the pinned base; a library Clippy run passes when allowing those exact baseline lints. All-features and Miri were not run because the local stable setup lacks the required nightly components. One first Serde doctest attempt was blocked by Windows Application Control (os error 4551); the exact retry and a later serial rerun both passed completely.

Draft PR #443 also touches retain_mut but does not address #444, so it may create a rebase conflict if merged first.

Authorship/provenance: this patch and pull request were prepared autonomously by OpenAI Codex under the LunaMeerkats account.

Fixes #444

@alejandro-vaz

Copy link
Copy Markdown
Collaborator

AI contributions are not allowed in any @servo repository as indicated on the contributing guidelines

https://book.servo.org/contributing/getting-started.html#ai-contributions

this PR will subsequently be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix retain_mut panic/drop behavior to match vec API

2 participants