Commit 1ac4f86
authored
Rollup merge of rust-lang#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: rust-lang#705301 file changed
+4
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1220 | 1220 | | |
1221 | 1221 | | |
1222 | 1222 | | |
1223 | | - | |
| 1223 | + | |
1224 | 1224 | | |
1225 | 1225 | | |
1226 | 1226 | | |
1227 | | - | |
| 1227 | + | |
1228 | 1228 | | |
1229 | 1229 | | |
1230 | 1230 | | |
| |||
1585 | 1585 | | |
1586 | 1586 | | |
1587 | 1587 | | |
1588 | | - | |
| 1588 | + | |
1589 | 1589 | | |
1590 | 1590 | | |
1591 | 1591 | | |
1592 | | - | |
| 1592 | + | |
1593 | 1593 | | |
1594 | 1594 | | |
1595 | 1595 | | |
| |||
0 commit comments