Skip to content

Commit a44a059

Browse files
committed
add regression test
1 parent 60a900e commit a44a059

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

library/alloc/tests/vec.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,18 @@ fn test_from_iter_specialization_panic_during_drop_leaks() {
10941094
}
10951095
}
10961096

1097+
// regression test for issue #85322. Peekable previously implemented InPlaceIterable,
1098+
// but due to an interaction with IntoIter's current Clone implementation it failed to uphold
1099+
// the contract.
1100+
#[test]
1101+
fn test_collect_after_iterator_clone() {
1102+
let v = vec![0; 5];
1103+
let mut i = v.into_iter().peekable();
1104+
i.peek();
1105+
let v = i.clone().collect::<Vec<_>>();
1106+
assert!(v.len() <= v.capacity());
1107+
}
1108+
10971109
#[test]
10981110
fn test_cow_from() {
10991111
let borrowed: &[_] = &["borrowed", "(slice)"];

0 commit comments

Comments
 (0)