-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add lint: from_iter_instead_of_collect #6101
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @flip1995 (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
I am not sure how to resolve the |
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.
LGTM overall. Some comments for cleanup and to get it aligned with the rest of the codebase.
About the Please also remove the empty |
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.
Last NIT, after that it's ready to get merged 🚀
The lint you implemented detected this problem in Clippy itself: error: usage of `FromIterator::from_iter`
--> clippy_lints/src/lifetimes.rs:217:24
|
217 | .intersection(&FxHashSet::from_iter(
| ________________________^
218 | | input_visitor
219 | | .nested_elision_site_lts
220 | | .iter()
... |
223 | | .filter(|v| matches!(v, RefLt::Named(_))),
224 | | ))
| |_________^
|
= note: `-D clippy::from-iter-instead-of-collect` implied by `-D clippy::all`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#from_iter_instead_of_collect
help: use `.collect()` instead of `::from_iter()`
|
217 | .intersection(&input_visitor
218 | .nested_elision_site_lts
219 | .iter()
220 | .chain(output_visitor.nested_elision_site_lts.iter())
221 | .cloned()
222 | .filter(|v| matches!(v, RefLt::Named(_))).collect())
| |
ping from triage @pitiK3U. There's only a small fix left to be done. Do you have any questions on how to proceed here? |
Sorry for taking me too long to finish this. My college had started and I hadn't had time to finish it. Will try to do so asap. |
Remove the generated files by `update-references.sh` if they are empty An empty file may be generated by `update-references.sh` and committed as is when creating a patch like #6101 (comment) and #6079 (review). So, I think it would be helpful to add documentation, and automatically remove the generated file if it's empty. changelog: none
Thanks! Only the dogfood error (#6101 (comment)) is now left to fix |
☔ The latest upstream changes (presumably #6227) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
@bors r+ Thanks! I rebased it for you, so I can directly r+ it, so that there won't be another rebase required. |
📌 Commit ddf23d6 has been approved by |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
@flip1995 Thank you! |
Fixes #5679
This implements lint for
::from_iter()
from #5679 not the general issue (std::ops::Add::add
, etc.).This lint checks if expression is function call with
from_iter
name and if it's implementation of thestd::iter::FromIterator
trait.changelog: Introduce from_iter_instead_of_collect lint