mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 06:42:02 +00:00
![]()
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / Fuzz for new ty panics (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / check playground (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
[ty Playground] Release / publish (push) Waiting to run
Summary -- I thought that emitting multiple diagnostics at once would be difficult to port to a diagnostic construction model closer to ty's `InferContext::report_lint`, so as a first step toward that, this PR removes `Checker::report_diagnostics`. In many cases I was able to do some related refactoring to avoid allocating a `Vec<Diagnostic>` at all, often by adding a `Checker` field to a `Visitor` or by passing a `Checker` instead of a `&mut Vec<Diagnostic>`. In other cases, I had to fall back on something like ```rust for diagnostic in diagnostics { checker.report_diagnostic(diagnostic); } ``` which I guess is a bit worse than the `extend` call in `report_diagnostics`, but hopefully it won't make too much of a difference. I'm still not quite sure what to do with the remaining loop cases. The two main use cases for collecting a sequence of diagnostics before emitting any of them are: 1. Applying a single `Fix` to a group of diagnostics 2. Avoiding an earlier diagnostic if something goes wrong later I was hoping we could get away with just a `DiagnosticGuard` that reported a `Diagnostic` on drop, but I guess we will still need a `DiagnosticGuardBuilder` that can be collected in these cases and produce a `DiagnosticGuard` once we know we actually want the diagnostics. Test Plan -- Existing tests |
||
---|---|---|
.. | ||
resources | ||
src | ||
Cargo.toml |