8000 Rollup of 7 pull requests by Centril · Pull Request #67263 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 7 pull requests #67263

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

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1afa9d9
Revert "Redefine `core::convert::Infallible` as `!`."
Dec 11, 2019
bca33d7
Revert "Remove `#![feature(never_type)]` from tests."
Dec 11, 2019
3499da6
Revert "Stabilize the `never_type`, written `!`."
Dec 11, 2019
951a38c
Add regression test for #66757
Dec 11, 2019
6613e33
add `#![feature(never_type)]` to tests as needed
Dec 11, 2019
189ccf2
VecDeque: drop remaining items on destructor panic
jonas-schievink Dec 11, 2019
5e32da1
LinkedList: drop remaining items when drop panics
jonas-schievink Dec 11, 2019
82c09b7
Add comment to `Dropper`
jonas-schievink Dec 11, 2019
fa199c5
Don't suggest wrong snippet in closure
JohnTitor Dec 11, 2019
ffd2142
Remove the `DelimSpan` from `NamedMatch::MatchedSeq`.
nnethercote Dec 12, 2019
0b1e08a
Require `allow_internal_unstable` for stable min_const_fn using unsta…
oli-obk Dec 12, 2019
0f47327
Remove i686-unknown-dragonfly target
tuxillo Dec 12, 2019
922e5dc
Rollup merge of #67224 - nikomatsakis:revert-stabilization-of-never-t…
Centril Dec 12, 2019
d7c9cf3
Rollup merge of #67235 - jonas-schievink:vecdeque-leak, r=KodrAus
Centril Dec 12, 2019
246397f
Rollup merge of #67243 - jonas-schievink:linkedlist-drop, r=KodrAus
Centril Dec 12, 2019
7bfd45a
Rollup merge of #67247 - JohnTitor:fix-sugg, r=estebank
Centril Dec 12, 2019
b533592
Rollup merge of #67250 - nnethercote:rm-DelimSpan-from-NamedMatch-Mat…
Centril Dec 12, 2019
7b93d36
Rollup merge of #67251 - oli-obk:stability_sieve, r=Centril
Centril Dec 12, 2019
8e6c199
Rollup merge of #67255 - tuxillo:remove-i686-unknown-dragonfly, r=ale…
Centril Dec 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/liballoc/collections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,23 @@ impl<T: Clone> Clone for VecDeque<T> {
#[stable(feature = "rust1", since = "1.0.0")]
unsafe impl<#[may_dangle] T> Drop for VecDeque<T> {
fn drop(&mut self) {
/// Runs the destructor for all items in the slice when it gets dropped (normally or
/// during unwinding).
struct Dropper<'a, T>(&'a mut [T]);

impl<'a, T> Drop for Dropper<'a, T> {
fn drop(&mut self) {
unsafe {
ptr::drop_in_place(self.0);
}
}
}

let (front, back) = self.as_mut_slices();
unsafe {
let _back_dropper = Dropper(back);
// use drop for [T]
ptr::drop_in_place(front);
ptr::drop_in_place(back);
}
// RawVec handles deallocation
}
Expand Down
34 changes: 34 additions & 0 deletions src/liballoc/tests/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::collections::TryReserveError::*;
use std::collections::{vec_deque::Drain, VecDeque};
use std::fmt::Debug;
use std::mem::size_of;
use std::panic::catch_unwind;
use std::{isize, usize};

use crate::hash;
Expand Down Expand Up @@ -709,6 +710,39 @@ fn test_drop_clear() {
assert_eq!(unsafe { DROPS }, 4);
}

#[test]
fn test_drop_panic() {
static mut DROPS: i32 = 0;

struct D(bool);

impl Drop for D {
fn drop(&mut self) {
unsafe {
DROPS += 1;
}

if self.0 {
panic!("panic in `drop`");
}
}
}

let mut q = VecDeque::new();
q.push_back(D(false));
q.push_back(D(false));
q.push_back(D(false));
q.push_back(D(false));
q.push_back(D(false));
q.push_front(D(false));
q.push_front(D(false));
q.push_front(D(true));

catch_unwind(move || drop(q)).ok();

assert_eq!(unsafe { DROPS }, 8);
}

#[test]
fn test_reserve_grow() {
// test growth path A
Expand Down
0