Update salsa (#18212)

This commit is contained in:
Micha Reiser 2025-05-20 09:19:34 +02:00 committed by GitHub
parent f9ca6eb63e
commit 3b56c7ca3d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 82 additions and 10 deletions

8
Cargo.lock generated
View file

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3 version = 4
[[package]] [[package]]
name = "adler2" name = "adler2"
@ -3180,7 +3180,7 @@ checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f"
[[package]] [[package]]
name = "salsa" name = "salsa"
version = "0.21.1" version = "0.21.1"
source = "git+https://github.com/salsa-rs/salsa.git?rev=7edce6e248f35c8114b4b021cdb474a3fb2813b3#7edce6e248f35c8114b4b021cdb474a3fb2813b3" source = "git+https://github.com/salsa-rs/salsa.git?rev=4818b15f3b7516555d39f5a41cb75970448bee4c#4818b15f3b7516555d39f5a41cb75970448bee4c"
dependencies = [ dependencies = [
"boxcar", "boxcar",
"compact_str", "compact_str",
@ -3203,12 +3203,12 @@ dependencies = [
[[package]] [[package]]
name = "salsa-macro-rules" name = "salsa-macro-rules"
version = "0.21.1" version = "0.21.1"
source = "git+https://github.com/salsa-rs/salsa.git?rev=7edce6e248f35c8114b4b021cdb474a3fb2813b3#7edce6e248f35c8114b4b021cdb474a3fb2813b3" source = "git+https://github.com/salsa-rs/salsa.git?rev=4818b15f3b7516555d39f5a41cb75970448bee4c#4818b15f3b7516555d39f5a41cb75970448bee4c"
[[package]] [[package]]
name = "salsa-macros" name = "salsa-macros"
version = "0.21.1" version = "0.21.1"
source = "git+https://github.com/salsa-rs/salsa.git?rev=7edce6e248f35c8114b4b021cdb474a3fb2813b3#7edce6e248f35c8114b4b021cdb474a3fb2813b3" source = "git+https://github.com/salsa-rs/salsa.git?rev=4818b15f3b7516555d39f5a41cb75970448bee4c#4818b15f3b7516555d39f5a41cb75970448bee4c"
dependencies = [ dependencies = [
"heck", "heck",
"proc-macro2", "proc-macro2",

View file

@ -129,7 +129,7 @@ regex = { version = "1.10.2" }
rustc-hash = { version = "2.0.0" } rustc-hash = { version = "2.0.0" }
rustc-stable-hash = { version = "0.1.2" } rustc-stable-hash = { version = "0.1.2" }
# When updating salsa, make sure to also update the revision in `fuzz/Cargo.toml` # When updating salsa, make sure to also update the revision in `fuzz/Cargo.toml`
salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "7edce6e248f35c8114b4b021cdb474a3fb2813b3" } salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "4818b15f3b7516555d39f5a41cb75970448bee4c" }
schemars = { version = "0.8.16" } schemars = { version = "0.8.16" }
seahash = { version = "4.1.0" } seahash = { version = "4.1.0" }
serde = { version = "1.0.197", features = ["derive"] } serde = { version = "1.0.197", features = ["derive"] }

View file

@ -275,7 +275,12 @@ impl fmt::Debug for Files {
impl std::panic::RefUnwindSafe for Files {} impl std::panic::RefUnwindSafe for Files {}
/// A file that's either stored on the host system's file system or in the vendored file system. /// A file that's either stored on the host system's file system or in the vendored file system.
///
/// # Ordering
/// Ordering is based on the file's salsa-assigned id and not on its values.
/// The id may change between runs.
#[salsa::input] #[salsa::input]
#[derive(PartialOrd, Ord)]
pub struct File { pub struct File {
/// The path of the file (immutable). /// The path of the file (immutable).
#[returns(ref)] #[returns(ref)]

View file

@ -13,11 +13,10 @@ pub use hover::hover;
pub use inlay_hints::inlay_hints; pub use inlay_hints::inlay_hints;
pub use markup::MarkupKind; pub use markup::MarkupKind;
use rustc_hash::FxHashSet;
use std::ops::{Deref, DerefMut};
use ruff_db::files::{File, FileRange}; use ruff_db::files::{File, FileRange};
use ruff_text_size::{Ranged, TextRange}; use ruff_text_size::{Ranged, TextRange};
use rustc_hash::FxHashSet;
use std::ops::{Deref, DerefMut};
use ty_python_semantic::types::{Type, TypeDefinition}; use ty_python_semantic::types::{Type, TypeDefinition};
/// Information associated with a text range. /// Information associated with a text range.

View file

@ -335,7 +335,12 @@ pub use crate::types::definition::TypeDefinition;
pub(crate) use todo_type; pub(crate) use todo_type;
/// Represents an instance of `builtins.property`. /// Represents an instance of `builtins.property`.
///
/// # Ordering
/// Ordering is based on the property instance's salsa-assigned id and not on its values.
/// The id may change between runs, or when the property instance was garbage collected and recreated.
#[salsa::interned(debug)] #[salsa::interned(debug)]
#[derive(PartialOrd, Ord)]
pub struct PropertyInstanceType<'db> { pub struct PropertyInstanceType<'db> {
getter: Option<Type<'db>>, getter: Option<Type<'db>>,
setter: Option<Type<'db>>, setter: Option<Type<'db>>,
@ -438,6 +443,7 @@ impl Default for DataclassTransformerParams {
} }
/// Representation of a type: a set of possible values at runtime. /// Representation of a type: a set of possible values at runtime.
///
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, salsa::Update)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, salsa::Update)]
pub enum Type<'db> { pub enum Type<'db> {
/// The dynamic type: a statically unknown set of values /// The dynamic type: a statically unknown set of values
@ -5825,7 +5831,12 @@ pub enum TypeVarKind {
/// typevar represents as an annotation: that is, an unknown set of objects, constrained by the /// typevar represents as an annotation: that is, an unknown set of objects, constrained by the
/// upper-bound/constraints on this type var, defaulting to the default type of this type var when /// upper-bound/constraints on this type var, defaulting to the default type of this type var when
/// not otherwise bound to a type. /// not otherwise bound to a type.
///
/// # Ordering
/// Ordering is based on the type var instance's salsa-assigned id and not on its values.
/// The id may change between runs, or when the type var instance was garbage collected and recreated.
#[salsa::interned(debug)] #[salsa::interned(debug)]
#[derive(PartialOrd, Ord)]
pub struct TypeVarInstance<'db> { pub struct TypeVarInstance<'db> {
/// The name of this TypeVar (e.g. `T`) /// The name of this TypeVar (e.g. `T`)
#[returns(ref)] #[returns(ref)]
@ -6745,7 +6756,11 @@ impl<'db> OverloadedFunction<'db> {
} }
} }
/// # Ordering
/// Ordering is based on the function type's salsa-assigned id and not on its values.
/// The id may change between runs, or when the function type was garbage collected and recreated.
#[salsa::interned(debug)] #[salsa::interned(debug)]
#[derive(PartialOrd, Ord)]
pub struct FunctionType<'db> { pub struct FunctionType<'db> {
/// Name of the function at definition. /// Name of the function at definition.
#[returns(ref)] #[returns(ref)]
@ -7368,7 +7383,12 @@ impl KnownFunction {
/// on an instance of a class. For example, the expression `Path("a.txt").touch` creates /// on an instance of a class. For example, the expression `Path("a.txt").touch` creates
/// a bound method object that represents the `Path.touch` method which is bound to the /// a bound method object that represents the `Path.touch` method which is bound to the
/// instance `Path("a.txt")`. /// instance `Path("a.txt")`.
///
/// # Ordering
/// Ordering is based on the bounded method's salsa-assigned id and not on its values.
/// The id may change between runs, or when the bounded method was garbage collected and recreated.
#[salsa::interned(debug)] #[salsa::interned(debug)]
#[derive(PartialOrd, Ord)]
pub struct BoundMethodType<'db> { pub struct BoundMethodType<'db> {
/// The function that is being bound. Corresponds to the `__func__` attribute on a /// The function that is being bound. Corresponds to the `__func__` attribute on a
/// bound method object /// bound method object
@ -7434,7 +7454,12 @@ impl<'db> BoundMethodType<'db> {
/// It can be written in type expressions using `typing.Callable`. `lambda` expressions are /// It can be written in type expressions using `typing.Callable`. `lambda` expressions are
/// inferred directly as `CallableType`s; all function-literal types are subtypes of a /// inferred directly as `CallableType`s; all function-literal types are subtypes of a
/// `CallableType`. /// `CallableType`.
///
/// # Ordering
/// Ordering is based on the callable type's salsa-assigned id and not on its values.
/// The id may change between runs, or when the callable type was garbage collected and recreated.
#[salsa::interned(debug)] #[salsa::interned(debug)]
#[derive(PartialOrd, Ord)]
pub struct CallableType<'db> { pub struct CallableType<'db> {
#[returns(deref)] #[returns(deref)]
signatures: Box<[Signature<'db>]>, signatures: Box<[Signature<'db>]>,
@ -7801,7 +7826,11 @@ pub enum WrapperDescriptorKind {
PropertyDunderSet, PropertyDunderSet,
} }
/// # Ordering
/// Ordering is based on the module literal's salsa-assigned id and not on its values.
/// The id may change between runs, or when the module literal was garbage collected and recreated.
#[salsa::interned(debug)] #[salsa::interned(debug)]
#[derive(PartialOrd, Ord)]
pub struct ModuleLiteralType<'db> { pub struct ModuleLiteralType<'db> {
/// The file in which this module was imported. /// The file in which this module was imported.
/// ///
@ -7850,7 +7879,11 @@ impl<'db> ModuleLiteralType<'db> {
} }
} }
/// # Ordering
/// Ordering is based on the type alias's salsa-assigned id and not on its values.
/// The id may change between runs, or when the alias was garbage collected and recreated.
#[salsa::interned(debug)] #[salsa::interned(debug)]
#[derive(PartialOrd, Ord)]
pub struct PEP695TypeAliasType<'db> { pub struct PEP695TypeAliasType<'db> {
#[returns(ref)] #[returns(ref)]
pub name: ast::name::Name, pub name: ast::name::Name,
@ -7876,7 +7909,11 @@ impl<'db> PEP695TypeAliasType<'db> {
} }
} }
/// # Ordering
/// Ordering is based on the type alias's salsa-assigned id and not on its values.
/// The id may change between runs, or when the alias was garbage collected and recreated.
#[salsa::interned(debug)] #[salsa::interned(debug)]
#[derive(PartialOrd, Ord)]
pub struct BareTypeAliasType<'db> { pub struct BareTypeAliasType<'db> {
#[returns(ref)] #[returns(ref)]
pub name: ast::name::Name, pub name: ast::name::Name,
@ -8380,7 +8417,11 @@ impl<'db> IntersectionType<'db> {
} }
} }
/// # Ordering
/// Ordering is based on the string literal's salsa-assigned id and not on its value.
/// The id may change between runs, or when the string literal was garbage collected and recreated.
#[salsa::interned(debug)] #[salsa::interned(debug)]
#[derive(PartialOrd, Ord)]
pub struct StringLiteralType<'db> { pub struct StringLiteralType<'db> {
#[returns(deref)] #[returns(deref)]
value: Box<str>, value: Box<str>,
@ -8401,7 +8442,11 @@ impl<'db> StringLiteralType<'db> {
} }
} }
/// # Ordering
/// Ordering is based on the byte literal's salsa-assigned id and not on its value.
/// The id may change between runs, or when the byte literal was garbage collected and recreated.
#[salsa::interned(debug)] #[salsa::interned(debug)]
#[derive(PartialOrd, Ord)]
pub struct BytesLiteralType<'db> { pub struct BytesLiteralType<'db> {
#[returns(deref)] #[returns(deref)]
value: Box<[u8]>, value: Box<[u8]>,
@ -8413,7 +8458,11 @@ impl<'db> BytesLiteralType<'db> {
} }
} }
/// # Ordering
/// Ordering is based on the tuple's salsa-assigned id and not on its elements.
/// The id may change between runs, or when the tuple was garbage collected and recreated.
#[salsa::interned(debug)] #[salsa::interned(debug)]
#[derive(PartialOrd, Ord)]
pub struct TupleType<'db> { pub struct TupleType<'db> {
#[returns(deref)] #[returns(deref)]
elements: Box<[Type<'db>]>, elements: Box<[Type<'db>]>,

View file

@ -157,7 +157,12 @@ impl CodeGeneratorKind {
} }
/// A specialization of a generic class with a particular assignment of types to typevars. /// A specialization of a generic class with a particular assignment of types to typevars.
///
/// # Ordering
/// Ordering is based on the generic aliases's salsa-assigned id and not on its values.
/// The id may change between runs, or when the alias was garbage collected and recreated.
#[salsa::interned(debug)] #[salsa::interned(debug)]
#[derive(PartialOrd, Ord)]
pub struct GenericAlias<'db> { pub struct GenericAlias<'db> {
pub(crate) origin: ClassLiteral<'db>, pub(crate) origin: ClassLiteral<'db>,
pub(crate) specialization: Specialization<'db>, pub(crate) specialization: Specialization<'db>,
@ -503,7 +508,12 @@ impl<'db> From<ClassType<'db>> for Type<'db> {
/// ///
/// This does not in itself represent a type, but can be transformed into a [`ClassType`] that /// This does not in itself represent a type, but can be transformed into a [`ClassType`] that
/// does. (For generic classes, this requires specializing its generic context.) /// does. (For generic classes, this requires specializing its generic context.)
///
/// # Ordering
/// Ordering is based on the class's id assigned by salsa and not on the class literal's values.
/// The id may change between runs, or when the class literal was garbage collected and recreated.
#[salsa::interned(debug)] #[salsa::interned(debug)]
#[derive(PartialOrd, Ord)]
pub struct ClassLiteral<'db> { pub struct ClassLiteral<'db> {
/// Name of the class at definition /// Name of the class at definition
#[returns(ref)] #[returns(ref)]

View file

@ -18,7 +18,12 @@ use crate::{Db, FxOrderSet};
/// ///
/// TODO: Handle nested generic contexts better, with actual parent links to the lexically /// TODO: Handle nested generic contexts better, with actual parent links to the lexically
/// containing context. /// containing context.
///
/// # Ordering
/// Ordering is based on the context's salsa-assigned id and not on its values.
/// The id may change between runs, or when the context was garbage collected and recreated.
#[salsa::interned(debug)] #[salsa::interned(debug)]
#[derive(PartialOrd, Ord)]
pub struct GenericContext<'db> { pub struct GenericContext<'db> {
#[returns(ref)] #[returns(ref)]
pub(crate) variables: FxOrderSet<TypeVarInstance<'db>>, pub(crate) variables: FxOrderSet<TypeVarInstance<'db>>,

View file

@ -160,7 +160,7 @@ impl<'db> From<NominalInstanceType<'db>> for Type<'db> {
/// A `ProtocolInstanceType` represents the set of all possible runtime objects /// A `ProtocolInstanceType` represents the set of all possible runtime objects
/// that conform to the interface described by a certain protocol. /// that conform to the interface described by a certain protocol.
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, PartialOrd, Ord, salsa::Update)] #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, salsa::Update, PartialOrd, Ord)]
pub struct ProtocolInstanceType<'db> { pub struct ProtocolInstanceType<'db> {
pub(super) inner: Protocol<'db>, pub(super) inner: Protocol<'db>,

View file

@ -58,7 +58,11 @@ impl<'db> Deref for ProtocolClassLiteral<'db> {
} }
} }
/// # Ordering
/// Ordering is based on the protocol interface member's salsa-assigned id and not on its members.
/// The id may change between runs, or when the protocol instance members was garbage collected and recreated.
#[salsa::interned(debug)] #[salsa::interned(debug)]
#[derive(PartialOrd, Ord)]
pub(super) struct ProtocolInterfaceMembers<'db> { pub(super) struct ProtocolInterfaceMembers<'db> {
#[returns(ref)] #[returns(ref)]
inner: BTreeMap<Name, ProtocolMemberData<'db>>, inner: BTreeMap<Name, ProtocolMemberData<'db>>,

View file

@ -30,7 +30,7 @@ ty_python_semantic = { path = "../crates/ty_python_semantic" }
ty_vendored = { path = "../crates/ty_vendored" } ty_vendored = { path = "../crates/ty_vendored" }
libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer", default-features = false } libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer", default-features = false }
salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "7edce6e248f35c8114b4b021cdb474a3fb2813b3" } salsa = { git = "https://github.com/salsa-rs/salsa.git", rev = "4818b15f3b7516555d39f5a41cb75970448bee4c" }
similar = { version = "2.5.0" } similar = { version = "2.5.0" }
tracing = { version = "0.1.40" } tracing = { version = "0.1.40" }