mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-08 07:23:40 +00:00
[ty] Some more simplifications when rendering constraint sets (#21009)
This PR adds another useful simplification when rendering constraint sets: `T = int` instead of `T = int ∧ T ≠ str`. (The "smaller" constraint `T = int` implies the "larger" constraint `T ≠ str`. Constraint set clauses are intersections, and if one constraint in a clause implies another, we can throw away the "larger" constraint.) While we're here, we also normalize the bounds of a constraint, so that we equate e.g. `T ≤ int | str` with `T ≤ str | int`, and change the ordering of BDD variables so that all constraints with the same typevar are ordered adjacent to each other. Lastly, we also add a new `display_graph` helper method that prints out the full graph structure of a BDD. --------- Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
81c1d36088
commit
766ed5b5f3
6 changed files with 314 additions and 23 deletions
|
|
@ -22,7 +22,12 @@ use crate::unpack::{Unpack, UnpackPosition};
|
|||
/// because a new scope gets inserted before the `Definition` or a new place is inserted
|
||||
/// before this `Definition`. However, the ID can be considered stable and it is okay to use
|
||||
/// `Definition` in cross-module` salsa queries or as a field on other salsa tracked structs.
|
||||
///
|
||||
/// # Ordering
|
||||
/// Ordering is based on the definition's salsa-assigned id and not on its values.
|
||||
/// The id may change between runs, or when the definition was garbage collected and recreated.
|
||||
#[salsa::tracked(debug, heap_size=ruff_memory_usage::heap_size)]
|
||||
#[derive(Ord, PartialOrd)]
|
||||
pub struct Definition<'db> {
|
||||
/// The file in which the definition occurs.
|
||||
pub file: File,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue