Skip to content

Commit

Permalink
Auto merge of #104455 - the8472:dont-drain-on-drop, r=Amanieu
Browse files Browse the repository at this point in the history
Don't drain-on-drop in DrainFilter impls of various collections.

This removes drain-on-drop behavior from various unstable DrainFilter impls (not yet for HashSet/Map) because that behavior [is problematic](rust-lang/rust#43244 (comment)) (because it can lead to panic-in-drop when user closures panic) and may become forbidden if [this draft RFC passes](rust-lang/rfcs#3288).

closes #101122

[ACP](rust-lang/libs-team#136)

affected tracking issues
* #43244
* #70530
* #59618

Related hashbrown update: rust-lang/hashbrown#374
  • Loading branch information
bors committed Jun 15, 2023
2 parents 5e0ac4a + 0e9efe7 commit 1042e8d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/pass/btreemap.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@revisions: stack tree
//@[tree]compile-flags: -Zmiri-tree-borrows
//@compile-flags: -Zmiri-strict-provenance
#![feature(btree_drain_filter)]
#![feature(btree_extract_if)]
use std::collections::{BTreeMap, BTreeSet};
use std::mem;

Expand Down Expand Up @@ -49,8 +49,8 @@ pub fn main() {
}
test_all_refs(&mut 13, b.values_mut());

// Test forgetting the drain.
let mut d = b.drain_filter(|_, i| *i < 30);
// Test forgetting the extractor.
let mut d = b.extract_if(|_, i| *i < 30);
d.next().unwrap();
mem::forget(d);
}

0 comments on commit 1042e8d

Please sign in to comment.