Implement redundant idempotent calls lint#17187
Implement redundant idempotent calls lint#17187Francisco-Andre-Martins wants to merge 2 commits into
Conversation
When a method that is idempotent (calling it multiple times produces the same result as calling it once) is called on a value that has already had the same method applied with the same arguments, the second call is redundant and can be removed. Examples of idempotent methods: 'to_lowercase', 'to_uppercase', 'trim', 'trim_start', 'trim_end', 'abs', 'floor', 'ceil', 'round', 'max', 'min', 'clamp', 'and', 'or', 'to_vec', 'to_ascii_lowercase', 'to_ascii_uppercase', 'signum'. Some methods were left out as a possible follow-up, either because each call wraps the value in a new iterator adapter rather than being a true idempotent, because they have side effects, or because they are only idempotent under very specific conditions. Closes rust-lang#16099 Co-authored-by: Guilherme Silva <guilherme.d.silva@tecnico.ulisboa.pt>
|
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @samueltardieu (or someone else) some time within the next two weeks. 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 (
Why was this reviewer chosen?The reviewer was selected based on:
|
|
Lintcheck changes for 0b846fb
This comment will be updated if you push new changes |
|
Tests need to pass (including "dogfood") @rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
|
Yup, sorry for the inconvenient, it should be ready now. |
When a method that is idempotent (calling it multiple times produces the same result as calling it once) is called on a value that has already had the same method applied with the same arguments, the second call is redundant and can be removed.
Examples of idempotent methods: 'to_lowercase', 'to_uppercase', 'trim', 'trim_start', 'trim_end', 'abs', 'floor', 'ceil', 'round', 'max', 'min', 'clamp', 'and', 'or', 'to_vec', 'to_ascii_lowercase', 'to_ascii_uppercase', 'signum'.
Some methods were left out as a possible follow-up, either because each call wraps the value in a new iterator adapter rather than being a true idempotent, because they have side effects, or because they are only idempotent under very specific conditions.
Closes #16099
changelog: implement redundant idempotent call lint