rust-lang / rust-lang/rust-clippy
await_holding_refcell_ref false negative when inside async block
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Example code
use std::cell::RefCell;
use std::future::Future;
#[allow(unused)]
async fn foo(x: &RefCell<u32>, bar: impl Future<Output=()>) {
async {
let mut y = x.borrow_mut();
*y += 1;
bar.await;
}.await;
}
When running cargo clippy -- -W clippy::pedantic expected the warning this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await. Instead no warning is produced. Removing the async block produces the warning as expected.
Meta
cargo clippy -V:
clippy 0.1.52 (acca8189 2021-03-13)
rustc -Vv:
rustc 1.52.0-nightly (acca81892 2021-03-13)
binary: rustc
commit-hash: acca818928654807ed3bc1ce0e97df118f8716c8
commit-date: 2021-03-13
host: x86_64-pc-windows-msvc
release: 1.52.0-nightly
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 issue with the supplied Rust example using cargo clippy -- -W clippy::pedantic, then compare the result with the version that removes the async block. Trace the await_holding_refcell_ref lint entry point and add coverage so the nested async-block case emits the expected warning without regressing the existing case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100