Skip to content

borrowck: suggest explicit &_ annotations for unannotated closure arguments on E0597 - #163648

Open
raushan728 wants to merge 2 commits into
rust-lang:mainfrom
raushan728:issues/163475
Open

raushan728 wants to merge 2 commits into
rust-lang:mainfrom
raushan728:issues/163475

Conversation

@raushan728

@raushan728 raushan728 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #163475

When an E0597 borrow error is caused by passing a borrowed local into an unannotated closure parameter, the inferred lifetime is often too large.

This PR traces the MIR def-use chain to the exact closure argument and suggests explicitly annotating the parameter to make it higher-ranked.

r? @GuillaumeGomez

@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 Oct 2, 2026
@rust-log-analyzer

This comment has been minimized.

@rustbot

rustbot commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

This branch has not been deployed

No deployments
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. 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.

Diagnostic: confusing output for closure type inference

4 participants