Summary
--
There were several new cargo and clippy lints here, so I tried to break
up the changes into several
commits:
- deleting some unused workspace dependencies, these looked kind of
intentional as they also had
some shear ignores, but it seems okay to delete those too?
- allowing the [redundant_homepage] lint. We could delete a lot of
these, but the ones in the `ruff`
and `ty` crates seem necessary for maturin, as I noted in a comment.
- fixing the [missing_lints_inheritance] lint. It seems that several of
our crates don't inherit our
workspace lints. For now I just included the `allow` for
`redundant_homepage`, but we could follow
up by inheriting the full table and fixing all the additional lints that
produces. (This commit is
actually combined with the previous one)
- allowing cargo's new [unused_dependencies] lint, which seems redundant
with `shear` and had some
false positives on our benchmark dependencies. Codex tried to work
around this with some
`cfg`-gated imports in the benchmark crate, but ignoring this seemed
better for now, at least
while we're still using `shear`.
- running `clippy --fix` on the remaining lint errors, with one manual
intervention where Clippy
dropped some of our `cfg` handling. These new diagnostics were mostly
around returning boolean
expressions.
- renaming `NodeIndex::_NONE` to avoid [used_underscore_items]
There are also some new APIs in 1.98 that we can use now. I'll follow up
with those separately.
[redundant_homepage]:
https://doc.rust-lang.org/cargo/reference/lints.html#redundant_homepage
[missing_lints_inheritance]:
https://doc.rust-lang.org/cargo/reference/lints.html#missing_lints_inheritance
[used_underscore_items]:
https://clippy.rust-lang.org/master/#used_underscore_items
[unused_dependencies]:
https://doc.rust-lang.org/cargo/reference/lints.html#unused_dependencies
## Summary
The `max_diagnostics` checks on our real-world benchmarks were
originally introduced as "stopgap" solution, a form of sanity check
([original
discussion](https://github.com/astral-sh/ruff/pull/18714#discussion_r2154190510)).
But I would argue that they are mostly a waste of developer time (they
had to be adapted ~60 times) and have never actually caught a
regression. The benchmark projects are also pinned now, so we should be
immune to external changes.
I'm proposing to remove these diagnostic limits and to add a new form of
sanity check, which looks for I/O errors or panics.
## Summary
We now run Hawk 0.1.13 with Rust 1.98.0 in CI, following the pattern
used by uv. The configuration preserves intentional public APIs and
generated interfaces while checking all configured production binaries
and workspace non-production targets with `-D warnings`.
The accompanying cleanup narrows internal visibility, removes unused
benchmark classification state and accessors, and records intentional
public interfaces as audited Hawk expectations. The resulting
configuration reports zero Hawk findings across the configured targets.
## Summary
This unifies the validation of supported Python versions between the CLI
and TOML (e.g., `environment.python-version`) by introducing a single
enum to share across them.
For awhile we've known that our constraint sets can balloon in size when
they involve large unions, and especially intersections of large unions.
And we've had ecosystem runs (typically involving projects that depend
on numpy) that trigger this pathological behavior. #23848 is the latest
example, with a 25× performance regression for the `mesonbuild` project.
Guillaume Duboc just defended his [PhD
thesis](https://gldubc.github.io/#thesis) in January, and in §11.2, he
calls out an optimization first introduced by Frisch for handling these
kinds of unions more efficiently. The approach is also described in [a
post](https://elixir-lang.org/blog/2025/12/02/lazier-bdds-for-set-theoretic-types/)
on the Elixir blog. (Frisch and Duboc are both using these BDDs to
represent _types_, whereas we're using them to represent _constraints on
types_, but the same ideas apply.)
Frisch describes the basic idea, which is to add an "uncertain" branch
to each BDD node, turning them into ternary decision diagrams (TDDs).
Frisch also provides TDD construction rules for union (OR), intersection
(AND), and difference. Duboc takes this further and derives more
efficient rules for intersection and difference.
This PR implements TDDs and Frisch's and Duboc's construction rules.
I've confirmed that this completely eliminates the performance
regression for `mesonbuild` on #23848.
---
More details on how this works, and why we get these savings:
The key benefit is that they let us represent unions more efficiently.
As a simple example, with our quasi-reduced BDDs from before, `a ∨ b`
becomes:
```
<n1> a
┡━₁ <n2> b
│ ┡━₁ true
│ └─₀ true
└─₀ <n3> b
┡━₁ true
└─₀ false
```
With TDDs, the rhs of `a ∨ b` is moved into the new "uncertain" branch:
```
<t1> a
┡━₁ true
├─? <t2> b
│ ┡━₁ true
│ ├─? false
│ └─₀ false
└─₀ false
```
We already have some savings, since the TDD representation "allows
unions to be kept lazy, postponing expansion until needed for
intersection or difference operations". We "park" the rhs as-is into the
uncertain branch, so we only need one (existing) copy of it. In the BDD
case, we had to fold the rhs into the `a = true` case, creating an
entire (modified) copy of its subgraph. That means we only need 2 nodes
for the TDD instead of 3 for the BDD. (With only two variables, this
might not seem like a lot, but we've actually gone from O(n²) nodes to
O(n).)
We get even more savings when with more complex formulas, like `(a ∨ b)
∧ (c ∨ d)`. With BDDs, we get:
```
<n1> a <n7> a
┡━₁ <n2> b ┡━₁ <n8> b
│ ┡━₁ true │ ┡━₁ <n4> c
│ └─₀ true │ │ ┡━₁ <n5> d
└─₀ <n3> b │ │ │ ┡━₁ true
┡━₁ true │ │ │ └─₀ true
└─₀ false │ │ └─₀ <n6> d
│ │ ┡━₁ true
<n4> c │ │ └─₀ false
┡━₁ <n5> d │ └─₀ <n4> SHARED
│ ┡━₁ true └─₀ <n9> b
│ └─₀ true ┡━₁ <n4> SHARED
└─₀ <n6> d └─₀ false
┡━₁ true
└─₀ false
```
With TDDs, we get:
```
<t1> a <t5> a
┡━₁ true ┡━₁ <t3> c
├─? <t2> b │ ┡━₁ true
│ ┡━₁ true │ ├─? <t4> d
│ ├─? false │ │ ┡━₁ true
│ └─₀ false │ │ ├─? false
└─₀ false │ │ └─₀ false
│ └─₀ false
<t3> c ├─? <t6> b
┡━₁ true │ ┡━₁ <t3> SHARED
├─? <t4> d │ ├─? false
│ ┡━₁ true │ └─₀ false
│ ├─? false └─₀ false
│ └─₀ false
└─₀ false
```
That's 7 nodes for the BDDs, and 4 for TDDs — still linear in the total
number of variables, even though our BDDs are only quasi-reduced. And
also note that we never had to modify the TDD that represented the rhs
of the AND (`t3 = c ∨ d`).
Changes the red-knot benchmark to run on the stdlib "tomllib" library
(which is self-contained, four files, uses type annotations) instead of
on very small bits of handwritten code.
Also remove the `without_parse` benchmark: now that we are running on
real code that uses typeshed, we'd either have to pre-parse all of
typeshed (slow) or find some way to determine which typeshed modules
will be used by the benchmark (not feasible with reasonable complexity.)
## Test Plan
`cargo bench -p ruff_benchmark --bench red_knot`