Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171)

<!--
Thank you for contributing to Ruff! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

I decided to disable the new
[`needless_continue`](https://rust-lang.github.io/rust-clippy/master/index.html#needless_continue)
rule because I often found the explicit `continue` more readable over an
empty block or having to invert the condition of an other branch.


## Test Plan

`cargo test`

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Micha Reiser
2025-04-03 17:59:44 +02:00
committed by GitHub
parent fedd982fd5
commit 8a4158c5f8
135 changed files with 285 additions and 255 deletions

View File

@@ -322,6 +322,7 @@ fn python_version_from_versions_file_string(
#[cfg(test)]
mod tests {
use std::fmt::Write as _;
use std::num::{IntErrorKind, NonZeroU16};
use std::path::Path;
@@ -333,8 +334,7 @@ mod tests {
const TYPESHED_STDLIB_DIR: &str = "stdlib";
#[allow(unsafe_code)]
const ONE: Option<NonZeroU16> = Some(unsafe { NonZeroU16::new_unchecked(1) });
const ONE: Option<NonZeroU16> = Some(NonZeroU16::new(1).unwrap());
impl TypeshedVersions {
#[must_use]
@@ -571,7 +571,7 @@ foo: 3.8- # trailing comment
let mut massive_versions_file = String::new();
for i in 0..too_many {
massive_versions_file.push_str(&format!("x{i}: 3.8-\n"));
let _ = writeln!(&mut massive_versions_file, "x{i}: 3.8-");
}
assert_eq!(

View File

@@ -1448,7 +1448,7 @@ where
self.visit_expr(subject);
if cases.is_empty() {
return;
};
}
let after_subject = self.flow_snapshot();
let mut vis_constraints = vec![];

View File

@@ -145,7 +145,7 @@ pub(crate) fn check_suppressions(db: &dyn Db, file: File, diagnostics: &mut Type
fn check_unknown_rule(context: &mut CheckSuppressionsContext) {
if context.is_lint_disabled(&UNKNOWN_RULE) {
return;
};
}
for unknown in &context.suppressions.unknown {
match &unknown.reason {
@@ -174,7 +174,7 @@ fn check_unknown_rule(context: &mut CheckSuppressionsContext) {
format_args!("Unknown rule `{prefixed}`. Did you mean `{suggestion}`?"),
);
}
};
}
}
}
@@ -267,7 +267,7 @@ fn check_unused_suppressions(context: &mut CheckSuppressionsContext) {
suppression.range,
format_args!("Unused `{kind}` without a code", kind = suppression.kind),
),
};
}
}
}

View File

@@ -657,7 +657,7 @@ fn symbol_from_bindings_impl<'db>(
binding,
visibility_constraint,
narrowing_constraint: _,
}) if binding.map_or(true, is_non_exported) => {
}) if binding.is_none_or(is_non_exported) => {
visibility_constraints.evaluate(db, predicates, *visibility_constraint)
}
_ => Truthiness::AlwaysFalse,
@@ -794,7 +794,7 @@ fn symbol_from_declarations_impl<'db>(
Some(DeclarationWithConstraint {
declaration,
visibility_constraint,
}) if declaration.map_or(true, is_non_exported) => {
}) if declaration.is_none_or(is_non_exported) => {
visibility_constraints.evaluate(db, predicates, *visibility_constraint)
}
_ => Truthiness::AlwaysFalse,

View File

@@ -502,13 +502,13 @@ impl<'db> Bindings<'db> {
if let Some(len_ty) = first_arg.len(db) {
overload.set_return_type(len_ty);
}
};
}
}
Some(KnownFunction::Repr) => {
if let [Some(first_arg)] = overload.parameter_types() {
overload.set_return_type(first_arg.repr(db));
};
}
}
Some(KnownFunction::Cast) => {

View File

@@ -985,7 +985,7 @@ impl<'db> TypeInferenceBuilder<'db> {
Some(KnownClass::Float | KnownClass::Int | KnownClass::Bool)
) => {}
_ => return false,
};
}
let (op, by_zero) = match op {
ast::Operator::Div => ("divide", "by zero"),
@@ -1036,7 +1036,7 @@ impl<'db> TypeInferenceBuilder<'db> {
report_invalid_assignment(&self.context, node, declared_ty, bound_ty);
// allow declarations to override inference in case of invalid assignment
bound_ty = declared_ty;
};
}
self.types.bindings.insert(binding, bound_ty);
}
@@ -2216,7 +2216,7 @@ impl<'db> TypeInferenceBuilder<'db> {
}
}
ast::Pattern::MatchStar(_) | ast::Pattern::MatchSingleton(_) => {}
};
}
}
fn infer_assignment_statement(&mut self, assignment: &ast::StmtAssign) {
@@ -3242,7 +3242,7 @@ impl<'db> TypeInferenceBuilder<'db> {
&DeclaredAndInferredType::AreTheSame(ty),
);
return;
};
}
// If the module doesn't bind the symbol, check if it's a submodule. This won't get
// handled by the `Type::member` call because it relies on the semantic index's
@@ -4044,7 +4044,7 @@ impl<'db> TypeInferenceBuilder<'db> {
parameter_ty=parameter_ty.display(self.db())
),
);
};
}
}
}
}
@@ -4895,7 +4895,7 @@ impl<'db> TypeInferenceBuilder<'db> {
if done {
return Type::Never;
};
}
match (truthiness, op) {
(Truthiness::AlwaysTrue, ast::BoolOp::And) => Type::Never,
@@ -5815,7 +5815,7 @@ impl<'db> TypeInferenceBuilder<'db> {
Err(CallDunderError::MethodNotAvailable) => {
// try `__class_getitem__`
}
};
}
// Otherwise, if the value is itself a class and defines `__class_getitem__`,
// return its return type.

View File

@@ -30,7 +30,7 @@ impl SlotsKind {
if matches!(bound, Boundness::PossiblyUnbound) {
return Self::Dynamic;
};
}
match slots_ty {
// __slots__ = ("a", "b")
@@ -98,6 +98,6 @@ pub(super) fn check_class_slots(context: &InferContext, class: Class, node: &ast
if let Some(index) = first_with_solid_base {
let base_node = &node.bases()[index];
report_base_with_incompatible_slots(context, base_node);
};
}
}
}

View File

@@ -116,8 +116,10 @@ impl<'db> Unpacker<'db> {
// it's worth it.
TupleType::from_elements(
self.db(),
std::iter::repeat(Type::LiteralString)
.take(string_literal_ty.python_len(self.db())),
std::iter::repeat_n(
Type::LiteralString,
string_literal_ty.python_len(self.db()),
),
)
}
_ => ty,