-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Remove unneeded lifetime bound from signature of BTreeSet::extract_if #142484
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r? @ibraheemdev rustbot has assigned @ibraheemdev. Use |
5 tasks
@bors r+ rollup |
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Jun 14, 2025
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#70530
bors
added a commit
that referenced
this pull request
Jun 14, 2025
Rollup of 9 pull requests Successful merges: - #140593 (Temporary lifetime extension through tuple struct and tuple variant constructors) - #141399 ([rustdoc] Give more information into extracted doctest information) - #141493 (Delegate `<SocketAddr as Debug>` to `ByteStr`) - #141811 (Unimplement unsized_locals) - #142243 (float tests: deduplicate min, max, and rounding tests) - #142464 (variadic functions: remove list of supported ABIs from error) - #142477 (Fix incorrect suggestion when calling an associated type with a type anchor) - #142484 (Remove unneeded lifetime bound from signature of BTreeSet::extract_if) - #142489 (Update the `compiler-builtins` subtree) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
that referenced
this pull request
Jun 14, 2025
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
RalfJung
pushed a commit
to RalfJung/miri
that referenced
this pull request
Jun 15, 2025
Rollup of 9 pull requests Successful merges: - rust-lang/rust#140593 (Temporary lifetime extension through tuple struct and tuple variant constructors) - rust-lang/rust#141399 ([rustdoc] Give more information into extracted doctest information) - rust-lang/rust#141493 (Delegate `<SocketAddr as Debug>` to `ByteStr`) - rust-lang/rust#141811 (Unimplement unsized_locals) - rust-lang/rust#142243 (float tests: deduplicate min, max, and rounding tests) - rust-lang/rust#142464 (variadic functions: remove list of supported ABIs from error) - rust-lang/rust#142477 (Fix incorrect suggestion when calling an associated type with a type anchor) - rust-lang/rust#142484 (Remove unneeded lifetime bound from signature of BTreeSet::extract_if) - rust-lang/rust#142489 (Update the `compiler-builtins` subtree) r? `@ghost` `@rustbot` modify labels: rollup
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
T-libs
Relevant to the library team, which will review and decide on the PR/issue.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
One way to observe the difference between these signatures, using 0 explicit lifetimes and 0 contrived where-clauses:
Before:
After: compiles successfully.