-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VecDeque::push_back(())
does not work correctly.
#28488
Comments
() is void type / value, so it should be correct; if you add nothinh to an empty collection, the collection remains empty ... |
use std::collections::VecDeque;
fn main() {
let mut v = VecDeque::new();
v.push_front(());
assert_eq!(v.len(), 1);
} fails with
|
@ituxbag No, the collection just contains one nothing ;)
fn main() {
let mut v = Vec::new();
v.push(());
v.push(());
assert_eq!(v.len(), 2);
} |
/cc @rust-lang/libs this is interesting. |
This variant appears to loop forever, presumably in use std::collections::VecDeque;
fn main() {
let mut v = VecDeque::new();
v.push_front(());
println!("{}", v.len());
} |
Let's aim to improve the testsuite with general collections + Zero sized types tests too. |
Ok, Zero sized types (ZSTs) are a can of worms, potentially there may be several problems, but so far I found that the VecDeque in Rust 1.3 with ZST uses |
I would recommend |
Oh, right this capacity is inherited from RawVec! Annoying, but not a big deal. |
This used to work in Rust 1.0, 1.1, 1.2. Regression report, ad-hoc via travis First broken release: Rust 1.3.0. |
VecDeque: Use power of two capacity even for zero sized types VecDeque depends on using a power of two capacity. Use the largest possible power of two capacity for ZSTs. Fixes #28488
@dpc As soon as a new nightly is built, it would be great if you could verify that the bug was fixed for the original problem. |
Sure. I'll try that tomorrow. |
@dpc Any luck? |
The original problem reported confirmed it's fixed in: https://github.com/dpc/mioco/issues/55#issuecomment-142004340 |
Thank you! Good to have some confidence so that we can backport the fix to beta. |
http://is.gd/NY4tCl
The text was updated successfully, but these errors were encountered: