ruff/crates
Brent Westbrook c713e76e4d
Add a SourceFile to OldDiagnostic (#18356)
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
2025-05-30 13:34:38 +00:00
..
ruff Add a SourceFile to OldDiagnostic (#18356) 2025-05-30 13:34:38 +00:00
ruff_annotate_snippets Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_benchmark [ty] Add --config-file CLI arg (#18083) 2025-05-27 08:00:38 +02:00
ruff_cache Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_db Update salsa past generational id change (#18362) 2025-05-30 15:31:33 +02:00
ruff_dev Add a ViolationMetadata::rule method (#18234) 2025-05-28 09:27:09 -04:00
ruff_diagnostics Add a ViolationMetadata::rule method (#18234) 2025-05-28 09:27:09 -04:00
ruff_formatter Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_graph [ty] Tell the user why we inferred the Python version we inferred (#18082) 2025-05-21 11:06:27 -04:00
ruff_index Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_linter Add a SourceFile to OldDiagnostic (#18356) 2025-05-30 13:34:38 +00:00
ruff_macros Add a ViolationMetadata::rule method (#18234) 2025-05-28 09:27:09 -04:00
ruff_notebook Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_options_metadata [ty] Document configuration schema (#17950) 2025-05-09 10:47:45 +02:00
ruff_python_ast ty_ide: improve completions by using scopes 2025-05-29 10:31:30 -04:00
ruff_python_ast_integration_tests Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_codegen Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_formatter Preserve tuple parentheses in case patterns (#18147) 2025-05-22 07:52:21 +02:00
ruff_python_index Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_literal Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_parser ruff_python_parser: add Tokens::before method 2025-05-29 10:31:30 -04:00
ruff_python_resolver Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_semantic Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_stdlib Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_trivia Add offset method to ruff_python_trivia::Cursor (#18371) 2025-05-29 16:08:15 +01:00
ruff_python_trivia_integration_tests Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_server Add a ViolationMetadata::rule method (#18234) 2025-05-28 09:27:09 -04:00
ruff_source_file Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_text_size Add rustfmt.toml file (#18197) 2025-05-19 11:40:58 -04:00
ruff_wasm Bump 0.11.12 (#18369) 2025-05-29 09:17:12 -04:00
ruff_workspace Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ty [ty] Split Type::KnownInstance into two type variants (#18350) 2025-05-29 14:47:55 +01:00
ty_ide ty_ide: improve completions by using scopes 2025-05-29 10:31:30 -04:00
ty_project [ty] Support publishing diagnostics in the server (#18309) 2025-05-28 13:15:11 +05:30
ty_python_semantic Update salsa past generational id change (#18362) 2025-05-30 15:31:33 +02:00
ty_server [ty] Support cancellation and retry in the server (#18273) 2025-05-28 10:59:29 +02:00
ty_test Add offset method to ruff_python_trivia::Cursor (#18371) 2025-05-29 16:08:15 +01:00
ty_vendored [ty] Type compendium (#18263) 2025-05-23 11:41:31 +02:00
ty_wasm [ty] Gracefully handle salsa cancellations and panics in background request handlers (#18254) 2025-05-26 13:37:49 +01:00