fix soundness issue in make_contiguous#79814
Conversation
|
r? @cramertj (rust-highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
this was only a perfomance issue because is_contiguous returns false if the head is 0
| #[test] | ||
| fn make_contiguous_head_to_end() { | ||
| let mut dq = VecDeque::with_capacity(3); | ||
| dq.push_front('B'); | ||
| dq.push_front('A'); | ||
| dq.push_back('C'); | ||
| dq.make_contiguous(); | ||
| let expected_tail = 0; | ||
| let expected_head = 3; | ||
| assert_eq!(expected_tail, dq.tail); | ||
| assert_eq!(expected_head, dq.head); | ||
| assert_eq!((&['A', 'B', 'C'] as &[_], &[] as &[_]), dq.as_slices()); | ||
| } |
There was a problem hiding this comment.
Do you want to write a version of this that uses Boxes so that we ensure it doesn't segfault?
There was a problem hiding this comment.
that shouldn't matter i think. The reason this could segfault is if the result is wrong. But as the used algorithm doesn't depend on T asserting that it is correct for i32 also means that it would be correct for Box and therefore can't segfault.
There was a problem hiding this comment.
Probably, but I figured better safe than sorry :)
There was a problem hiding this comment.
yeah, don't have the capacity for this rn though.
|
This seems ok, I'd like to get it merged ASAP so we can get testing to the extent possible. @bors r+ p=1 I admit the code is pretty high-context I think in terms of being able to follow it. |
|
📌 Commit 4fb9f1d has been approved by |
|
(I removed |
|
☀️ Test successful - checks-actions |
…ulacrum [beta] backports * Revert rust-lang#77534 fixing rust-lang#77713 on beta, principled fix landed on master * fix soundness issue in `make_contiguous` rust-lang#79814 * Fix exhaustiveness in case a byte string literal is used at slice type rust-lang#79072
|
The process for stable and beta nominations is the same - until they happen, both nominated and stable should be left. Reading. |
|
Oops, didn't realize that! Sorry. |
fixes #79808