Skip to content
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

suggest into_iter() when Iterator method called on impl IntoIterator #119928

Merged
merged 1 commit into from
Feb 16, 2024

Conversation

d-sonuga
Copy link
Contributor

Fix for issue #117711.

@rustbot
Copy link
Collaborator

rustbot commented Jan 13, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @TaKO8Ki (or someone else) soon.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 13, 2024
@compiler-errors
Copy link
Member

r? compiler

@rustbot rustbot assigned compiler-errors and unassigned TaKO8Ki Feb 2, 2024
@bors
Copy link
Contributor

bors commented Feb 7, 2024

☔ The latest upstream changes (presumably #120722) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-log-analyzer

This comment has been minimized.

@d-sonuga d-sonuga force-pushed the into-iter-sugg branch 2 times, most recently from 7b4201d to 51a9e61 Compare February 12, 2024 15:14
@rust-log-analyzer

This comment has been minimized.

Comment on lines 152 to 153
tcx.def_path_str(trait_pred.trait_ref.def_id)
== tcx.def_path_str(into_iterator_trait)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you using string comparison here? Just compare the def ids directly.

Suggested change
tcx.def_path_str(trait_pred.trait_ref.def_id)
== tcx.def_path_str(into_iterator_trait)
trait_pred.trait_ref.def_id == into_iterator_trait

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, you can use is_diagnostic_item

}
_ => return false,
}
false
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this whole approach could be simplified by just checking if {ty}: IntoIterator holds. You can use predicate_must_hold_modulo_regions to do this.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 12, 2024
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 12, 2024
@compiler-errors
Copy link
Member

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Feb 16, 2024

📌 Commit e99766d has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 16, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 16, 2024
…llaumeGomez

Rollup of 6 pull requests

Successful merges:

 - rust-lang#119928 (suggest `into_iter()` when `Iterator` method called on `impl IntoIterator`)
 - rust-lang#121020 (Avoid an ICE in diagnostics)
 - rust-lang#121111 (For E0038, suggest associated type if available)
 - rust-lang#121137 (Add clippy into the known `cfg` list)
 - rust-lang#121179 (allow mutable references in const values when they point to no memory)
 - rust-lang#121181 (Fix an ICE in the recursion lint)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f81fd90 into rust-lang:master Feb 16, 2024
11 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Feb 16, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 16, 2024
Rollup merge of rust-lang#119928 - d-sonuga:into-iter-sugg, r=compiler-errors

suggest `into_iter()` when `Iterator` method called on `impl IntoIterator`

Fix for issue rust-lang#117711.
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-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants