Skip to content

Suggest annotating closure parameters as references on E0597 - #164874

Closed
Muhtasim-Rasheed wants to merge 1 commit into
rust-lang:mainfrom
Muhtasim-Rasheed:issue-164504-add-help-message
Closed

Muhtasim-Rasheed wants to merge 1 commit into
rust-lang:mainfrom
Muhtasim-Rasheed:issue-164504-add-help-message

Conversation

@Muhtasim-Rasheed

@Muhtasim-Rasheed Muhtasim-Rasheed commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #164504

When a closure parameter has no type annotation, its type is inferred from the first call which fixes a single lifetime for the parameter instead of making the closure higher-ranked. If a later call passes a shorter borrow, it fails with E0597 and nothing points at the cause. If the region in the error comes from the type of a closure bound with "let", and the borrow goes into a call argument whose parameter has no annotation, suggest ": &_" for that parameter

When a closure parameter has no type annotation, its type is inferred
from the first call which fixes a single lifetime for the parameter
instead of making the closure higher-ranked. If a later call passes a
shorter borrow, it fails with E0597 and nothing points at the cause.
If the region in the error comes from the type of a closure bound with
"let", and the borrow goes into a call argument whose parameter has no
annotation, suggest ": &_" for that parameter.
@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 24, 2026
@rustbot

rustbot commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator

r? @folkertdev

rustbot has assigned @folkertdev.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: borrowck, compiler
  • borrowck, compiler expanded to 77 candidates
  • Random selection from 17 candidates

@fmease

fmease commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

At a glance, this PR looks like a duplicate of open PR #163648. Similarly, the corresponding issue, #164504, could be a duplicate of issue #163475.

Disclaimer: This is just a shallow drive-by review.

@Muhtasim-Rasheed

Copy link
Copy Markdown
Contributor Author

Thanks @fmease. I built #163648 and tested it against the snippet from #164504, and it suggests there too, so this PR is redundant. Closing in favor of #163648

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 25, 2026
@Muhtasim-Rasheed
Muhtasim-Rasheed deleted the issue-164504-add-help-message branch October 25, 2026 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Add a help in borrow checker for some strangly early bind closures

4 participants