1
Fork 0

Auto merge of #118460 - the8472:fix-vec-realloc, r=saethlin

Fix in-place collect not reallocating when necessary

Regression introduced in https://github.com/rust-lang/rust/pull/110353.
This was [caught by miri](https://rust-lang.zulipchat.com/#narrow/stream/269128-miri/topic/Cron.20Job.20Failure.20.28miri-test-libstd.2C.202023-11.29/near/404764617)

r? `@saethlin`
This commit is contained in:
bors 2023-12-06 08:45:11 +00:00
commit 15bb3e204a
2 changed files with 35 additions and 7 deletions

View file

@ -1213,6 +1213,14 @@ fn test_in_place_specialization_step_up_down() {
assert_ne!(src_bytes, sink_bytes);
assert_eq!(sink.len(), 2);
let mut src: Vec<[u8; 3]> = Vec::with_capacity(17);
src.resize( 8, [0; 3]);
let iter = src.into_iter().map(|[a, b, _]| [a, b]);
assert_in_place_trait(&iter);
let sink: Vec<[u8; 2]> = iter.collect();
assert_eq!(sink.len(), 8);
assert!(sink.capacity() <= 25);
let src = vec![[0u8; 4]; 256];
let srcptr = src.as_ptr();
let iter = src