rust-lang / rust-lang/rust-clippy

Lint for locals living through yield points even though they're not used anymore

Open
#4,893 0 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-lint L-correctness T-async-await
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

I tend to not analyze when or in what order locals go out of scope in sync code unless compiler starts complaining. And it seems OK to mostly not care because everything's going to be dropped shortly. I imagine other people might have the same attitude.

With locals being held across yield points in async methods, it might turn out to be much more problematic. While there are cases when you'd get reminded quickly (e.g. !Send local in Future + Send) Notable mishaps that I can imagine:

  • unnecessarily holding on to response data from after first await that was used to create next request. People don't really want to hold on to something they don't need. Especially if it's a few KBs in size and future will not complete for another minute. And there's 5K futures / sec like that.
  • taking lock and mistakenly thinking that it's released. I think it is rare to need to lock across yield points.
  • generally assuming drop will happen at yield point and planning logic with that in mind.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. Start by defining the diagnostic and scope for locals retained across yield points, then locate the relevant Clippy analysis and test area; done should include agreed behavior and coverage for the described async cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.