ruff/crates/ty_python_semantic
Alex Waygood ce8b744f17
[ty] Only calculate information for unresolved-reference subdiagnostic if we know we'll emit the diagnostic (#18465)
## Summary

This optimizes some of the logic added in
https://github.com/astral-sh/ruff/pull/18444. In general, we only
calculate information for subdiagnostics if we know we'll actually emit
the diagnostic. The check to see whether we'll emit the diagnostic is
work we'll definitely have to do whereas the the work to gather
information for a subdiagnostic isn't work we necessarily have to do if
the diagnostic isn't going to be emitted at all.

This PR makes us lazier about gathering the information we need for the
subdiagnostic, and moves all the subdiagnostic logic into one function
rather than having some `unresolved-reference` subdiagnostic logic in
`infer.rs` and some in `diagnostic.rs`.

## Test Plan

`cargo test -p ty_python_semantic`
2025-06-04 20:41:00 +01:00
..
resources [ty] Only calculate information for unresolved-reference subdiagnostic if we know we'll emit the diagnostic (#18465) 2025-06-04 20:41:00 +01:00
src [ty] Only calculate information for unresolved-reference subdiagnostic if we know we'll emit the diagnostic (#18465) 2025-06-04 20:41:00 +01:00
tests Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
Cargo.toml Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
build.rs Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
mdtest.py Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00
mdtest.py.lock Rename Red Knot (#17820) 2025-05-03 19:49:15 +02:00