Fix unsoundness in VecDeque::from_iter(vec::IntoIter) - #162462
Conversation
46f693a to
5d7774e
Compare
|
The cc @bjorn3 Edit: Sorry for the ping, I just got confused by the fact that debug assertions are apparently off in alloctests, which made me believe that the method wasn't getting run. |
I don't remember why for this particular case. For a couple of other cases it was necessary to avoid errors from the |
I don't have bors privileges ^^ |
898722c to
8bd0a5a
Compare
|
I'll r+ it once CI passes 👍 |
|
@bors r+ |
…uwer Rollup of 12 pull requests Successful merges: - #162462 (Fix unsoundness in `VecDeque::from_iter(vec::IntoIter)`) - #162468 (mir_build: Rename `lower_let_expr` to `lower_fallible_let`, and clarify) - #161806 (Add tests and docs for `#[derive(GenericTypeVisitable)]`) - #161912 (run `extern "tail"` with `byval` argument test) - #161932 (Only check `#[allow(dead_code)]` on the trait) - #162236 (Call renumberMetadataForAssembly() in LLVMRustPrintModule()) - #162435 (windows-gnu: document libgcc requirement) - #162439 (Update books) - #162451 (Add regression test for item-local diagnostic attribute lint levels) - #162455 (Update codegen-llvm/inline-debuginfo.rs for distinct DILocation) - #162459 (docs(time): replace "method" with "function") - #162465 (Fix my duplicate thanks entry)
Rollup merge of #162462 - maxdexh:issue-162452-vec-into-iter-into-deque, r=Darksonn Fix unsoundness in `VecDeque::from_iter(vec::IntoIter)` Adds a safety requirement to `VecDeque::from_contiguous_raw_parts_in` to ensure that the `VecDeque` it creates upholds the safety invariants. In particular, either `head < capacity` or `head == capacity == 0`. Refactors `vec::IntoIter::into_vecdeque` to uphold that invariant (and splits the unsafe blocks into multiple parts, because the safety comment was messy & incomplete). Actual fix is the addition of `|| len == 0`. I would add a regression test, but the specialization is behind `cfg(not(test))`. I cannot see why this was done, as there are no comments documenting this... Fixes #162452 r? libs
Adds a safety requirement to
VecDeque::from_contiguous_raw_parts_into ensure that theVecDequeit creates upholds the safety invariants. In particular, eitherhead < capacityorhead == capacity == 0.Refactors
vec::IntoIter::into_vecdequeto uphold that invariant (and splits the unsafe blocks into multiple parts, because the safety comment was messy & incomplete). Actual fix is the addition of|| len == 0.I would add a regression test, but the specialization is behind
cfg(not(test)). I cannot see why this was done, as there are no comments documenting this...Fixes #162452
r? libs