Skip to content

Commit c2dda74

Browse files
authored
Unrolled build for #142484
Rollup merge of #142484 - dtolnay:bsetextract, r=m-ou-se Remove unneeded lifetime bound from signature of BTreeSet::extract_if One way to observe the difference between these signatures, using 0 explicit lifetimes and 0 contrived where-clauses: ```rust use std::collections::btree_set::{BTreeSet, ExtractIf}; use std::ops::RangeFull; fn repro( set: &mut BTreeSet<i32>, predicate: impl Fn(i32) -> bool, ) -> ExtractIf<i32, RangeFull, impl FnMut(&i32) -> bool> { set.extract_if(.., move |x| predicate(*x)) } ``` **Before:** ```console error[E0311]: the parameter type `impl Fn(i32) -> bool` may not live long enough --> src/lib.rs:8:5 | 5 | set: &mut BTreeSet<i32>, | ------------------ the parameter type `impl Fn(i32) -> bool` must be valid for the anonymous lifetime defined here... ... 8 | set.extract_if(.., move |x| predicate(*x)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...so that the type `impl Fn(i32) -> bool` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound | 4 ~ fn repro<'a>( 5 ~ set: &'a mut BTreeSet<i32>, 6 ~ predicate: impl Fn(i32) -> bool + 'a, 7 ~ ) -> ExtractIf<'a, i32, RangeFull, impl FnMut(&i32) -> bool> { | ``` **After:** compiles success. - Tracking issue: #70530
2 parents 64033a4 + dac9d78 commit c2dda74

File tree

1 file changed

+4
-4
lines changed
  • library/alloc/src/collections/btree

1 file changed

+4
-4
lines changed

library/alloc/src/collections/btree/set.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,11 +1220,11 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
12201220
/// assert_eq!(high.into_iter().collect::<Vec<_>>(), [4, 5, 6, 7]);
12211221
/// ```
12221222
#[unstable(feature = "btree_extract_if", issue = "70530")]
1223-
pub fn extract_if<'a, F, R>(&'a mut self, range: R, pred: F) -> ExtractIf<'a, T, R, F, A>
1223+
pub fn extract_if<F, R>(&mut self, range: R, pred: F) -> ExtractIf<'_, T, R, F, A>
12241224
where
12251225
T: Ord,
12261226
R: RangeBounds<T>,
1227-
F: 'a + FnMut(&T) -> bool,
1227+
F: FnMut(&T) -> bool,
12281228
{
12291229
let (inner, alloc) = self.map.extract_if_inner(range);
12301230
ExtractIf { pred, inner, alloc }
@@ -1585,11 +1585,11 @@ where
15851585
}
15861586

15871587
#[unstable(feature = "btree_extract_if", issue = "70530")]
1588-
impl<'a, T, R, F, A: Allocator + Clone> Iterator for ExtractIf<'_, T, R, F, A>
1588+
impl<T, R, F, A: Allocator + Clone> Iterator for ExtractIf<'_, T, R, F, A>
15891589
where
15901590
T: PartialOrd,
15911591
R: RangeBounds<T>,
1592-
F: 'a + FnMut(&T) -> bool,
1592+
F: FnMut(&T) -> bool,
15931593
{
15941594
type Item = T;
15951595

0 commit comments

Comments
 (0)