diff --git a/crates/red_knot_python_semantic/src/module_resolver/resolver.rs b/crates/red_knot_python_semantic/src/module_resolver/resolver.rs index 808dbab0fafdd7..ab727bbcc771c4 100644 --- a/crates/red_knot_python_semantic/src/module_resolver/resolver.rs +++ b/crates/red_knot_python_semantic/src/module_resolver/resolver.rs @@ -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) diff --git a/crates/red_knot_python_semantic/src/semantic_index/use_def.rs b/crates/red_knot_python_semantic/src/semantic_index/use_def.rs index 2fe2b471833376..cfb8318b592220 100644 --- a/crates/red_knot_python_semantic/src/semantic_index/use_def.rs +++ b/crates/red_knot_python_semantic/src/semantic_index/use_def.rs @@ -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 { @@ -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 { diff --git a/crates/red_knot_python_semantic/src/semantic_index/use_def/symbol_state.rs b/crates/red_knot_python_semantic/src/semantic_index/use_def/symbol_state.rs index 09210bfab05d6c..506300067c9520 100644 --- a/crates/red_knot_python_semantic/src/semantic_index/use_def/symbol_state.rs +++ b/crates/red_knot_python_semantic/src/semantic_index/use_def/symbol_state.rs @@ -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 { diff --git a/crates/red_knot_python_semantic/src/types.rs b/crates/red_knot_python_semantic/src/types.rs index 64bfd3ec796605..695a779a849de9 100644 --- a/crates/red_knot_python_semantic/src/types.rs +++ b/crates/red_knot_python_semantic/src/types.rs @@ -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 { @@ -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) } @@ -2995,7 +2995,7 @@ pub struct SliceLiteralType<'db> { step: Option, } -impl<'db> SliceLiteralType<'db> { +impl SliceLiteralType<'_> { fn as_tuple(self, db: &dyn Db) -> (Option, Option, Option) { (self.start(db), self.stop(db), self.step(db)) } diff --git a/crates/red_knot_python_semantic/src/types/display.rs b/crates/red_knot_python_semantic/src/types/display.rs index cf86187dbbbb67..3240247926e9fb 100644 --- a/crates/red_knot_python_semantic/src/types/display.rs +++ b/crates/red_knot_python_semantic/src/types/display.rs @@ -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("~")?; @@ -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))) diff --git a/crates/red_knot_python_semantic/src/types/narrow.rs b/crates/red_knot_python_semantic/src/types/narrow.rs index 7ce84cb7fb553b..93e2f5afa357ba 100644 --- a/crates/red_knot_python_semantic/src/types/narrow.rs +++ b/crates/red_knot_python_semantic/src/types/narrow.rs @@ -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, @@ -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, @@ -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, diff --git a/crates/red_knot_server/src/server/client.rs b/crates/red_knot_server/src/server/client.rs index bd12f86d78e5c9..c5a502e213c5e6 100644 --- a/crates/red_knot_server/src/server/client.rs +++ b/crates/red_knot_server/src/server/client.rs @@ -26,7 +26,7 @@ pub(crate) struct Requester<'s> { response_handlers: FxHashMap>, } -impl<'s> Client<'s> { +impl Client<'_> { pub(super) fn new(sender: ClientSender) -> Self { Self { notifier: Notifier(sender.clone()), diff --git a/crates/red_knot_workspace/src/workspace.rs b/crates/red_knot_workspace/src/workspace.rs index 98ba10fe6a90f1..780f552f7158b6 100644 --- a/crates/red_knot_workspace/src/workspace.rs +++ b/crates/red_knot_workspace/src/workspace.rs @@ -1,3 +1,5 @@ +#![allow(clippy::ref_option)] + use crate::db::Db; use crate::db::RootDatabase; use crate::workspace::files::{Index, Indexed, IndexedIter, PackageFiles}; diff --git a/crates/ruff_db/src/display.rs b/crates/ruff_db/src/display.rs index 439cd4b1becd35..27f93846e8216b 100644 --- a/crates/ruff_db/src/display.rs +++ b/crates/ruff_db/src/display.rs @@ -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 diff --git a/crates/ruff_db/src/vendored.rs b/crates/ruff_db/src/vendored.rs index 4cdbfe8a512d8f..923824d1e95a37 100644 --- a/crates/ruff_db/src/vendored.rs +++ b/crates/ruff_db/src/vendored.rs @@ -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(); diff --git a/crates/ruff_diagnostics/src/edit.rs b/crates/ruff_diagnostics/src/edit.rs index 5bd4e629b4c956..1195fdc540ed97 100644 --- a/crates/ruff_diagnostics/src/edit.rs +++ b/crates/ruff_diagnostics/src/edit.rs @@ -62,6 +62,10 @@ impl Edit { self.content.as_deref() } + pub fn into_content(self) -> Option> { + self.content + } + fn kind(&self) -> EditOperationKind { if self.content.is_none() { EditOperationKind::Deletion diff --git a/crates/ruff_formatter/src/buffer.rs b/crates/ruff_formatter/src/buffer.rs index 4137fbe58e3547..b96dc7bb08da02 100644 --- a/crates/ruff_formatter/src/buffer.rs +++ b/crates/ruff_formatter/src/buffer.rs @@ -263,7 +263,7 @@ impl<'inner, Context, Inspector> Inspect<'inner, Context, Inspector> { } } -impl<'inner, Context, Inspector> Buffer for Inspect<'inner, Context, Inspector> +impl Buffer for Inspect<'_, Context, Inspector> where Inspector: FnMut(&FormatElement), { diff --git a/crates/ruff_formatter/src/format_element.rs b/crates/ruff_formatter/src/format_element.rs index eb42a44bc07655..8623f9850f4877 100644 --- a/crates/ruff_formatter/src/format_element.rs +++ b/crates/ruff_formatter/src/format_element.rs @@ -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 { let start_position = self.elements.iter().rposition(|element| { matches!(element, FormatElement::Tag(Tag::StartBestFittingEntry)) diff --git a/crates/ruff_formatter/src/format_element/document.rs b/crates/ruff_formatter/src/format_element/document.rs index 68d8ee906ba1e1..cbdea125fdfc61 100644 --- a/crates/ruff_formatter/src/format_element/document.rs +++ b/crates/ruff_formatter/src/format_element/document.rs @@ -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, diff --git a/crates/ruff_formatter/src/printer/mod.rs b/crates/ruff_formatter/src/printer/mod.rs index 0a7bd8fedf7d73..4fcd71132205ac 100644 --- a/crates/ruff_formatter/src/printer/mod.rs +++ b/crates/ruff_formatter/src/printer/mod.rs @@ -905,7 +905,7 @@ struct PrinterState<'a> { fits_queue: Vec>, } -impl<'a> PrinterState<'a> { +impl PrinterState<'_> { fn with_capacity(capacity: usize) -> Self { Self { buffer: String::with_capacity(capacity), @@ -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>, diff --git a/crates/ruff_formatter/src/printer/queue.rs b/crates/ruff_formatter/src/printer/queue.rs index b1f6500c9b6eef..e7ae215409212f 100644 --- a/crates/ruff_formatter/src/printer/queue.rs +++ b/crates/ruff_formatter/src/printer/queue.rs @@ -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] diff --git a/crates/ruff_linter/src/docstrings/sections.rs b/crates/ruff_linter/src/docstrings/sections.rs index 1068a0db07535d..41a51801e72cac 100644 --- a/crates/ruff_linter/src/docstrings/sections.rs +++ b/crates/ruff_linter/src/docstrings/sections.rs @@ -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 { let back = self.inner.next_back()?; Some(SectionContext { diff --git a/crates/ruff_linter/src/fix/edits.rs b/crates/ruff_linter/src/fix/edits.rs index 407ffb0492d883..e7de716f9fa498 100644 --- a/crates/ruff_linter/src/fix/edits.rs +++ b/crates/ruff_linter/src/fix/edits.rs @@ -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(); @@ -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 diff --git a/crates/ruff_linter/src/message/diff.rs b/crates/ruff_linter/src/message/diff.rs index e3b3d99290c825..0e56578e177f93 100644 --- a/crates/ruff_linter/src/message/diff.rs +++ b/crates/ruff_linter/src/message/diff.rs @@ -26,7 +26,7 @@ pub(super) struct Diff<'a> { } impl<'a> Diff<'a> { - pub(crate) fn from_message(message: &'a Message) -> Option { + pub(crate) fn from_message(message: &'a Message) -> Option> { message.fix().map(|fix| Diff { source_code: message.source_file(), fix, diff --git a/crates/ruff_linter/src/noqa.rs b/crates/ruff_linter/src/noqa.rs index ce670225b89c90..258b4931ca61f0 100644 --- a/crates/ruff_linter/src/noqa.rs +++ b/crates/ruff_linter/src/noqa.rs @@ -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 @@ -240,7 +240,7 @@ pub(crate) struct Codes<'a> { codes: Vec>, } -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 { self.codes.iter() @@ -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(); @@ -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); @@ -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 } diff --git a/crates/ruff_linter/src/rules/fastapi/rules/mod.rs b/crates/ruff_linter/src/rules/fastapi/rules/mod.rs index 9cf10734e466cb..43dd60cecc1659 100644 --- a/crates/ruff_linter/src/rules/fastapi/rules/mod.rs +++ b/crates/ruff_linter/src/rules/fastapi/rules/mod.rs @@ -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. diff --git a/crates/ruff_linter/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs b/crates/ruff_linter/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs index 3bf5bc76ab3008..46e9cbbf28a4c2 100644 --- a/crates/ruff_linter/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs +++ b/crates/ruff_linter/src/rules/flake8_pyi/rules/custom_type_var_return_type.rs @@ -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(), @@ -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 { @@ -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 { diff --git a/crates/ruff_linter/src/rules/flake8_return/visitor.rs b/crates/ruff_linter/src/rules/flake8_return/visitor.rs index c88abc6676bd53..38ddae2af4edee 100644 --- a/crates/ruff_linter/src/rules/flake8_return/visitor.rs +++ b/crates/ruff_linter/src/rules/flake8_return/visitor.rs @@ -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, .. }) => { diff --git a/crates/ruff_linter/src/rules/isort/sorting.rs b/crates/ruff_linter/src/rules/isort/sorting.rs index 829d743e4d01d3..0db5d804236687 100644 --- a/crates/ruff_linter/src/rules/isort/sorting.rs +++ b/crates/ruff_linter/src/rules/isort/sorting.rs @@ -59,7 +59,7 @@ impl<'a> From<&'a str> for NatOrdStr<'a> { } } -impl<'a> From for NatOrdStr<'a> { +impl From for NatOrdStr<'_> { fn from(s: String) -> Self { NatOrdStr(Cow::Owned(s)) } diff --git a/crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs b/crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs index bb99f68ce6aab5..c7e2765204284d 100644 --- a/crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs +++ b/crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs @@ -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 { diff --git a/crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs b/crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs index 3e1a25572d0bc3..b315d4cbc4183d 100644 --- a/crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs +++ b/crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs @@ -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` @@ -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( diff --git a/crates/ruff_linter/src/rules/pydocstyle/helpers.rs b/crates/ruff_linter/src/rules/pydocstyle/helpers.rs index d802afcc69d5c3..405be36dc5291c 100644 --- a/crates/ruff_linter/src/rules/pydocstyle/helpers.rs +++ b/crates/ruff_linter/src/rules/pydocstyle/helpers.rs @@ -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 diff --git a/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs b/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs index 09e4149b32c98b..04acc5a30eaabd 100644 --- a/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs +++ b/crates/ruff_linter/src/rules/pyflakes/rules/unused_import.rs @@ -462,7 +462,7 @@ struct ImportBinding<'a> { parent_range: Option, } -impl<'a> ImportBinding<'a> { +impl ImportBinding<'_> { /// The symbol that is stored in the outer scope as a result of this import. /// /// For example: diff --git a/crates/ruff_linter/src/rules/pylint/helpers.rs b/crates/ruff_linter/src/rules/pylint/helpers.rs index 7f6959341d27b6..75777a40fd651c 100644 --- a/crates/ruff_linter/src/rules/pylint/helpers.rs +++ b/crates/ruff_linter/src/rules/pylint/helpers.rs @@ -113,7 +113,7 @@ impl SequenceIndexVisitor<'_> { } } -impl<'a> Visitor<'_> for SequenceIndexVisitor<'a> { +impl Visitor<'_> for SequenceIndexVisitor<'_> { fn visit_stmt(&mut self, stmt: &Stmt) { if self.modified { return; diff --git a/crates/ruff_linter/src/rules/pylint/rules/len_test.rs b/crates/ruff_linter/src/rules/pylint/rules/len_test.rs index 44b56f64c1050c..5303483912f660 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/len_test.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/len_test.rs @@ -162,7 +162,7 @@ fn is_sequence(expr: &Expr, semantic: &SemanticModel) -> bool { }; // Match against specific built-in constructors that return sequences - return semantic.resolve_builtin_symbol(func).is_some_and(|func| { + semantic.resolve_builtin_symbol(func).is_some_and(|func| { matches!( func, "chr" @@ -187,5 +187,5 @@ fn is_sequence(expr: &Expr, semantic: &SemanticModel) -> bool { | "memoryview" | "oct" ) - }); + }) } diff --git a/crates/ruff_linter/src/rules/pylint/rules/redefined_loop_name.rs b/crates/ruff_linter/src/rules/pylint/rules/redefined_loop_name.rs index 3fb716d12f325c..145845c4980584 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/redefined_loop_name.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/redefined_loop_name.rs @@ -144,7 +144,7 @@ struct InnerForWithAssignTargetsVisitor<'a, 'b> { assignment_targets: Vec>, } -impl<'a, 'b> StatementVisitor<'b> for InnerForWithAssignTargetsVisitor<'a, 'b> { +impl<'b> StatementVisitor<'b> for InnerForWithAssignTargetsVisitor<'_, 'b> { fn visit_stmt(&mut self, stmt: &'b Stmt) { // Collect target expressions. match stmt { diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/yield_in_for_loop.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/yield_in_for_loop.rs index ab69c25e180c08..02c96754be908f 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/yield_in_for_loop.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/yield_in_for_loop.rs @@ -149,7 +149,7 @@ fn is_same_expr(left: &Expr, right: &Expr) -> bool { /// Collect all named variables in an expression consisting solely of tuples and /// names. -fn collect_names<'a>(expr: &'a Expr) -> Box + 'a> { +fn collect_names<'a>(expr: &'a Expr) -> Box + 'a> { Box::new( expr.as_name_expr().into_iter().chain( expr.as_tuple_expr() diff --git a/crates/ruff_linter/src/rules/refurb/helpers.rs b/crates/ruff_linter/src/rules/refurb/helpers.rs index ff07354ddebd67..57333af76803e0 100644 --- a/crates/ruff_linter/src/rules/refurb/helpers.rs +++ b/crates/ruff_linter/src/rules/refurb/helpers.rs @@ -106,7 +106,7 @@ pub(super) struct FileOpen<'a> { pub(super) reference: &'a ResolvedReference, } -impl<'a> FileOpen<'a> { +impl FileOpen<'_> { /// Determine whether an expression is a reference to the file handle, by comparing /// their ranges. If two expressions have the same range, they must be the same expression. pub(super) fn is_ref(&self, expr: &Expr) -> bool { diff --git a/crates/ruff_linter/src/rules/ruff/rules/invalid_formatter_suppression_comment.rs b/crates/ruff_linter/src/rules/ruff/rules/invalid_formatter_suppression_comment.rs index 6bd4d7c3ac3233..3fb3254041b594 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/invalid_formatter_suppression_comment.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/invalid_formatter_suppression_comment.rs @@ -203,7 +203,7 @@ impl<'src, 'loc> UselessSuppressionComments<'src, 'loc> { } } -impl<'src, 'loc> CaptureSuppressionComment<'src> for UselessSuppressionComments<'src, 'loc> { +impl<'src> CaptureSuppressionComment<'src> for UselessSuppressionComments<'src, '_> { fn capture(&mut self, comment: SuppressionCommentData<'src>) { match self.check_suppression_comment(&comment) { Ok(()) => {} diff --git a/crates/ruff_linter/src/rules/ruff/rules/sort_dunder_slots.rs b/crates/ruff_linter/src/rules/ruff/rules/sort_dunder_slots.rs index 29c48a4e9e8efb..fd588bf82f82cb 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/sort_dunder_slots.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/sort_dunder_slots.rs @@ -315,7 +315,7 @@ enum DisplayKind<'a> { Dict { items: &'a [ast::DictItem] }, } -impl<'a> DisplayKind<'a> { +impl DisplayKind<'_> { const fn is_set_literal(self) -> bool { matches!(self, Self::Sequence(SequenceKind::Set)) } diff --git a/crates/ruff_linter/src/rules/tryceratops/helpers.rs b/crates/ruff_linter/src/rules/tryceratops/helpers.rs index 7b07240c20a392..f38ca0b16c50ec 100644 --- a/crates/ruff_linter/src/rules/tryceratops/helpers.rs +++ b/crates/ruff_linter/src/rules/tryceratops/helpers.rs @@ -22,7 +22,7 @@ impl<'a, 'b> LoggerCandidateVisitor<'a, 'b> { } } -impl<'a, 'b> Visitor<'b> for LoggerCandidateVisitor<'a, 'b> { +impl<'b> Visitor<'b> for LoggerCandidateVisitor<'_, 'b> { fn visit_expr(&mut self, expr: &'b Expr) { if let Expr::Call(call) = expr { match call.func.as_ref() { diff --git a/crates/ruff_python_ast/src/expression.rs b/crates/ruff_python_ast/src/expression.rs index 469f12b003af45..6f9db5a2cdeef7 100644 --- a/crates/ruff_python_ast/src/expression.rs +++ b/crates/ruff_python_ast/src/expression.rs @@ -407,7 +407,7 @@ pub enum StringLike<'a> { FString(&'a ast::ExprFString), } -impl<'a> StringLike<'a> { +impl StringLike<'_> { pub const fn is_fstring(self) -> bool { matches!(self, Self::FString(_)) } diff --git a/crates/ruff_python_ast/src/name.rs b/crates/ruff_python_ast/src/name.rs index 58da7e14592f56..848e18cc0193e0 100644 --- a/crates/ruff_python_ast/src/name.rs +++ b/crates/ruff_python_ast/src/name.rs @@ -669,7 +669,7 @@ impl<'a> Deref for SegmentsVec<'a> { } } -impl<'a, 'b> PartialEq> for SegmentsVec<'a> { +impl<'b> PartialEq> for SegmentsVec<'_> { fn eq(&self, other: &SegmentsVec<'b>) -> bool { self.as_slice() == other.as_slice() } diff --git a/crates/ruff_python_ast/src/nodes.rs b/crates/ruff_python_ast/src/nodes.rs index f210c08b70dec8..17d7797193504e 100644 --- a/crates/ruff_python_ast/src/nodes.rs +++ b/crates/ruff_python_ast/src/nodes.rs @@ -919,14 +919,14 @@ impl<'a> Iterator for DictKeyIterator<'a> { } } -impl<'a> DoubleEndedIterator for DictKeyIterator<'a> { +impl DoubleEndedIterator for DictKeyIterator<'_> { fn next_back(&mut self) -> Option { self.items.next_back().map(DictItem::key) } } -impl<'a> FusedIterator for DictKeyIterator<'a> {} -impl<'a> ExactSizeIterator for DictKeyIterator<'a> {} +impl FusedIterator for DictKeyIterator<'_> {} +impl ExactSizeIterator for DictKeyIterator<'_> {} #[derive(Debug, Clone)] pub struct DictValueIterator<'a> { @@ -961,14 +961,14 @@ impl<'a> Iterator for DictValueIterator<'a> { } } -impl<'a> DoubleEndedIterator for DictValueIterator<'a> { +impl DoubleEndedIterator for DictValueIterator<'_> { fn next_back(&mut self) -> Option { self.items.next_back().map(DictItem::value) } } -impl<'a> FusedIterator for DictValueIterator<'a> {} -impl<'a> ExactSizeIterator for DictValueIterator<'a> {} +impl FusedIterator for DictValueIterator<'_> {} +impl ExactSizeIterator for DictValueIterator<'_> {} /// See also [Set](https://docs.python.org/3/library/ast.html#ast.Set) #[derive(Clone, Debug, PartialEq)] @@ -3666,7 +3666,7 @@ impl<'a> Iterator for ParametersIterator<'a> { } } -impl<'a> DoubleEndedIterator for ParametersIterator<'a> { +impl DoubleEndedIterator for ParametersIterator<'_> { fn next_back(&mut self) -> Option { let ParametersIterator { posonlyargs, @@ -3692,11 +3692,11 @@ impl<'a> DoubleEndedIterator for ParametersIterator<'a> { } } -impl<'a> FusedIterator for ParametersIterator<'a> {} +impl FusedIterator for ParametersIterator<'_> {} /// We rely on the same invariants outlined in the comment above `Parameters::len()` /// in order to implement `ExactSizeIterator` here -impl<'a> ExactSizeIterator for ParametersIterator<'a> {} +impl ExactSizeIterator for ParametersIterator<'_> {} impl<'a> IntoIterator for &'a Parameters { type IntoIter = ParametersIterator<'a>; diff --git a/crates/ruff_python_formatter/src/comments/map.rs b/crates/ruff_python_formatter/src/comments/map.rs index 9222d25549d2a2..4c3fa1b21873c5 100644 --- a/crates/ruff_python_formatter/src/comments/map.rs +++ b/crates/ruff_python_formatter/src/comments/map.rs @@ -340,7 +340,7 @@ impl<'a, T> IntoIterator for LeadingDanglingTrailing<'a, T> { } } -impl<'a, T> Debug for LeadingDanglingTrailing<'a, T> +impl Debug for LeadingDanglingTrailing<'_, T> where T: Debug, { diff --git a/crates/ruff_python_formatter/src/context.rs b/crates/ruff_python_formatter/src/context.rs index 10d41cb5de95a3..e6b7830cb712d5 100644 --- a/crates/ruff_python_formatter/src/context.rs +++ b/crates/ruff_python_formatter/src/context.rs @@ -221,7 +221,7 @@ where } } -impl<'ast, 'buf, B> Deref for WithNodeLevel<'ast, 'buf, B> +impl<'ast, B> Deref for WithNodeLevel<'ast, '_, B> where B: Buffer>, { @@ -232,7 +232,7 @@ where } } -impl<'ast, 'buf, B> DerefMut for WithNodeLevel<'ast, 'buf, B> +impl<'ast, B> DerefMut for WithNodeLevel<'ast, '_, B> where B: Buffer>, { diff --git a/crates/ruff_python_formatter/src/expression/binary_like.rs b/crates/ruff_python_formatter/src/expression/binary_like.rs index be6f3ec22d2125..429740c0b327a7 100644 --- a/crates/ruff_python_formatter/src/expression/binary_like.rs +++ b/crates/ruff_python_formatter/src/expression/binary_like.rs @@ -881,7 +881,7 @@ impl Format> for Operand<'_> { fn fmt(&self, f: &mut Formatter>) -> FormatResult<()> { let expression = self.expression(); - return if is_expression_parenthesized( + if is_expression_parenthesized( expression.into(), f.context().comments().ranges(), f.context().source(), @@ -1017,7 +1017,7 @@ impl Format> for Operand<'_> { Ok(()) } else { expression.format().with_options(Parentheses::Never).fmt(f) - }; + } } } diff --git a/crates/ruff_python_formatter/src/expression/expr_tuple.rs b/crates/ruff_python_formatter/src/expression/expr_tuple.rs index 7ca6ac0ccde5f3..1caacc10a89b3d 100644 --- a/crates/ruff_python_formatter/src/expression/expr_tuple.rs +++ b/crates/ruff_python_formatter/src/expression/expr_tuple.rs @@ -133,9 +133,7 @@ impl FormatNodeRule for FormatExprTuple { // ``` // In all other cases comments get assigned to a list element match elts.as_slice() { - [] => { - return empty_parenthesized("(", dangling, ")").fmt(f); - } + [] => empty_parenthesized("(", dangling, ")").fmt(f), [single] => match self.parentheses { TupleParentheses::Preserve if !is_parenthesized => { single.format().fmt(f)?; diff --git a/crates/ruff_python_formatter/src/expression/expr_yield.rs b/crates/ruff_python_formatter/src/expression/expr_yield.rs index 679cbef8965d25..8d8d13c726a269 100644 --- a/crates/ruff_python_formatter/src/expression/expr_yield.rs +++ b/crates/ruff_python_formatter/src/expression/expr_yield.rs @@ -14,7 +14,7 @@ pub(super) enum AnyExpressionYield<'a> { YieldFrom(&'a ExprYieldFrom), } -impl<'a> AnyExpressionYield<'a> { +impl AnyExpressionYield<'_> { const fn is_yield_from(&self) -> bool { matches!(self, AnyExpressionYield::YieldFrom(_)) } diff --git a/crates/ruff_python_formatter/src/shared_traits.rs b/crates/ruff_python_formatter/src/shared_traits.rs index 7ffa5d9484764f..6ccd9ac600ae2f 100644 --- a/crates/ruff_python_formatter/src/shared_traits.rs +++ b/crates/ruff_python_formatter/src/shared_traits.rs @@ -18,7 +18,10 @@ impl AsFormat for &T where T: AsFormat, { - type Format<'a> = T::Format<'a> where Self: 'a; + type Format<'a> + = T::Format<'a> + where + Self: 'a; fn format(&self) -> Self::Format<'_> { AsFormat::format(&**self) diff --git a/crates/ruff_python_formatter/src/statement/clause.rs b/crates/ruff_python_formatter/src/statement/clause.rs index 6e7e2adf5da2e6..0bfef484380141 100644 --- a/crates/ruff_python_formatter/src/statement/clause.rs +++ b/crates/ruff_python_formatter/src/statement/clause.rs @@ -36,7 +36,7 @@ pub(crate) enum ClauseHeader<'a> { OrElse(ElseClause<'a>), } -impl<'a> ClauseHeader<'a> { +impl ClauseHeader<'_> { /// The range from the clause keyword up to and including the final colon. pub(crate) fn range(self, source: &str) -> FormatResult { let keyword_range = self.first_keyword_range(source)?; diff --git a/crates/ruff_python_formatter/src/statement/stmt_try.rs b/crates/ruff_python_formatter/src/statement/stmt_try.rs index a24cc654ccea79..a3964ad214cfa0 100644 --- a/crates/ruff_python_formatter/src/statement/stmt_try.rs +++ b/crates/ruff_python_formatter/src/statement/stmt_try.rs @@ -47,12 +47,10 @@ impl FormatRule> for FormatExceptHandler { } impl<'ast> AsFormat> for ExceptHandler { - type Format<'a> = FormatRefWithRule< - 'a, - ExceptHandler, - FormatExceptHandler, - PyFormatContext<'ast>, - > where Self: 'a; + type Format<'a> + = FormatRefWithRule<'a, ExceptHandler, FormatExceptHandler, PyFormatContext<'ast>> + where + Self: 'a; fn format(&self) -> Self::Format<'_> { FormatRefWithRule::new(self, FormatExceptHandler::default()) diff --git a/crates/ruff_python_formatter/src/string/docstring.rs b/crates/ruff_python_formatter/src/string/docstring.rs index b078c5c6b3c90b..394cf09d0908b3 100644 --- a/crates/ruff_python_formatter/src/string/docstring.rs +++ b/crates/ruff_python_formatter/src/string/docstring.rs @@ -267,7 +267,7 @@ struct DocstringLinePrinter<'ast, 'buf, 'fmt, 'src> { code_example: CodeExample<'src>, } -impl<'ast, 'buf, 'fmt, 'src> DocstringLinePrinter<'ast, 'buf, 'fmt, 'src> { +impl<'src> DocstringLinePrinter<'_, '_, '_, 'src> { /// Print all of the lines in the given iterator to this /// printer's formatter. /// @@ -665,7 +665,7 @@ struct OutputDocstringLine<'src> { is_last: bool, } -impl<'src> OutputDocstringLine<'src> { +impl OutputDocstringLine<'_> { /// Return this reformatted line, but with the given function applied to /// the text of the line. fn map(self, mut map: impl FnMut(&str) -> String) -> OutputDocstringLine<'static> { @@ -1026,7 +1026,7 @@ impl<'src> CodeExampleRst<'src> { /// /// [literal block]: https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#literal-blocks /// [code block directive]: https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-code-block - fn new(original: InputDocstringLine<'src>) -> Option { + fn new(original: InputDocstringLine<'src>) -> Option> { let (opening_indent, rest) = indent_with_suffix(original.line); if rest.starts_with(".. ") { if let Some(litblock) = CodeExampleRst::new_code_block(original) { @@ -1061,7 +1061,7 @@ impl<'src> CodeExampleRst<'src> { /// Attempts to create a new reStructuredText code example from a /// `code-block` or `sourcecode` directive. If one couldn't be found, then /// `None` is returned. - fn new_code_block(original: InputDocstringLine<'src>) -> Option { + fn new_code_block(original: InputDocstringLine<'src>) -> Option> { // This regex attempts to parse the start of a reStructuredText code // block [directive]. From the reStructuredText spec: // diff --git a/crates/ruff_python_formatter/src/string/normalize.rs b/crates/ruff_python_formatter/src/string/normalize.rs index 6eb59bb05fb404..2606fd5e951c57 100644 --- a/crates/ruff_python_formatter/src/string/normalize.rs +++ b/crates/ruff_python_formatter/src/string/normalize.rs @@ -778,7 +778,7 @@ impl<'str> CharIndicesWithOffset<'str> { } } -impl<'str> Iterator for CharIndicesWithOffset<'str> { +impl Iterator for CharIndicesWithOffset<'_> { type Item = (usize, char); fn next(&mut self) -> Option { diff --git a/crates/ruff_python_formatter/src/verbatim.rs b/crates/ruff_python_formatter/src/verbatim.rs index 942eda70c859dd..6aac70efeac072 100644 --- a/crates/ruff_python_formatter/src/verbatim.rs +++ b/crates/ruff_python_formatter/src/verbatim.rs @@ -787,7 +787,7 @@ impl<'a> LogicalLinesIter<'a> { } } -impl<'a> Iterator for LogicalLinesIter<'a> { +impl Iterator for LogicalLinesIter<'_> { type Item = FormatResult; fn next(&mut self) -> Option { @@ -841,7 +841,7 @@ impl<'a> Iterator for LogicalLinesIter<'a> { } } -impl<'a> FusedIterator for LogicalLinesIter<'a> {} +impl FusedIterator for LogicalLinesIter<'_> {} /// A logical line or a comment (or form feed only) line struct LogicalLine { diff --git a/crates/ruff_python_literal/src/escape.rs b/crates/ruff_python_literal/src/escape.rs index 8aaab507c376c4..91157b57109ec8 100644 --- a/crates/ruff_python_literal/src/escape.rs +++ b/crates/ruff_python_literal/src/escape.rs @@ -202,7 +202,7 @@ impl UnicodeEscape<'_> { } } -impl<'a> Escape for UnicodeEscape<'a> { +impl Escape for UnicodeEscape<'_> { fn source_len(&self) -> usize { self.source.len() } @@ -337,7 +337,7 @@ impl AsciiEscape<'_> { } } -impl<'a> Escape for AsciiEscape<'a> { +impl Escape for AsciiEscape<'_> { fn source_len(&self) -> usize { self.source.len() } diff --git a/crates/ruff_python_parser/src/parser/pattern.rs b/crates/ruff_python_parser/src/parser/pattern.rs index 0685913e3b655a..80b6b294f0aa1e 100644 --- a/crates/ruff_python_parser/src/parser/pattern.rs +++ b/crates/ruff_python_parser/src/parser/pattern.rs @@ -49,7 +49,7 @@ const MAPPING_PATTERN_START_SET: TokenSet = TokenSet::new([ ]) .union(LITERAL_PATTERN_START_SET); -impl<'src> Parser<'src> { +impl Parser<'_> { /// Returns `true` if the current token is a valid start of a pattern. pub(super) fn at_pattern_start(&self) -> bool { self.at_ts(PATTERN_START_SET) || self.at_soft_keyword() diff --git a/crates/ruff_python_semantic/src/analyze/type_inference.rs b/crates/ruff_python_semantic/src/analyze/type_inference.rs index 6f7dfb0469a2ce..11a1c6b3f16039 100644 --- a/crates/ruff_python_semantic/src/analyze/type_inference.rs +++ b/crates/ruff_python_semantic/src/analyze/type_inference.rs @@ -113,33 +113,29 @@ impl From<&Expr> for ResolvedPythonType { // Unary operators. Expr::UnaryOp(ast::ExprUnaryOp { operand, op, .. }) => match op { - UnaryOp::Invert => { - return match ResolvedPythonType::from(operand.as_ref()) { - ResolvedPythonType::Atom(PythonType::Number( - NumberLike::Bool | NumberLike::Integer, - )) => ResolvedPythonType::Atom(PythonType::Number(NumberLike::Integer)), - ResolvedPythonType::Atom(_) => ResolvedPythonType::TypeError, - _ => ResolvedPythonType::Unknown, - } - } + UnaryOp::Invert => match ResolvedPythonType::from(operand.as_ref()) { + ResolvedPythonType::Atom(PythonType::Number( + NumberLike::Bool | NumberLike::Integer, + )) => ResolvedPythonType::Atom(PythonType::Number(NumberLike::Integer)), + ResolvedPythonType::Atom(_) => ResolvedPythonType::TypeError, + _ => ResolvedPythonType::Unknown, + }, // Ex) `not 1.0` UnaryOp::Not => ResolvedPythonType::Atom(PythonType::Number(NumberLike::Bool)), // Ex) `+1` or `-1` - UnaryOp::UAdd | UnaryOp::USub => { - return match ResolvedPythonType::from(operand.as_ref()) { - ResolvedPythonType::Atom(PythonType::Number(number)) => { - ResolvedPythonType::Atom(PythonType::Number( - if number == NumberLike::Bool { - NumberLike::Integer - } else { - number - }, - )) - } - ResolvedPythonType::Atom(_) => ResolvedPythonType::TypeError, - _ => ResolvedPythonType::Unknown, + UnaryOp::UAdd | UnaryOp::USub => match ResolvedPythonType::from(operand.as_ref()) { + ResolvedPythonType::Atom(PythonType::Number(number)) => { + ResolvedPythonType::Atom(PythonType::Number( + if number == NumberLike::Bool { + NumberLike::Integer + } else { + number + }, + )) } - } + ResolvedPythonType::Atom(_) => ResolvedPythonType::TypeError, + _ => ResolvedPythonType::Unknown, + }, }, // Binary operators. diff --git a/crates/ruff_python_semantic/src/binding.rs b/crates/ruff_python_semantic/src/binding.rs index 790a6d556b4aa9..83a3fc508feaf5 100644 --- a/crates/ruff_python_semantic/src/binding.rs +++ b/crates/ruff_python_semantic/src/binding.rs @@ -446,7 +446,7 @@ impl<'a> Deref for Bindings<'a> { } } -impl<'a> DerefMut for Bindings<'a> { +impl DerefMut for Bindings<'_> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } @@ -749,7 +749,7 @@ pub enum AnyImport<'a, 'ast> { FromImport(&'a FromImport<'ast>), } -impl<'a, 'ast> Imported<'ast> for AnyImport<'a, 'ast> { +impl<'ast> Imported<'ast> for AnyImport<'_, 'ast> { fn qualified_name(&self) -> &QualifiedName<'ast> { match self { Self::Import(import) => import.qualified_name(), diff --git a/crates/ruff_python_semantic/src/imports.rs b/crates/ruff_python_semantic/src/imports.rs index 6e7d1a0eaacc9f..0936ed02731cc8 100644 --- a/crates/ruff_python_semantic/src/imports.rs +++ b/crates/ruff_python_semantic/src/imports.rs @@ -209,7 +209,7 @@ impl<'de> serde::de::Deserialize<'de> for NameImports { struct AnyNameImportsVisitor; - impl<'de> serde::de::Visitor<'de> for AnyNameImportsVisitor { + impl serde::de::Visitor<'_> for AnyNameImportsVisitor { type Value = NameImports; fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { diff --git a/crates/ruff_python_semantic/src/model/all.rs b/crates/ruff_python_semantic/src/model/all.rs index d757823fba3ed9..e14f8e1e1c9cd5 100644 --- a/crates/ruff_python_semantic/src/model/all.rs +++ b/crates/ruff_python_semantic/src/model/all.rs @@ -70,7 +70,7 @@ impl Ranged for DunderAllDefinition<'_> { } } -impl<'a> SemanticModel<'a> { +impl SemanticModel<'_> { /// Extract the names bound to a given __all__ assignment. pub fn extract_dunder_all_names<'expr>( &self, diff --git a/crates/ruff_python_semantic/src/scope.rs b/crates/ruff_python_semantic/src/scope.rs index 9f610eba007b35..4ea1b52429690d 100644 --- a/crates/ruff_python_semantic/src/scope.rs +++ b/crates/ruff_python_semantic/src/scope.rs @@ -255,7 +255,7 @@ impl<'a> Deref for Scopes<'a> { } } -impl<'a> DerefMut for Scopes<'a> { +impl DerefMut for Scopes<'_> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } diff --git a/crates/ruff_server/src/lint.rs b/crates/ruff_server/src/lint.rs index 5b95488b32df2f..1d8bd511ce5eb7 100644 --- a/crates/ruff_server/src/lint.rs +++ b/crates/ruff_server/src/lint.rs @@ -156,7 +156,7 @@ pub(crate) fn check( .map(|(diagnostic, noqa_edit)| { to_lsp_diagnostic( diagnostic, - &noqa_edit, + noqa_edit, &source_kind, locator.to_index(), encoding, @@ -234,7 +234,7 @@ pub(crate) fn fixes_for_diagnostics( /// If the source kind is a text document, the cell index will always be `0`. fn to_lsp_diagnostic( diagnostic: Diagnostic, - noqa_edit: &Option, + noqa_edit: Option, source_kind: &SourceKind, index: &LineIndex, encoding: PositionEncoding, @@ -261,9 +261,9 @@ fn to_lsp_diagnostic( new_text: edit.content().unwrap_or_default().to_string(), }) .collect(); - let noqa_edit = noqa_edit.as_ref().map(|noqa_edit| lsp_types::TextEdit { + let noqa_edit = noqa_edit.map(|noqa_edit| lsp_types::TextEdit { range: diagnostic_edit_range(noqa_edit.range(), source_kind, index, encoding), - new_text: noqa_edit.content().unwrap_or_default().to_string(), + new_text: noqa_edit.into_content().unwrap_or_default().into_string(), }); serde_json::to_value(AssociatedDiagnosticData { kind: kind.clone(), diff --git a/crates/ruff_server/src/server/client.rs b/crates/ruff_server/src/server/client.rs index bd12f86d78e5c9..c5a502e213c5e6 100644 --- a/crates/ruff_server/src/server/client.rs +++ b/crates/ruff_server/src/server/client.rs @@ -26,7 +26,7 @@ pub(crate) struct Requester<'s> { response_handlers: FxHashMap>, } -impl<'s> Client<'s> { +impl Client<'_> { pub(super) fn new(sender: ClientSender) -> Self { Self { notifier: Notifier(sender.clone()), diff --git a/crates/ruff_server/src/session/index/ruff_settings.rs b/crates/ruff_server/src/session/index/ruff_settings.rs index 6166af800bc30d..9341595289e243 100644 --- a/crates/ruff_server/src/session/index/ruff_settings.rs +++ b/crates/ruff_server/src/session/index/ruff_settings.rs @@ -334,7 +334,7 @@ impl RuffSettingsIndex { struct EditorConfigurationTransformer<'a>(&'a ResolvedEditorSettings, &'a Path); -impl<'a> ConfigurationTransformer for EditorConfigurationTransformer<'a> { +impl ConfigurationTransformer for EditorConfigurationTransformer<'_> { fn transform(&self, filesystem_configuration: Configuration) -> Configuration { let ResolvedEditorSettings { configuration, diff --git a/crates/ruff_workspace/src/options_base.rs b/crates/ruff_workspace/src/options_base.rs index 7b2c2d405e3e52..a905db867229bc 100644 --- a/crates/ruff_workspace/src/options_base.rs +++ b/crates/ruff_workspace/src/options_base.rs @@ -333,7 +333,7 @@ struct SerializeVisitor<'a> { entries: &'a mut BTreeMap, } -impl<'a> Visit for SerializeVisitor<'a> { +impl Visit for SerializeVisitor<'_> { fn record_set(&mut self, name: &str, set: OptionSet) { // Collect the entries of the set. let mut entries = BTreeMap::new(); diff --git a/crates/ruff_workspace/src/resolver.rs b/crates/ruff_workspace/src/resolver.rs index fd77839c1dce50..080d96efb77a2a 100644 --- a/crates/ruff_workspace/src/resolver.rs +++ b/crates/ruff_workspace/src/resolver.rs @@ -186,7 +186,7 @@ impl<'a> Resolver<'a> { pub fn package_roots( &'a self, files: &[&'a Path], - ) -> FxHashMap<&'a Path, Option>> { + ) -> FxHashMap<&'a Path, Option>> { // Pre-populate the module cache, since the list of files could (but isn't // required to) contain some `__init__.py` files. let mut package_cache: FxHashMap<&Path, bool> = FxHashMap::default(); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 76fcadb5b3218f..a718dc2fc84c03 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.82" +channel = "1.83"