rust-lang / rust-lang/rust-clippy
False positive for `await_holding_refcell_ref`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
I tried this code:
let mut state = self.state.borrow_mut();
let handles = state.cancel_all_in_flight();
drop(state);
let to_cancel = handles.len();
let cancelled = stream::iter(handles).then(|f| f).count().await;
I expected to see this happen: No error since the RefMut is explicitly dropped before the await
Instead, this happened: Brought up a warning
This happens in the recently promoted beta.
This should be pretty easy to fix. As a short term mitigation, I will downgrade the check from correctness and should hopefully be able to work on the fix next week.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the supplied Rust example with the await_holding_refcell_ref lint enabled, then trace that lint's implementation and existing regression tests in rust-clippy. The fix is complete when an explicitly dropped RefMut before the await no longer produces the warning, while the lint still catches a borrow held across await.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100