Update Rust toolchain to 1.89 (#19807)

This commit is contained in:
Micha Reiser 2025-08-07 18:21:50 +02:00 committed by GitHub
parent b22586fa0e
commit 7dfde3b929
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
101 changed files with 234 additions and 200 deletions

View file

@ -196,7 +196,7 @@ impl<K, V> ListBuilder<K, V> {
/// entries to duplicate for each insertion. If you construct the list in reverse order, we
/// will have to duplicate O(n) entries for each insertion, making it _quadratic_ to construct
/// the entire list.
pub(crate) fn entry(&mut self, list: List<K, V>, key: K) -> ListEntry<K, V>
pub(crate) fn entry(&mut self, list: List<K, V>, key: K) -> ListEntry<'_, K, V>
where
K: Clone + Ord,
V: Clone,
@ -373,7 +373,7 @@ impl<K, V> ListBuilder<K, V> {
impl<K> ListStorage<K, ()> {
/// Iterates through the elements in a set _in reverse order_.
#[expect(clippy::needless_pass_by_value)]
pub(crate) fn iter_set_reverse(&self, set: List<K, ()>) -> ListSetReverseIterator<K> {
pub(crate) fn iter_set_reverse(&self, set: List<K, ()>) -> ListSetReverseIterator<'_, K> {
ListSetReverseIterator {
storage: self,
curr: set.last,

View file

@ -21,7 +21,7 @@ mod typeshed;
mod testing;
/// Returns an iterator over all search paths pointing to a system path
pub fn system_module_search_paths(db: &dyn Db) -> SystemModuleSearchPathsIter {
pub fn system_module_search_paths(db: &dyn Db) -> SystemModuleSearchPathsIter<'_> {
SystemModuleSearchPathsIter {
inner: search_paths(db),
}

View file

@ -153,7 +153,7 @@ pub(crate) fn file_to_module(db: &dyn Db, file: File) -> Option<Module<'_>> {
}
}
pub(crate) fn search_paths(db: &dyn Db) -> SearchPathIterator {
pub(crate) fn search_paths(db: &dyn Db) -> SearchPathIterator<'_> {
Program::get(db).search_paths(db).iter(db)
}

View file

@ -301,7 +301,7 @@ impl<'db> SemanticIndex<'db> {
&self.scopes[id]
}
pub(crate) fn scope_ids(&self) -> impl Iterator<Item = ScopeId> {
pub(crate) fn scope_ids(&self) -> impl Iterator<Item = ScopeId<'db>> + '_ {
self.scope_ids_by_scope.iter().copied()
}
@ -371,18 +371,18 @@ impl<'db> SemanticIndex<'db> {
/// Returns an iterator over the descendent scopes of `scope`.
#[allow(unused)]
pub(crate) fn descendent_scopes(&self, scope: FileScopeId) -> DescendantsIter {
pub(crate) fn descendent_scopes(&self, scope: FileScopeId) -> DescendantsIter<'_> {
DescendantsIter::new(self, scope)
}
/// Returns an iterator over the direct child scopes of `scope`.
#[allow(unused)]
pub(crate) fn child_scopes(&self, scope: FileScopeId) -> ChildrenIter {
pub(crate) fn child_scopes(&self, scope: FileScopeId) -> ChildrenIter<'_> {
ChildrenIter::new(self, scope)
}
/// Returns an iterator over all ancestors of `scope`, starting with `scope` itself.
pub(crate) fn ancestor_scopes(&self, scope: FileScopeId) -> AncestorsIter {
pub(crate) fn ancestor_scopes(&self, scope: FileScopeId) -> AncestorsIter<'_> {
AncestorsIter::new(self, scope)
}
@ -400,7 +400,7 @@ impl<'db> SemanticIndex<'db> {
/// print(x) # Refers to global x=1, not class x=2
/// ```
/// The `method` function can see the global scope but not the class scope.
pub(crate) fn visible_ancestor_scopes(&self, scope: FileScopeId) -> VisibleAncestorsIter {
pub(crate) fn visible_ancestor_scopes(&self, scope: FileScopeId) -> VisibleAncestorsIter<'_> {
VisibleAncestorsIter::new(self, scope)
}

View file

@ -243,7 +243,7 @@ impl MemberExpr {
self.segments.len()
}
pub(crate) fn as_ref(&self) -> MemberExprRef {
pub(crate) fn as_ref(&self) -> MemberExprRef<'_> {
MemberExprRef {
path: self.path.as_str(),
segments: SegmentsRef::from(&self.segments),
@ -381,7 +381,7 @@ impl MemberTable {
}
/// Returns an iterator over all members in the table.
pub(crate) fn iter(&self) -> std::slice::Iter<Member> {
pub(crate) fn iter(&self) -> std::slice::Iter<'_, Member> {
self.members.iter()
}

View file

@ -162,12 +162,12 @@ impl PlaceTable {
}
/// Iterator over all symbols in this scope.
pub(crate) fn symbols(&self) -> std::slice::Iter<Symbol> {
pub(crate) fn symbols(&self) -> std::slice::Iter<'_, Symbol> {
self.symbols.iter()
}
/// Iterator over all members in this scope.
pub(crate) fn members(&self) -> std::slice::Iter<Member> {
pub(crate) fn members(&self) -> std::slice::Iter<'_, Member> {
self.members.iter()
}
@ -220,7 +220,7 @@ impl PlaceTable {
/// ## Panics
/// If the place ID is not found in the table.
#[track_caller]
pub(crate) fn place(&self, place_id: impl Into<ScopedPlaceId>) -> PlaceExprRef {
pub(crate) fn place(&self, place_id: impl Into<ScopedPlaceId>) -> PlaceExprRef<'_> {
match place_id.into() {
ScopedPlaceId::Symbol(symbol) => self.symbol(symbol).into(),
ScopedPlaceId::Member(member) => self.member(member).into(),
@ -275,7 +275,7 @@ impl PlaceTableBuilder {
}
#[track_caller]
pub(crate) fn place(&self, place_id: impl Into<ScopedPlaceId>) -> PlaceExprRef {
pub(crate) fn place(&self, place_id: impl Into<ScopedPlaceId>) -> PlaceExprRef<'_> {
match place_id.into() {
ScopedPlaceId::Symbol(id) => PlaceExprRef::Symbol(self.symbols.symbol(id)),
ScopedPlaceId::Member(id) => PlaceExprRef::Member(self.member.member(id)),
@ -289,7 +289,7 @@ impl PlaceTableBuilder {
}
}
pub(crate) fn iter(&self) -> impl Iterator<Item = PlaceExprRef> {
pub(crate) fn iter(&self) -> impl Iterator<Item = PlaceExprRef<'_>> {
self.symbols
.iter()
.map(Into::into)

View file

@ -153,7 +153,7 @@ impl SymbolTable {
}
/// Iterate over the symbols in this symbol table.
pub(crate) fn iter(&self) -> std::slice::Iter<Symbol> {
pub(crate) fn iter(&self) -> std::slice::Iter<'_, Symbol> {
self.symbols.iter()
}

View file

@ -36,7 +36,7 @@ impl<'db> SemanticModel<'db> {
line_index(self.db, self.file)
}
pub fn resolve_module(&self, module_name: &ModuleName) -> Option<Module> {
pub fn resolve_module(&self, module_name: &ModuleName) -> Option<Module<'_>> {
resolve_module(self.db, module_name)
}

View file

@ -402,7 +402,7 @@ impl Suppressions {
})
}
fn iter(&self) -> SuppressionsIter {
fn iter(&self) -> SuppressionsIter<'_> {
self.file.iter().chain(&self.line)
}
}

View file

@ -2507,7 +2507,7 @@ impl<'db> Type<'db> {
/// This function is roughly equivalent to `find_name_in_mro` as defined in the [descriptor guide] or
/// [`_PyType_Lookup`] in CPython's `Objects/typeobject.c`. It should typically be called through
/// [Type::class_member], unless it is known that `self` is a class-like type. This function returns
/// [`Type::class_member`], unless it is known that `self` is a class-like type. This function returns
/// `None` if called on an instance-like type.
///
/// [descriptor guide]: https://docs.python.org/3/howto/descriptor.html#invocation-from-an-instance
@ -5009,7 +5009,7 @@ impl<'db> Type<'db> {
}
}
/// Given a class literal or non-dynamic SubclassOf type, try calling it (creating an instance)
/// Given a class literal or non-dynamic `SubclassOf` type, try calling it (creating an instance)
/// and return the resulting instance type.
///
/// Models `type.__call__` behavior.
@ -6328,7 +6328,7 @@ impl<'db> KnownInstanceType<'db> {
/// For example, an alias created using the `type` statement is an instance of
/// `typing.TypeAliasType`, so `KnownInstanceType::TypeAliasType(_).instance_fallback(db)`
/// returns `Type::NominalInstance(NominalInstanceType { class: <typing.TypeAliasType> })`.
fn instance_fallback(self, db: &dyn Db) -> Type {
fn instance_fallback(self, db: &dyn Db) -> Type<'_> {
self.class().to_instance(db)
}
@ -7908,7 +7908,7 @@ impl Truthiness {
}
}
fn into_type(self, db: &dyn Db) -> Type {
fn into_type(self, db: &dyn Db) -> Type<'_> {
match self {
Self::AlwaysTrue => Type::BooleanLiteral(true),
Self::AlwaysFalse => Type::BooleanLiteral(false),
@ -8606,7 +8606,7 @@ impl<'db> UnionType<'db> {
Self::from_elements(db, self.elements(db).iter().filter(filter_fn))
}
pub fn iter(&self, db: &'db dyn Db) -> Iter<Type<'db>> {
pub fn iter(&self, db: &'db dyn Db) -> Iter<'_, Type<'db>> {
self.elements(db).iter()
}

View file

@ -97,7 +97,7 @@ impl<'a, 'db> CallArguments<'a, 'db> {
/// Prepend an optional extra synthetic argument (for a `self` or `cls` parameter) to the front
/// of this argument list. (If `bound_self` is none, we return the argument list
/// unmodified.)
pub(crate) fn with_self(&self, bound_self: Option<Type<'db>>) -> Cow<Self> {
pub(crate) fn with_self(&self, bound_self: Option<Type<'db>>) -> Cow<'_, Self> {
if bound_self.is_some() {
let arguments = std::iter::once(Argument::Synthetic)
.chain(self.arguments.iter().copied())

View file

@ -591,7 +591,7 @@ impl<'db> ClassType<'db> {
}
/// Returns the inferred type of the class member named `name`. Only bound members
/// or those marked as ClassVars are considered.
/// or those marked as `ClassVars` are considered.
///
/// You must provide the `inherited_generic_context` that we should use for the `__new__` or
/// `__init__` member. This is inherited from the containing class -­but importantly, from the
@ -1146,7 +1146,8 @@ pub struct ClassLiteral<'db> {
// The Salsa heap is tracked separately.
impl get_size2::GetSize for ClassLiteral<'_> {}
#[expect(clippy::trivially_copy_pass_by_ref, clippy::ref_option)]
#[expect(clippy::ref_option)]
#[allow(clippy::trivially_copy_pass_by_ref)]
fn pep695_generic_context_cycle_recover<'db>(
_db: &'db dyn Db,
_value: &Option<GenericContext<'db>>,
@ -1778,7 +1779,7 @@ impl<'db> ClassLiteral<'db> {
}
/// Returns the inferred type of the class member named `name`. Only bound members
/// or those marked as ClassVars are considered.
/// or those marked as `ClassVars` are considered.
///
/// Returns [`Place::Unbound`] if `name` cannot be found in this class's scope
/// directly. Use [`ClassLiteral::class_member`] if you require a method that will
@ -3614,7 +3615,7 @@ impl KnownClass {
/// representing all possible instances of the class.
///
/// If the class cannot be found in typeshed, a debug-level log message will be emitted stating this.
pub(crate) fn to_instance(self, db: &dyn Db) -> Type {
pub(crate) fn to_instance(self, db: &dyn Db) -> Type<'_> {
self.to_class_literal(db)
.to_class_type(db)
.map(|class| Type::instance(db, class))
@ -3676,7 +3677,7 @@ impl KnownClass {
fn try_to_class_literal_without_logging(
self,
db: &dyn Db,
) -> Result<ClassLiteral, KnownClassLookupError> {
) -> Result<ClassLiteral<'_>, KnownClassLookupError<'_>> {
let symbol = known_module_symbol(db, self.canonical_module(db), self.name(db)).place;
match symbol {
Place::Type(Type::ClassLiteral(class_literal), Boundness::Bound) => Ok(class_literal),
@ -3693,7 +3694,7 @@ impl KnownClass {
/// Lookup a [`KnownClass`] in typeshed and return a [`Type`] representing that class-literal.
///
/// If the class cannot be found in typeshed, a debug-level log message will be emitted stating this.
pub(crate) fn try_to_class_literal(self, db: &dyn Db) -> Option<ClassLiteral> {
pub(crate) fn try_to_class_literal(self, db: &dyn Db) -> Option<ClassLiteral<'_>> {
// a cache of the `KnownClass`es that we have already failed to lookup in typeshed
// (and therefore that we've already logged a warning for)
static MESSAGES: LazyLock<Mutex<FxHashSet<KnownClass>>> = LazyLock::new(Mutex::default);
@ -3728,7 +3729,7 @@ impl KnownClass {
/// Lookup a [`KnownClass`] in typeshed and return a [`Type`] representing that class-literal.
///
/// If the class cannot be found in typeshed, a debug-level log message will be emitted stating this.
pub(crate) fn to_class_literal(self, db: &dyn Db) -> Type {
pub(crate) fn to_class_literal(self, db: &dyn Db) -> Type<'_> {
self.try_to_class_literal(db)
.map(Type::ClassLiteral)
.unwrap_or_else(Type::unknown)
@ -3738,7 +3739,7 @@ impl KnownClass {
/// representing that class and all possible subclasses of the class.
///
/// If the class cannot be found in typeshed, a debug-level log message will be emitted stating this.
pub(crate) fn to_subclass_of(self, db: &dyn Db) -> Type {
pub(crate) fn to_subclass_of(self, db: &dyn Db) -> Type<'_> {
self.to_class_literal(db)
.to_class_type(db)
.map(|class| SubclassOfType::from(db, class))

View file

@ -678,7 +678,7 @@ declare_lint! {
/// Checks for exception handlers that catch non-exception classes.
///
/// ## Why is this bad?
/// Catching classes that do not inherit from `BaseException` will raise a TypeError at runtime.
/// Catching classes that do not inherit from `BaseException` will raise a `TypeError` at runtime.
///
/// ## Example
/// ```python

View file

@ -20,7 +20,7 @@ use crate::types::{
use crate::{Db, FxOrderSet};
impl<'db> Type<'db> {
pub fn display(&self, db: &'db dyn Db) -> DisplayType {
pub fn display(&self, db: &'db dyn Db) -> DisplayType<'_> {
DisplayType { ty: self, db }
}
fn representation(self, db: &'db dyn Db) -> DisplayRepresentation<'db> {
@ -980,23 +980,23 @@ impl Display for DisplayMaybeParenthesizedType<'_> {
}
pub(crate) trait TypeArrayDisplay<'db> {
fn display(&self, db: &'db dyn Db) -> DisplayTypeArray;
fn display(&self, db: &'db dyn Db) -> DisplayTypeArray<'_, 'db>;
}
impl<'db> TypeArrayDisplay<'db> for Box<[Type<'db>]> {
fn display(&self, db: &'db dyn Db) -> DisplayTypeArray {
fn display(&self, db: &'db dyn Db) -> DisplayTypeArray<'_, 'db> {
DisplayTypeArray { types: self, db }
}
}
impl<'db> TypeArrayDisplay<'db> for Vec<Type<'db>> {
fn display(&self, db: &'db dyn Db) -> DisplayTypeArray {
fn display(&self, db: &'db dyn Db) -> DisplayTypeArray<'_, 'db> {
DisplayTypeArray { types: self, db }
}
}
impl<'db> TypeArrayDisplay<'db> for [Type<'db>] {
fn display(&self, db: &'db dyn Db) -> DisplayTypeArray {
fn display(&self, db: &'db dyn Db) -> DisplayTypeArray<'_, 'db> {
DisplayTypeArray { types: self, db }
}
}

View file

@ -9631,7 +9631,7 @@ impl<'db> TypeInferenceBuilder<'db, '_> {
&self,
expression: &ast::Expr,
message: std::fmt::Arguments,
) -> Option<LintDiagnosticGuard> {
) -> Option<LintDiagnosticGuard<'_, '_>> {
self.context
.report_lint(&INVALID_TYPE_FORM, expression)
.map(|builder| {
@ -11231,7 +11231,7 @@ impl StringPartsCollector {
self.expression = true;
}
fn string_type(self, db: &dyn Db) -> Type {
fn string_type(self, db: &dyn Db) -> Type<'_> {
if self.expression {
KnownClass::Str.to_instance(db)
} else if let Some(concatenated) = self.concatenated {

View file

@ -1183,7 +1183,7 @@ impl<'db> Parameters<'db> {
self.value.len()
}
pub(crate) fn iter(&self) -> std::slice::Iter<Parameter<'db>> {
pub(crate) fn iter(&self) -> std::slice::Iter<'_, Parameter<'db>> {
self.value.iter()
}

View file

@ -171,7 +171,7 @@ impl SpecialFormType {
/// For example, the symbol `typing.Literal` is an instance of `typing._SpecialForm`,
/// so `SpecialFormType::Literal.instance_fallback(db)`
/// returns `Type::NominalInstance(NominalInstanceType { class: <typing._SpecialForm> })`.
pub(super) fn instance_fallback(self, db: &dyn Db) -> Type {
pub(super) fn instance_fallback(self, db: &dyn Db) -> Type<'_> {
self.class().to_instance(db)
}
@ -244,7 +244,7 @@ impl SpecialFormType {
}
}
pub(super) fn to_meta_type(self, db: &dyn Db) -> Type {
pub(super) fn to_meta_type(self, db: &dyn Db) -> Type<'_> {
self.class().to_class_literal(db)
}