-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.
Description
When I run the following code on the latest nightly channel, it prints incorrect result:
#![feature(deque_extend_front)]
use std::collections::VecDeque;
use itertools::join;
struct Point([i32; 2]);
fn main() {
let mut vec_2 = VecDeque::with_capacity(10);
vec_2.push_back(Point([0, 6]));
vec_2.push_back(Point([4, 6]));
vec_2.push_back(Point([4, 2]));
vec_2.push_back(Point([2, 2]));
vec_2.push_back(Point([2, 6]));
vec_2.push_back(Point([0, 6]));
let mut vec_3 = VecDeque::with_capacity(10);
vec_3.push_back(Point([8, 6]));
vec_3.push_back(Point([8, 4]));
vec_3.push_back(Point([6, 4]));
vec_3.push_back(Point([6, 6]));
let mut vec = VecDeque::with_capacity(10);
vec.push_front(Point([0, 0]));
vec.push_back(Point([10, 0]));
let mut points_str = join(
vec.iter().map(|val| format!("({}, {})", val.0[0], val.0[1])),
", ",
);
println!("{}", points_str);
vec.prepend(vec_2.drain(..));
points_str = join(
vec.iter().map(|val| format!("({}, {})", val.0[0], val.0[1])),
", ",
);
println!("{}", points_str);
vec.splice(1..1, vec_3.drain(..));
points_str = join(
vec.iter().map(|val| format!("({}, {})", val.0[0], val.0[1])),
", ",
);
println!("{}", points_str);
}I would expect the output of this simple program to be:
(0, 0), (10, 0)
(0, 6), (4, 6), (4, 2), (2, 2), (2, 6), (0, 6), (0, 0), (10, 0)
(0, 6), (8, 6), (8, 4), (6, 4), (6, 6), (4, 6), (4, 2), (2, 2), (2, 6), (0, 0), (10, 0)
but instead the following got print:
(0, 0), (10, 0)
(0, 6), (4, 6), (4, 2), (2, 2), (2, 6), (0, 6), (0, 0), (10, 0)
(0, 6), (8, 6), (8, 4), (6, 4), (6, 6), (4, 6), (4, 2), (2, 2), (2, 6), (0, 0), (0, 0), (0, 0)
As you can see, the last element got remvoed, and two extra elements got inserted. In my actual application (not in this simple example), the extra elements contain random values instead of just zeros.
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.This issue requires a nightly compiler in some way. When possible, use a F-* label instead.