-
Notifications
You must be signed in to change notification settings - Fork 13.4k
add Iterator::contains #141994
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
base: master
Are you sure you want to change the base?
add Iterator::contains #141994
Conversation
r? @ibraheemdev rustbot has assigned @ibraheemdev. Use |
This comment has been minimized.
This comment has been minimized.
rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead. cc @rust-lang/rust-analyzer |
This comment has been minimized.
This comment has been minimized.
cb04a2d
to
606cd35
Compare
This comment has been minimized.
This comment has been minimized.
src/tools/rust-analyzer/crates/ide-assists/src/handlers/convert_bool_to_enum.rs
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
9e27be5
to
8fccd73
Compare
r? libs-api to confirm that this is fine to merge with nightly breakage due to the conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Stabilizing this is going to be blocked on #89151 to avoid breaking code that currently uses Itertools's contains
. The signatures are different — itertools looks more like HashSet::contains
with a bound of Self::Item: Borrow<Q>, Q: PartialEq
whereas what we are planning for the standard library is Q: PartialEq<Self::Item>
.
https://docs.rs/itertools/0.14.0/itertools/trait.Itertools.html#method.contains
@rfcbot fcp merge Even though this is an unstable addition, let me run this by the team to assess whether we want to take this step now. This PR causes new warnings in code that uses Unfortunately the warning is 100% spurious, because we have no intention of stabilizing If we merge this as-is, a lot of people will get warnings and uselessly rewrite their code. warning: a method with this name may be added to the standard library in the future
--> crates/ide-assists/src/handlers/convert_bool_to_enum.rs:381:48
|
381 | if !bin_expr.lhs()?.syntax().descendants().contains(name.syntax()) {
| ^^^^^^^^
|
= warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
= note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
= help: call with fully qualified syntax `itertools::Itertools::contains(...)` to keep using the current method
= note: `#[warn(unstable_name_collisions)]` on by default
help: add `#![feature(iter_contains)]` to the crate attributes to enable `std::iter::Iterator::contains`
--> crates/ide-assists/src/lib.rs:63:1
|
63 + #![feature(iter_contains)]
|
warning: a method with this name may be added to the standard library in the future
--> crates/ide-assists/src/handlers/convert_bool_to_enum.rs:447:41
|
447 | if !receiver.syntax().descendants().contains(name.syntax()) {
| ^^^^^^^^
|
= warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
= note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
= help: call with fully qualified syntax `itertools::Itertools::contains(...)` to keep using the current method
help: add `#![feature(iter_contains)]` to the crate attributes to enable `std::iter::Iterator::contains`
--> crates/ide-assists/src/lib.rs:63:1
|
63 + #![feature(iter_contains)]
| |
Team member @dtolnay has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
I think I would prefer to block this PR on not necessarily stabilizing #89151, but just a compiler fix that prevents the |
Tracking issue: #127494
Continuing from where #135018 left off