Skip to content

Conversation

dylni
Copy link

@dylni dylni commented Sep 8, 2025

Update unnecessary_lazy_evaluations to allow closures for trivial functions according to the developer's preference.

The current list of trivial functions is is_empty, len, and as_*. This list cannot be updated without causing churn, because e.g., calls to unwrap_or_else and unwrap_or would need to be swapped for each addition and removal. This list is also undocumented and not based on actual method complexity, but repositories need to follow it to be compliant with this default lint. Leaving these trivial functions up to developer preference allows developers to not need to think about which functions Clippy considers lazy.

A configuration could be added later to re-enable this without any backward-compatibility concern, but it should not be enforced by default.

changelog: [unnecessary_lazy_evaluations]: allow optional closure for trivial functions

Fixes: #8109

@rustbot
Copy link
Collaborator

rustbot commented Sep 8, 2025

r? @Jarcho

rustbot has assigned @Jarcho.
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 the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Sep 8, 2025
Copy link

github-actions bot commented Sep 8, 2025

Lintcheck changes for de1028a

Lint Added Removed Changed
clippy::if_then_some_else_none 0 0 3
clippy::option_if_let_else 0 0 2
clippy::unnecessary_lazy_evaluations 0 12 0

This comment will be updated if you push new changes

@rustbot
Copy link
Collaborator

rustbot commented Sep 18, 2025

☔ The latest upstream changes (possibly e1130b6) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

unnecessary_lazy_evaluations warns about str::len
3 participants