mirror of
https://github.com/astral-sh/ruff.git
synced 2026-11-22 03:45:35 +08:00
Summary -- This PR fixes #23587 by removing this `std::mem::take` call: https://github.com/astral-sh/ruff/blob/a62ba8c6e2bac0b899d90fd30a1b26c07aac44bb/crates/ruff_linter/src/checkers/ast/analyze/definitions.rs#L120 This was previously moving the `Definitions` out of the `Checker` and causing this operation to panic if the definitions were accessed in a later analysis phase: https://github.com/astral-sh/ruff/blob/a62ba8c6e2bac0b899d90fd30a1b26c07aac44bb/crates/ruff_linter/src/checkers/ast/analyze/definitions.rs#L120 which was apparently never done before `PLR1712` was added. I don't see any reason why this really needed to be a move as it only took a couple of lifetimes to handle it with borrowing, so this seems like the easiest fix. I also changed the indexing operation to a `get` call (with a `debug_assert`) since the method already returns an `Option`, but doing that alone would prevent `PLR1712` from firing in the module scope. Test Plan -- A new test based on the issue that also covers the module scope mentioned above