Skip to content

False positive for await_holding_refcell_ref #6353

Open

Description

@Daniel-B-Smith

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.

Activity

  1. added
    C-bug
    on Nov 20, 2020
  2. added 2 commits that reference this issue on Nov 20, 2020
  3. added
    I-false-positive
    on Dec 18, 2020
  4. khuey commented on Jan 6, 2021

    @khuey
    Contributor

    Any progress here?

  5. Daniel-B-Smith commented on Jan 13, 2021

    @Daniel-B-Smith
    Author

    Apologies for the lack of communication. From conversations on Zulip, it is in fact not an easy fix to identify variables that have been explicitly dropped. I intended to add the documentation quickly, but got caught up in things. I just sent out #6585. Unfortunately, I don't have the cycles to dig into this deeply right now.

  6. added
    E-hard
    on Jan 17, 2021
  7. added 2 commits that reference this issue on Jan 17, 2021
  8. Ralith commented on May 21, 2022

    @Ralith
    Contributor

    This lint seems to have been enabled by default in 1.61 and is still producing false positives, breaking my CI.

  9. Ralith commented on Jun 18, 2022

    @Ralith
    Contributor

    Bump. This is still breaking my CI. Can we get it rolled back?

  10. cbiffle commented on Nov 9, 2025

    @cbiffle

    I believe this class of false positive was fixed -- I'm working on code that's doing explicit dropping of RefMuts in complex loops without any false positives from Clippy (though I have gotten a couple of true-positives!).

  11. AaronDewes commented on Nov 12, 2025

    @AaronDewes

    I've still been getting such false positives with Rust 1.91 ( clippy 0.1.91 (f8297e351a 2025-10-28) ), so it does not appear to be fully fixed.

  12. Jarcho commented on Nov 12, 2025

    @Jarcho
    Contributor

    This still has no fix. If the scope of a binding extends past an await point it's erroneously assumed to be live by this lint. This isn't trivial to fix since this requires dataflow analysis to determine the value of any drop flags at await points. Alternatively the compiler could be changed to not store such values in the generator, although I'm not sure how that interacts with potential panics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugE-hardI-false-positive

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions