Skip to content

Commit

Permalink
Rollup merge of rust-lang#112677 - the8472:remove-unusued-field, r=Jo…
Browse files Browse the repository at this point in the history
…hnTitor

remove unused field

Followup to rust-lang#104455. The field is no longer needed since ExtractIf (previously DrainFilter) doesn't keep draining in its drop impl.
  • Loading branch information
TaKO8Ki authored Jun 26, 2023
2 parents 27e10c5 + 64ee0f7 commit c6a4d44
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
8 changes: 0 additions & 8 deletions library/alloc/src/vec/extract_if.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ pub struct ExtractIf<
pub(super) old_len: usize,
/// The filter test predicate.
pub(super) pred: F,
/// A flag that indicates a panic has occurred in the filter test predicate.
/// This is used as a hint in the drop implementation to prevent consumption
/// of the remainder of the `ExtractIf`. Any unprocessed items will be
/// backshifted in the `vec`, but no further items will be dropped or
/// tested by the filter predicate.
pub(super) panic_flag: bool,
}

impl<T, F, A: Allocator> ExtractIf<'_, T, F, A>
Expand All @@ -69,9 +63,7 @@ where
while self.idx < self.old_len {
let i = self.idx;
let v = slice::from_raw_parts_mut(self.vec.as_mut_ptr(), self.old_len);
self.panic_flag = true;
let drained = (self.pred)(&mut v[i]);
self.panic_flag = false;
// Update the index *after* the predicate is called. If the index
// is updated prior and the predicate panics, the element at this
// index would be leaked.
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2948,7 +2948,7 @@ impl<T, A: Allocator> Vec<T, A> {
self.set_len(0);
}

ExtractIf { vec: self, idx: 0, del: 0, old_len, pred: filter, panic_flag: false }
ExtractIf { vec: self, idx: 0, del: 0, old_len, pred: filter }
}
}

Expand Down

0 comments on commit c6a4d44

Please sign in to comment.