Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions crates/ty_python_semantic/src/semantic_index/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ 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,
Expand Down
15 changes: 3 additions & 12 deletions crates/ty_python_semantic/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6937,12 +6937,7 @@ impl TypeVarKind {
/// This represents the core identity of a typevar, independent of its bounds or constraints. Two
/// typevars have the same identity if they represent the same logical typevar, even if their
/// bounds have been materialized differently.
///
/// # Ordering
/// Ordering is based on the identity's salsa-assigned id and not on its values.
/// The id may change between runs, or when the identity was garbage collected and recreated.
#[salsa::interned(debug, heap_size=ruff_memory_usage::heap_size)]
#[derive(PartialOrd, Ord)]
pub struct TypeVarIdentity<'db> {
/// The name of this TypeVar (e.g. `T`)
#[returns(ref)]
Expand Down Expand Up @@ -7479,9 +7474,7 @@ fn lazy_default_cycle_recover<'db>(
}

/// Where a type variable is bound and usable.
#[derive(
Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, salsa::Update, get_size2::GetSize,
)]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, salsa::Update, get_size2::GetSize)]
pub enum BindingContext<'db> {
/// The definition of the generic class, function, or type alias that binds this typevar.
Definition(Definition<'db>),
Expand Down Expand Up @@ -7509,7 +7502,7 @@ impl<'db> BindingContext<'db> {
}
}

#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, get_size2::GetSize)]
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, get_size2::GetSize)]
pub enum ParamSpecAttrKind {
Args,
Kwargs,
Expand All @@ -7530,9 +7523,7 @@ impl std::fmt::Display for ParamSpecAttrKind {
/// independent of the typevar's bounds or constraints. Two bound typevars have the same identity
/// if they represent the same logical typevar bound in the same context, even if their bounds
/// have been materialized differently.
#[derive(
Debug, Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd, get_size2::GetSize, salsa::Update,
)]
#[derive(Debug, Clone, Copy, Eq, Hash, PartialEq, get_size2::GetSize, salsa::Update)]
pub struct BoundTypeVarIdentity<'db> {
pub(crate) identity: TypeVarIdentity<'db>,
pub(crate) binding_context: BindingContext<'db>,
Expand Down
2 changes: 1 addition & 1 deletion crates/ty_python_semantic/src/types/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ impl<'db> Type<'db> {

Type::KnownInstance(KnownInstanceType::ConstraintSet(tracked_set)) => {
let constraints = ConstraintSetBuilder::new();
let tracked_set = constraints.load(tracked_set.constraints(db));
let tracked_set = constraints.load(db, tracked_set.constraints(db));
Truthiness::from(tracked_set.is_always_satisfied(db))
}

Expand Down
15 changes: 9 additions & 6 deletions crates/ty_python_semantic/src/types/call/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1806,7 +1806,7 @@ impl<'db> Bindings<'db> {
ty_a.when_subtype_of_assuming(
db,
*ty_b,
constraints.load(tracked.constraints(db)),
constraints.load(db, tracked.constraints(db)),
constraints,
InferableTypeVars::None,
)
Expand All @@ -1830,8 +1830,8 @@ impl<'db> Bindings<'db> {

let constraints = ConstraintSetBuilder::new();
let result = constraints.into_owned(|constraints| {
let lhs = constraints.load(tracked.constraints(db));
let rhs = constraints.load(other.constraints(db));
let lhs = constraints.load(db, tracked.constraints(db));
let rhs = constraints.load(db, other.constraints(db));
lhs.implies(db, constraints, || rhs)
});
let tracked = InternedConstraintSet::new(db, result);
Expand Down Expand Up @@ -1871,9 +1871,12 @@ impl<'db> Bindings<'db> {
};

let constraints = ConstraintSetBuilder::new();
let set = constraints.load(tracked.constraints(db));
let result =
set.satisfied_by_all_typevars(db, InferableTypeVars::One(&inferable));
let set = constraints.load(db, tracked.constraints(db));
let result = set.satisfied_by_all_typevars(
db,
&constraints,
InferableTypeVars::One(&inferable),
);
overload.set_return_type(Type::bool_literal(result));
}

Expand Down
Loading