Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-schievink committed Jan 19, 2020
1 parent 52d6c90 commit e5987a0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
7 changes: 5 additions & 2 deletions src/liballoc/collections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1566,10 +1566,13 @@ where
{
fn drop(&mut self) {
struct DropGuard<'r, 'a, T, F>(&'r mut DrainFilter<'a, T, F>)
where F: FnMut(&mut T) -> bool;
where
F: FnMut(&mut T) -> bool;

impl<'r, 'a, T, F> Drop for DropGuard<'r, 'a, T, F>
where F: FnMut(&mut T) -> bool {
where
F: FnMut(&mut T) -> bool,
{
fn drop(&mut self) {
self.0.for_each(drop);
}
Expand Down
11 changes: 5 additions & 6 deletions src/liballoc/tests/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,13 +590,12 @@ fn drain_filter_pred_panic_leak() {
q.push_front(D(1));
q.push_front(D(0));

catch_unwind(AssertUnwindSafe(|| drop(q.drain_filter(|item| if item.0 >= 2 {
panic!()
} else {
true
})))).ok();
catch_unwind(AssertUnwindSafe(|| {
drop(q.drain_filter(|item| if item.0 >= 2 { panic!() } else { true }))
}))
.ok();

assert_eq!(unsafe { DROPS }, 2); // 0 and 1
assert_eq!(unsafe { DROPS }, 2); // 0 and 1
assert_eq!(q.len(), 6);
}

Expand Down
6 changes: 1 addition & 5 deletions src/liballoc/tests/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,11 +783,7 @@ fn test_into_iter_leak() {
}
}

let v = vec![
D(false),
D(true),
D(false),
];
let v = vec![D(false), D(true), D(false)];

catch_unwind(move || drop(v.into_iter())).ok();

Expand Down
5 changes: 3 additions & 2 deletions src/liballoc/tests/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +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::{AssertUnwindSafe, catch_unwind};
use std::panic::{catch_unwind, AssertUnwindSafe};
use std::{isize, usize};

use crate::hash;
Expand Down Expand Up @@ -1637,7 +1637,8 @@ fn test_drain_leak() {

catch_unwind(AssertUnwindSafe(|| {
v.drain(1..=4);
})).ok();
}))
.ok();

assert_eq!(unsafe { DROPS }, 4);
assert_eq!(v.len(), 3);
Expand Down

0 comments on commit e5987a0

Please sign in to comment.