about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2021-03-19 23:01:37 +0100
committerGitHub <noreply@github.com>2021-03-19 23:01:37 +0100
commit1a0e32f4bc30318f4e15d200039bdbc2ea659fdb (patch)
tree7ed7b88459086ffb2ae66fee9a37fca8e3482b0f /compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
parentf7febc8865a2cb2287b034f6588d7617fa0fc6e9 (diff)
parentc07955c6b6a8901fc59d9c22004127b30a965407 (diff)
downloadrust-1a0e32f4bc30318f4e15d200039bdbc2ea659fdb.tar.gz
rust-1a0e32f4bc30318f4e15d200039bdbc2ea659fdb.zip
Rollup merge of #83244 - cuviper:vec_deque-zst, r=m-ou-se
Fix overflowing length in Vec<ZST> to VecDeque

`Vec` can hold up to `usize::MAX` ZST items, but `VecDeque` has a lower
limit to keep its raw capacity as a power of two, so we should check
that in `From<Vec<T>> for VecDeque<T>`. We can also simplify the
capacity check for the remaining non-ZST case.

Before this fix, the new test would fail on the length:

```
thread 'collections::vec_deque::tests::test_from_vec_zst_overflow' panicked at 'assertion failed: `(left == right)`
  left: `0`,
 right: `9223372036854775808`', library/alloc/src/collections/vec_deque/tests.rs:474:5
note: panic did not contain expected string
      panic message: `"assertion failed: `(left == right)`\n  left: `0`,\n right: `9223372036854775808`"`,
 expected substring: `"capacity overflow"`
```

That was a result of `len()` using a mask `& (size - 1)` with the
improper length. Now we do get a "capacity overflow" panic as soon as
that `VecDeque::from(vec)` is attempted.

Fixes #80167.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp')
0 files changed, 0 insertions, 0 deletions