mirror of
https://github.com/astral-sh/ruff
synced 2026-01-21 13:30:49 -05:00
Summary -- This is the last main difference between the `OldDiagnostic` and `Message` types, so attaching a `SourceFile` to `OldDiagnostic` should make combining the two types almost trivial. Initially I updated the remaining rules without access to a `Checker` to take a `&SourceFile` directly, but after Micha's suggestion in https://github.com/astral-sh/ruff/pull/18356#discussion_r2113281552, I updated all of these calls to take a `LintContext` instead. This new type is a thin wrapper around a `RefCell<Vec<OldDiagnostic>>` and a `SourceFile` and now has the `report_diagnostic` method returning a `DiagnosticGuard` instead of `Checker`. This allows the same `Drop`-based implementation to be used in cases without a `Checker` and also avoids a lot of intermediate allocations of `Vec<OldDiagnostic>`s. `Checker` now also contains a `LintContext`, which it defers to for its `report_diagnostic` methods, which I preserved for convenience. Test Plan -- Existing tests