Skip to content

Commit 1042e8d

Browse files
committed
Auto merge of #104455 - the8472:dont-drain-on-drop, r=Amanieu
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
2 parents 5e0ac4a + 0e9efe7 commit 1042e8d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/pass/btreemap.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@revisions: stack tree
22
//@[tree]compile-flags: -Zmiri-tree-borrows
33
//@compile-flags: -Zmiri-strict-provenance
4-
#![feature(btree_drain_filter)]
4+
#![feature(btree_extract_if)]
55
use std::collections::{BTreeMap, BTreeSet};
66
use std::mem;
77

@@ -49,8 +49,8 @@ pub fn main() {
4949
}
5050
test_all_refs(&mut 13, b.values_mut());
5151

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

0 commit comments

Comments
 (0)