ruff/crates/ruff_db/src
Brent Westbrook fd335eb8b7
Move fix suggestion to subdiagnostic (#19464)
Summary
--

This PR tweaks Ruff's internal usage of the new diagnostic model to more
closely
match the intended use, as I understand it. Specifically, it moves the
fix/help
suggestion from the primary annotation's message to a subdiagnostic. In
turn, it
adds the secondary/noqa code as the new primary annotation message. As
shown in
the new `ruff_db` tests, this more closely mirrors Ruff's current
diagnostic
output.

I also added `Severity::Help` to render the fix suggestion with a
`help:` prefix
instead of `info:`.

These changes don't have any external impact now but should help a bit
with #19415.

Test Plan
--

New full output format tests in `ruff_db`

Rendered Diagnostics
--

Full diagnostic output from `annotate-snippets` in this PR:

``` 
error[unused-import]: `os` imported but unused
  --> fib.py:1:8
   |
 1 | import os
   |        ^^
   |
 help: Remove unused import: `os`
```

Current Ruff output for the same code:

```
fib.py:1:8: F401 [*] `os` imported but unused
  |
1 | import os
  |        ^^ F401
  |
  = help: Remove unused import: `os`
```

Proposed final output after #19415:

``` 
F401 [*] `os` imported but unused
  --> fib.py:1:8
   |
 1 | import os
   |        ^^
   |
 help: Remove unused import: `os`
```

These are slightly updated from
https://github.com/astral-sh/ruff/pull/19464#issuecomment-3097377634
below to remove the extra noqa codes in the primary annotation messages
for the first and third cases.
2025-07-22 10:03:58 -04:00
..
diagnostic Move fix suggestion to subdiagnostic (#19464) 2025-07-22 10:03:58 -04:00
files [ty] Add caching for submodule completion suggestions (#19408) 2025-07-18 11:54:27 -04:00
system [ty] Support LSP go-to with vendored typeshed stubs (#19057) 2025-07-02 07:58:58 -04:00
vendored [ty] Move SystemOrVendoredPathRef 2025-07-11 10:06:35 -04:00
display.rs Upgrade Rust toolchain to 1.83 (#14677) 2024-11-29 12:05:05 +00:00
file_revision.rs [red-knot] Use web-time instead of FileTime::now (#16967) 2025-03-25 13:03:30 +00:00
files.rs [ty] Reduce size of TypeInference (#19435) 2025-07-22 11:36:36 +02:00
lib.rs [ty] Fix server version (#19284) 2025-07-14 09:06:34 +02:00
panic.rs [ty] Gracefully handle salsa cancellations and panics in background request handlers (#18254) 2025-05-26 13:37:49 +01:00
parsed.rs [ty] Add environment variable to dump Salsa memory usage stats (#18928) 2025-06-26 21:27:51 +00:00
source.rs [ty] Reduce size of TypeInference (#19435) 2025-07-22 11:36:36 +02:00
system.rs [ty] Support LSP go-to with vendored typeshed stubs (#19057) 2025-07-02 07:58:58 -04:00
testing.rs Update salsa past generational id change (#18362) 2025-05-30 15:31:33 +02:00
vendored.rs [ty] Document path separator usage in VendoredFileSystem 2025-07-11 10:06:35 -04:00