Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
Qelxiros wants to merge 4 commits into rust-lang:master
base: master
Choose a base branch
Loading
from Qelxiros:127494-iter_contains

Conversation

Copy link
Contributor

@Qelxiros Qelxiros commented Jun 4, 2025
edited by rustbot
Loading

Tracking issue: #127494

Continuing from where #135018 left off

Copy link
Collaborator

rustbot commented Jun 4, 2025

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 4, 2025

This comment has been minimized.

Copy link
Collaborator

rustbot commented Jun 7, 2025

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.

This comment has been minimized.

Copy link
Member

r? libs-api to confirm that this is fine to merge with nightly breakage due to the conflicts.

@rustbot rustbot added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Jun 15, 2025
@rustbot rustbot assigned dtolnay and unassigned ibraheemdev Jun 15, 2025
@dtolnay dtolnay added I-libs-api-nominated Nominated for discussion during a libs-api team meeting. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 15, 2025
Copy link
Member

@dtolnay dtolnay left a 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

Copy link
Member

dtolnay commented Jun 17, 2025

@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 itertools::Itertools::contains (which is one of the more widely used itertools extension trait methods).

Unfortunately the warning is 100% spurious, because we have no intention of stabilizing Iterator::contains in a way that would cause the breakage that it warns about. With #89151, code like the following from rust-analyzer will retain its current behavior because Iterator is a supertrait of Itertools so the supertrait method will be shadowed instead of ambiguous.

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)]
 |

Copy link

rfcbot commented Jun 17, 2025
edited by Amanieu
Loading

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.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Jun 17, 2025
Copy link
Member

dtolnay commented Jun 17, 2025
edited
Loading

I think I would prefer to block this PR on not necessarily stabilizing #89151, but just a compiler fix that prevents the unstable_name_collisions warning in the case of supertrait colliding methods.

@dtolnay dtolnay removed the I-libs-api-nominated Nominated for discussion during a libs-api team meeting. label Jun 17, 2025
Copy link
Member

Amanieu commented Jul 1, 2025

I'm also happy to block this on #89151.

@dtolnay dtolnay added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@lnicola lnicola lnicola left review comments

@dtolnay dtolnay dtolnay approved these changes

+1 more reviewer

@tbu- tbu- tbu- left review comments

Reviewers whose approvals may not affect merge requirements
Labels
disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /