-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Vec::retain leaks items when predicate panics #52267
Copy link
Copy link
Closed
Labels
A-collectionsArea: `std::collections`Area: `std::collections`C-bugCategory: This is a bug.Category: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Metadata
Metadata
Assignees
Labels
A-collectionsArea: `std::collections`Area: `std::collections`C-bugCategory: This is a bug.Category: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Since the implementation of
Vec::retainchanged after Rust 1.25, items may not be dropped when the predicate panics.Reproduction example
Expected result
All 3
Fooinstances are dropped. The output should look like (with Rust 1.25):Actual result
Only one
Fooinstance is dropped. The output since Rust 1.26 (and with 1.27.1) is:Edited to clarify item leak (i.e. not dropped).