Skip to content

Commit

Permalink
Upgrade Rust toolchain to 1.83 (#14677)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser authored Nov 29, 2024
1 parent a6402fb commit b63c2e1
Show file tree
Hide file tree
Showing 63 changed files with 127 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ impl<'db> Iterator for SearchPathIterator<'db> {
}
}

impl<'db> FusedIterator for SearchPathIterator<'db> {}
impl FusedIterator for SearchPathIterator<'_> {}

/// Represents a single `.pth` file in a `site-packages` directory.
/// One or more lines in a `.pth` file may be a (relative or absolute)
Expand Down
4 changes: 2 additions & 2 deletions crates/red_knot_python_semantic/src/semantic_index/use_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ pub(crate) struct ConstraintsIterator<'map, 'db> {
constraint_ids: ConstraintIdIterator<'map>,
}

impl<'map, 'db> Iterator for ConstraintsIterator<'map, 'db> {
impl<'db> Iterator for ConstraintsIterator<'_, 'db> {
type Item = Constraint<'db>;

fn next(&mut self) -> Option<Self::Item> {
Expand All @@ -424,7 +424,7 @@ impl DeclarationsIterator<'_, '_> {
}
}

impl<'map, 'db> Iterator for DeclarationsIterator<'map, 'db> {
impl<'db> Iterator for DeclarationsIterator<'_, 'db> {
type Item = Definition<'db>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ pub(super) struct DeclarationIdIterator<'a> {
inner: DeclarationsIterator<'a>,
}

impl<'a> Iterator for DeclarationIdIterator<'a> {
impl Iterator for DeclarationIdIterator<'_> {
type Item = ScopedDefinitionId;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
6 changes: 3 additions & 3 deletions crates/red_knot_python_semantic/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2023,7 +2023,7 @@ impl<'db> TypeVarInstance<'db> {
}

#[allow(unused)]
pub(crate) fn constraints(self, db: &'db dyn Db) -> Option<&[Type<'db>]> {
pub(crate) fn constraints(self, db: &'db dyn Db) -> Option<&'db [Type<'db>]> {
if let Some(TypeVarBoundOrConstraints::Constraints(tuple)) = self.bound_or_constraints(db) {
Some(tuple.elements(db))
} else {
Expand Down Expand Up @@ -2567,7 +2567,7 @@ impl<'db> Class<'db> {
///
/// Were this not a salsa query, then the calling query
/// would depend on the class's AST and rerun for every change in that file.
fn explicit_bases(self, db: &'db dyn Db) -> &[Type<'db>] {
fn explicit_bases(self, db: &'db dyn Db) -> &'db [Type<'db>] {
self.explicit_bases_query(db)
}

Expand Down Expand Up @@ -2995,7 +2995,7 @@ pub struct SliceLiteralType<'db> {
step: Option<i32>,
}

impl<'db> SliceLiteralType<'db> {
impl SliceLiteralType<'_> {
fn as_tuple(self, db: &dyn Db) -> (Option<i32>, Option<i32>, Option<i32>) {
(self.start(db), self.stop(db), self.step(db))
}
Expand Down
4 changes: 2 additions & 2 deletions crates/red_knot_python_semantic/src/types/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ struct DisplayMaybeNegatedType<'db> {
negated: bool,
}

impl<'db> Display for DisplayMaybeNegatedType<'db> {
impl Display for DisplayMaybeNegatedType<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
if self.negated {
f.write_str("~")?;
Expand Down Expand Up @@ -319,7 +319,7 @@ pub(crate) struct DisplayTypeArray<'b, 'db> {
db: &'db dyn Db,
}

impl<'db> Display for DisplayTypeArray<'_, 'db> {
impl Display for DisplayTypeArray<'_, '_> {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.join(", ")
.entries(self.types.iter().map(|ty| ty.display(self.db)))
Expand Down
3 changes: 3 additions & 0 deletions crates/red_knot_python_semantic/src/types/narrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub(crate) fn narrowing_constraint<'db>(
}
}

#[allow(clippy::ref_option)]
#[salsa::tracked(return_ref)]
fn all_narrowing_constraints_for_pattern<'db>(
db: &'db dyn Db,
Expand All @@ -62,6 +63,7 @@ fn all_narrowing_constraints_for_pattern<'db>(
NarrowingConstraintsBuilder::new(db, ConstraintNode::Pattern(pattern), true).finish()
}

#[allow(clippy::ref_option)]
#[salsa::tracked(return_ref)]
fn all_narrowing_constraints_for_expression<'db>(
db: &'db dyn Db,
Expand All @@ -70,6 +72,7 @@ fn all_narrowing_constraints_for_expression<'db>(
NarrowingConstraintsBuilder::new(db, ConstraintNode::Expression(expression), true).finish()
}

#[allow(clippy::ref_option)]
#[salsa::tracked(return_ref)]
fn all_negative_narrowing_constraints_for_expression<'db>(
db: &'db dyn Db,
Expand Down
2 changes: 1 addition & 1 deletion crates/red_knot_server/src/server/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub(crate) struct Requester<'s> {
response_handlers: FxHashMap<lsp_server::RequestId, ResponseBuilder<'s>>,
}

impl<'s> Client<'s> {
impl Client<'_> {
pub(super) fn new(sender: ClientSender) -> Self {
Self {
notifier: Notifier(sender.clone()),
Expand Down
2 changes: 2 additions & 0 deletions crates/red_knot_workspace/src/workspace.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::ref_option)]

use crate::db::Db;
use crate::db::RootDatabase;
use crate::workspace::files::{Index, Indexed, IndexedIter, PackageFiles};
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_db/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub struct Join<'a, 'b> {
seen_first: bool,
}

impl<'a, 'b> Join<'a, 'b> {
impl Join<'_, '_> {
pub fn entry(&mut self, item: &dyn Display) -> &mut Self {
if self.seen_first {
self.result = self
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_db/src/vendored.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl VendoredZipArchive {
#[derive(Debug, Clone, PartialEq, Eq)]
struct NormalizedVendoredPath<'a>(Cow<'a, str>);

impl<'a> NormalizedVendoredPath<'a> {
impl NormalizedVendoredPath<'_> {
fn with_trailing_slash(self) -> Self {
debug_assert!(!self.0.ends_with('/'));
let mut data = self.0.into_owned();
Expand Down
4 changes: 4 additions & 0 deletions crates/ruff_diagnostics/src/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ impl Edit {
self.content.as_deref()
}

pub fn into_content(self) -> Option<Box<str>> {
self.content
}

fn kind(&self) -> EditOperationKind {
if self.content.is_none() {
EditOperationKind::Deletion
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_formatter/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl<'inner, Context, Inspector> Inspect<'inner, Context, Inspector> {
}
}

impl<'inner, Context, Inspector> Buffer for Inspect<'inner, Context, Inspector>
impl<Context, Inspector> Buffer for Inspect<'_, Context, Inspector>
where
Inspector: FnMut(&FormatElement),
{
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_formatter/src/format_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ impl<'a> Iterator for BestFittingVariantsIter<'a> {
}
}

impl<'a> DoubleEndedIterator for BestFittingVariantsIter<'a> {
impl DoubleEndedIterator for BestFittingVariantsIter<'_> {
fn next_back(&mut self) -> Option<Self::Item> {
let start_position = self.elements.iter().rposition(|element| {
matches!(element, FormatElement::Tag(Tag::StartBestFittingEntry))
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_formatter/src/format_element/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl Document {
propagate_expands(self, &mut enclosing, &mut interned);
}

pub fn display<'a>(&'a self, source_code: SourceCode<'a>) -> DisplayDocument {
pub fn display<'a>(&'a self, source_code: SourceCode<'a>) -> DisplayDocument<'a> {
DisplayDocument {
elements: self.elements.as_slice(),
source_code,
Expand Down
4 changes: 1 addition & 3 deletions crates/ruff_formatter/src/printer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ struct PrinterState<'a> {
fits_queue: Vec<std::slice::Iter<'a, FormatElement>>,
}

impl<'a> PrinterState<'a> {
impl PrinterState<'_> {
fn with_capacity(capacity: usize) -> Self {
Self {
buffer: String::with_capacity(capacity),
Expand Down Expand Up @@ -1049,8 +1049,6 @@ struct FitsMeasurer<'a, 'print> {
bomb: DebugDropBomb,
}

impl<'a, 'print> FitsMeasurer<'a, 'print> {}

impl<'a, 'print> FitsMeasurer<'a, 'print> {
fn new_flat(
print_queue: &'print PrintQueue<'a>,
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_formatter/src/printer/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl<'a, 'print> FitsQueue<'a, 'print> {
}
}

impl<'a, 'print> Queue<'a> for FitsQueue<'a, 'print> {
impl<'a> Queue<'a> for FitsQueue<'a, '_> {
fn pop(&mut self) -> Option<&'a FormatElement> {
self.queue.pop().or_else(
#[cold]
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_linter/src/docstrings/sections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ impl<'a> Iterator for SectionContextsIter<'a> {
}
}

impl<'a> DoubleEndedIterator for SectionContextsIter<'a> {
impl DoubleEndedIterator for SectionContextsIter<'_> {
fn next_back(&mut self) -> Option<Self::Item> {
let back = self.inner.next_back()?;
Some(SectionContext {
Expand Down
4 changes: 2 additions & 2 deletions crates/ruff_linter/src/fix/edits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ pub(crate) fn add_parameter(parameter: &str, parameters: &Parameters, source: &s
{
// Case 1: at least one regular parameter, so append after the last one.
Edit::insertion(format!(", {parameter}"), last.end())
} else if parameters.args.first().is_some() {
} else if !parameters.args.is_empty() {
// Case 2: no regular parameters, but at least one keyword parameter, so add before the
// first.
let pos = parameters.start();
Expand All @@ -316,7 +316,7 @@ pub(crate) fn add_parameter(parameter: &str, parameters: &Parameters, source: &s
} else {
Edit::insertion(format!(", {parameter}"), slash.start())
}
} else if parameters.kwonlyargs.first().is_some() {
} else if !parameters.kwonlyargs.is_empty() {
// Case 3: no regular parameter, but a keyword-only parameter exist, so add parameter before that.
// We need to backtrack to before the `*` separator.
// We know there is no non-keyword-only params, so we can safely assume that the `*` separator is the first
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_linter/src/message/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub(super) struct Diff<'a> {
}

impl<'a> Diff<'a> {
pub(crate) fn from_message(message: &'a Message) -> Option<Diff> {
pub(crate) fn from_message(message: &'a Message) -> Option<Diff<'a>> {
message.fix().map(|fix| Diff {
source_code: message.source_file(),
fix,
Expand Down
10 changes: 5 additions & 5 deletions crates/ruff_linter/src/noqa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ impl Display for Code<'_> {
}
}

impl<'a> Ranged for Code<'a> {
impl Ranged for Code<'_> {
/// The range of the rule code.
fn range(&self) -> TextRange {
self.range
Expand All @@ -240,7 +240,7 @@ pub(crate) struct Codes<'a> {
codes: Vec<Code<'a>>,
}

impl<'a> Codes<'a> {
impl Codes<'_> {
/// Returns an iterator over the [`Code`]s in the `noqa` directive.
pub(crate) fn iter(&self) -> std::slice::Iter<Code> {
self.codes.iter()
Expand Down Expand Up @@ -287,7 +287,7 @@ pub(crate) enum FileExemption<'a> {
Codes(Vec<&'a NoqaCode>),
}

impl<'a> FileExemption<'a> {
impl FileExemption<'_> {
/// Returns `true` if the file is exempt from the given rule.
pub(crate) fn includes(&self, needle: Rule) -> bool {
let needle = needle.noqa_code();
Expand Down Expand Up @@ -817,7 +817,7 @@ struct NoqaEdit<'a> {
line_ending: LineEnding,
}

impl<'a> NoqaEdit<'a> {
impl NoqaEdit<'_> {
fn into_edit(self) -> Edit {
let mut edit_content = String::new();
self.write(&mut edit_content);
Expand Down Expand Up @@ -849,7 +849,7 @@ impl<'a> NoqaEdit<'a> {
}
}

impl<'a> Ranged for NoqaEdit<'a> {
impl Ranged for NoqaEdit<'_> {
fn range(&self) -> TextRange {
self.edit_range
}
Expand Down
4 changes: 2 additions & 2 deletions crates/ruff_linter/src/rules/fastapi/rules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ pub(crate) fn is_fastapi_route(
function_def: &ast::StmtFunctionDef,
semantic: &SemanticModel,
) -> bool {
return function_def
function_def
.decorator_list
.iter()
.any(|decorator| is_fastapi_route_decorator(decorator, semantic).is_some());
.any(|decorator| is_fastapi_route_decorator(decorator, semantic).is_some())
}

/// Returns `true` if the decorator is indicative of a FastAPI route.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ enum Method<'a> {
Instance(InstanceMethod<'a>),
}

impl<'a> Method<'a> {
impl Method<'_> {
fn uses_custom_var(&self) -> bool {
match self {
Self::Class(class_method) => class_method.uses_custom_var(),
Expand All @@ -162,7 +162,7 @@ struct ClassMethod<'a> {
type_params: Option<&'a TypeParams>,
}

impl<'a> ClassMethod<'a> {
impl ClassMethod<'_> {
/// Returns `true` if the class method is annotated with
/// a custom `TypeVar` that is likely private.
fn uses_custom_var(&self) -> bool {
Expand Down Expand Up @@ -203,7 +203,7 @@ struct InstanceMethod<'a> {
type_params: Option<&'a TypeParams>,
}

impl<'a> InstanceMethod<'a> {
impl InstanceMethod<'_> {
/// Returns `true` if the instance method is annotated with
/// a custom `TypeVar` that is likely private.
fn uses_custom_var(&self) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_linter/src/rules/flake8_return/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl<'semantic, 'data> ReturnVisitor<'semantic, 'data> {
}
}

impl<'semantic, 'a> Visitor<'a> for ReturnVisitor<'semantic, 'a> {
impl<'a> Visitor<'a> for ReturnVisitor<'_, 'a> {
fn visit_stmt(&mut self, stmt: &'a Stmt) {
match stmt {
Stmt::ClassDef(ast::StmtClassDef { decorator_list, .. }) => {
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_linter/src/rules/isort/sorting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl<'a> From<&'a str> for NatOrdStr<'a> {
}
}

impl<'a> From<String> for NatOrdStr<'a> {
impl From<String> for NatOrdStr<'_> {
fn from(s: String) -> Self {
NatOrdStr(Cow::Owned(s))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ impl<'a> LinePreprocessor<'a> {
}
}

impl<'a> Iterator for LinePreprocessor<'a> {
impl Iterator for LinePreprocessor<'_> {
type Item = LogicalLineInfo;

fn next(&mut self) -> Option<LogicalLineInfo> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ pub(crate) fn check_docstring(
{
let extra_property_decorators = checker.settings.pydocstyle.property_decorators();
if !definition.is_property(extra_property_decorators, semantic) {
if body_entries.returns.first().is_some() {
if !body_entries.returns.is_empty() {
match function_def.returns.as_deref() {
Some(returns) => {
// Ignore it if it's annotated as returning `None`
Expand Down Expand Up @@ -915,7 +915,7 @@ pub(crate) fn check_docstring(
// DOC402
if checker.enabled(Rule::DocstringMissingYields) {
if !yields_documented(docstring, &docstring_sections, convention) {
if body_entries.yields.first().is_some() {
if !body_entries.yields.is_empty() {
match function_def.returns.as_deref() {
Some(returns)
if !generator_annotation_arguments(returns, semantic).is_some_and(
Expand Down
6 changes: 2 additions & 4 deletions crates/ruff_linter/src/rules/pydocstyle/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,9 @@ pub(crate) fn get_section_contexts<'a>(
) -> SectionContexts<'a> {
match convention {
Some(Convention::Google) => {
return SectionContexts::from_docstring(docstring, SectionStyle::Google);
}
Some(Convention::Numpy) => {
return SectionContexts::from_docstring(docstring, SectionStyle::Numpy);
SectionContexts::from_docstring(docstring, SectionStyle::Google)
}
Some(Convention::Numpy) => SectionContexts::from_docstring(docstring, SectionStyle::Numpy),
Some(Convention::Pep257) | None => {
// There are some overlapping section names, between the Google and NumPy conventions
// (e.g., "Returns", "Raises"). Break ties by checking for the presence of some of the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ struct ImportBinding<'a> {
parent_range: Option<TextRange>,
}

impl<'a> ImportBinding<'a> {
impl ImportBinding<'_> {
/// The symbol that is stored in the outer scope as a result of this import.
///
/// For example:
Expand Down
Loading

0 comments on commit b63c2e1

Please sign in to comment.