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

[unnecessary_lazy_eval]: reduce applicability if closure has return type annotation #11673

Merged
merged 1 commit into from Oct 16, 2023

Conversation

y21
Copy link
Member

@y21 y21 commented Oct 15, 2023

Fixes #11672

We already check if closure parameters don't have type annotations and reduce the applicability to MaybeIncorrect if they do, since those help type inference and removing them breaks code. We didn't do this for return type annotations however. This PR adds it. This doesn't change it to produce a fix that will compile, but it will prevent rustfix from auto-applying it.

(In general I'm not sure if we can suggest a fix that will compile. In this specific example, it might be possible to suggest &[] as &[u8], but as-casts won't always work, e.g. Default::default() as &[u8] is a compile error, so just reducing applicability should be a safe fix in any case for now)

changelog: [unnecessary_lazy_eval]: reduce applicability to MaybeIncorrect if closure has return type annotation

@rustbot
Copy link
Collaborator

rustbot commented Oct 15, 2023

r? @Manishearth

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Oct 15, 2023
@Manishearth
Copy link
Member

@bors r+

thanks!

@bors
Copy link
Collaborator

bors commented Oct 16, 2023

📌 Commit bb6516a has been approved by Manishearth

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Oct 16, 2023

⌛ Testing commit bb6516a with merge 9f27b15...

@bors
Copy link
Collaborator

bors commented Oct 16, 2023

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Manishearth
Pushing 9f27b15 to master...

@bors bors merged commit 9f27b15 into rust-lang:master Oct 16, 2023
5 checks passed
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 suggests wrong fix
4 participants