From 4e793e78590e0a3a6a5e4b07f501c88479bd2472 Mon Sep 17 00:00:00 2001 From: Ryo Yoshida Date: Thu, 29 Jun 2023 23:27:28 +0900 Subject: [PATCH] Use anonymous lifetime where possible --- crates/hir-def/src/body/pretty.rs | 4 ++-- crates/hir-def/src/item_tree/pretty.rs | 4 ++-- crates/hir-expand/src/lib.rs | 2 +- crates/hir-expand/src/mod_path.rs | 4 ++-- crates/hir-expand/src/name.rs | 8 ++++---- crates/hir-ty/src/chalk_db.rs | 2 +- crates/hir-ty/src/display.rs | 6 +++--- crates/hir-ty/src/infer/coerce.rs | 4 ++-- crates/hir-ty/src/infer/expr.rs | 2 +- crates/hir-ty/src/infer/mutability.rs | 2 +- crates/hir-ty/src/infer/pat.rs | 2 +- crates/hir-ty/src/infer/unify.rs | 8 ++++---- crates/hir-ty/src/lower.rs | 6 +++--- crates/hir-ty/src/traits.rs | 2 +- crates/hir-ty/src/utils.rs | 4 ++-- crates/hir/src/semantics.rs | 2 +- .../ide-assists/src/handlers/pull_assignment_up.rs | 2 +- crates/ide-db/src/path_transform.rs | 2 +- crates/ide-db/src/search.rs | 8 ++++---- crates/ide-diagnostics/src/lib.rs | 2 +- crates/ide-ssr/src/search.rs | 2 +- crates/mbe/src/expander/matcher.rs | 2 +- crates/mbe/src/syntax_bridge.rs | 12 ++++++------ crates/mbe/src/tt_iter.rs | 2 +- crates/parser/src/shortcuts.rs | 2 +- crates/profile/src/tree.rs | 2 +- crates/rust-analyzer/src/bin/logger.rs | 4 ++-- crates/rust-analyzer/src/dispatch.rs | 4 ++-- crates/rust-analyzer/tests/slow-tests/support.rs | 8 ++++---- crates/tt/src/buffer.rs | 6 +++--- 30 files changed, 60 insertions(+), 60 deletions(-) diff --git a/crates/hir-def/src/body/pretty.rs b/crates/hir-def/src/body/pretty.rs index cd6df0e6325..0c6cf0b49a2 100644 --- a/crates/hir-def/src/body/pretty.rs +++ b/crates/hir-def/src/body/pretty.rs @@ -105,7 +105,7 @@ struct Printer<'a> { needs_indent: bool, } -impl<'a> Write for Printer<'a> { +impl Write for Printer<'_> { fn write_str(&mut self, s: &str) -> fmt::Result { for line in s.split_inclusive('\n') { if self.needs_indent { @@ -125,7 +125,7 @@ impl<'a> Write for Printer<'a> { } } -impl<'a> Printer<'a> { +impl Printer<'_> { fn indented(&mut self, f: impl FnOnce(&mut Self)) { self.indent_level += 1; wln!(self); diff --git a/crates/hir-def/src/item_tree/pretty.rs b/crates/hir-def/src/item_tree/pretty.rs index e873316a578..ddf668d20b0 100644 --- a/crates/hir-def/src/item_tree/pretty.rs +++ b/crates/hir-def/src/item_tree/pretty.rs @@ -52,7 +52,7 @@ struct Printer<'a> { needs_indent: bool, } -impl<'a> Printer<'a> { +impl Printer<'_> { fn indented(&mut self, f: impl FnOnce(&mut Self)) { self.indent_level += 1; wln!(self); @@ -572,7 +572,7 @@ impl<'a> Printer<'a> { } } -impl<'a> Write for Printer<'a> { +impl Write for Printer<'_> { fn write_str(&mut self, s: &str) -> fmt::Result { for line in s.split_inclusive('\n') { if self.needs_indent { diff --git a/crates/hir-expand/src/lib.rs b/crates/hir-expand/src/lib.rs index e0c199328ef..4c37ad3d154 100644 --- a/crates/hir-expand/src/lib.rs +++ b/crates/hir-expand/src/lib.rs @@ -850,7 +850,7 @@ impl InFile> { } } -impl<'a> InFile<&'a SyntaxNode> { +impl InFile<&SyntaxNode> { pub fn ancestors_with_macros( self, db: &dyn db::ExpandDatabase, diff --git a/crates/hir-expand/src/mod_path.rs b/crates/hir-expand/src/mod_path.rs index 47a8ab7de77..69aa09c4a52 100644 --- a/crates/hir-expand/src/mod_path.rs +++ b/crates/hir-expand/src/mod_path.rs @@ -126,7 +126,7 @@ struct Display<'a> { path: &'a ModPath, } -impl<'a> fmt::Display for Display<'a> { +impl fmt::Display for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { display_fmt_path(self.db, self.path, f, true) } @@ -137,7 +137,7 @@ struct UnescapedDisplay<'a> { path: &'a UnescapedModPath<'a>, } -impl<'a> fmt::Display for UnescapedDisplay<'a> { +impl fmt::Display for UnescapedDisplay<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { display_fmt_path(self.db, self.path.0, f, false) } diff --git a/crates/hir-expand/src/name.rs b/crates/hir-expand/src/name.rs index f8dbb842775..6e61762f169 100644 --- a/crates/hir-expand/src/name.rs +++ b/crates/hir-expand/src/name.rs @@ -24,7 +24,7 @@ enum Repr { TupleField(usize), } -impl<'a> UnescapedName<'a> { +impl UnescapedName<'_> { /// Returns the textual representation of this name as a [`SmolStr`]. Prefer using this over /// [`ToString::to_string`] if possible as this conversion is cheaper in the general case. pub fn to_smol_str(&self) -> SmolStr { @@ -40,7 +40,7 @@ impl<'a> UnescapedName<'a> { } } - pub fn display(&'a self, db: &dyn crate::db::ExpandDatabase) -> impl fmt::Display + 'a { + pub fn display(&self, db: &dyn crate::db::ExpandDatabase) -> impl fmt::Display + '_ { _ = db; UnescapedDisplay { name: self } } @@ -162,7 +162,7 @@ struct Display<'a> { name: &'a Name, } -impl<'a> fmt::Display for Display<'a> { +impl fmt::Display for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match &self.name.0 { Repr::Text(text) => fmt::Display::fmt(&text, f), @@ -175,7 +175,7 @@ struct UnescapedDisplay<'a> { name: &'a UnescapedName<'a>, } -impl<'a> fmt::Display for UnescapedDisplay<'a> { +impl fmt::Display for UnescapedDisplay<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match &self.name.0 .0 { Repr::Text(text) => { diff --git a/crates/hir-ty/src/chalk_db.rs b/crates/hir-ty/src/chalk_db.rs index fb8c9a9a1c4..684a74693ef 100644 --- a/crates/hir-ty/src/chalk_db.rs +++ b/crates/hir-ty/src/chalk_db.rs @@ -46,7 +46,7 @@ pub(crate) type AssociatedTyValue = chalk_solve::rust_ir::AssociatedTyValue; pub(crate) type Variances = chalk_ir::Variances; -impl<'a> chalk_solve::RustIrDatabase for ChalkContext<'a> { +impl chalk_solve::RustIrDatabase for ChalkContext<'_> { fn associated_ty_data(&self, id: AssocTypeId) -> Arc { self.db.associated_ty_data(id) } diff --git a/crates/hir-ty/src/display.rs b/crates/hir-ty/src/display.rs index c1df24d1729..82cc4f9f590 100644 --- a/crates/hir-ty/src/display.rs +++ b/crates/hir-ty/src/display.rs @@ -192,7 +192,7 @@ pub trait HirDisplay { } } -impl<'a> HirFormatter<'a> { +impl HirFormatter<'_> { pub fn write_joined( &mut self, iter: impl IntoIterator, @@ -342,7 +342,7 @@ impl HirDisplayWrapper<'_, T> { } } -impl<'a, T> fmt::Display for HirDisplayWrapper<'a, T> +impl fmt::Display for HirDisplayWrapper<'_, T> where T: HirDisplay, { @@ -360,7 +360,7 @@ where const TYPE_HINT_TRUNCATION: &str = "…"; -impl HirDisplay for &'_ T { +impl HirDisplay for &T { fn hir_fmt(&self, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> { HirDisplay::hir_fmt(*self, f) } diff --git a/crates/hir-ty/src/infer/coerce.rs b/crates/hir-ty/src/infer/coerce.rs index 05a476f632d..7c5fe22bfae 100644 --- a/crates/hir-ty/src/infer/coerce.rs +++ b/crates/hir-ty/src/infer/coerce.rs @@ -220,7 +220,7 @@ pub(crate) fn coerce( Ok((adjustments, table.resolve_with_fallback(ty, &fallback))) } -impl<'a> InferenceContext<'a> { +impl InferenceContext<'_> { /// Unify two types, but may coerce the first one to the second one /// using "implicit coercion rules" if needed. pub(super) fn coerce( @@ -239,7 +239,7 @@ impl<'a> InferenceContext<'a> { } } -impl<'a> InferenceTable<'a> { +impl InferenceTable<'_> { /// Unify two types, but may coerce the first one to the second one /// using "implicit coercion rules" if needed. pub(crate) fn coerce( diff --git a/crates/hir-ty/src/infer/expr.rs b/crates/hir-ty/src/infer/expr.rs index 194471f0048..6c91f8426e4 100644 --- a/crates/hir-ty/src/infer/expr.rs +++ b/crates/hir-ty/src/infer/expr.rs @@ -50,7 +50,7 @@ use super::{ InferenceContext, InferenceDiagnostic, TypeMismatch, }; -impl<'a> InferenceContext<'a> { +impl InferenceContext<'_> { pub(crate) fn infer_expr(&mut self, tgt_expr: ExprId, expected: &Expectation) -> Ty { let ty = self.infer_expr_inner(tgt_expr, expected); if let Some(expected_ty) = expected.only_has_type(&mut self.table) { diff --git a/crates/hir-ty/src/infer/mutability.rs b/crates/hir-ty/src/infer/mutability.rs index 46f2e1d7d12..2f307408c62 100644 --- a/crates/hir-ty/src/infer/mutability.rs +++ b/crates/hir-ty/src/infer/mutability.rs @@ -12,7 +12,7 @@ use crate::{lower::lower_to_chalk_mutability, Adjust, Adjustment, AutoBorrow, Ov use super::InferenceContext; -impl<'a> InferenceContext<'a> { +impl InferenceContext<'_> { pub(crate) fn infer_mut_body(&mut self) { self.infer_mut_expr(self.body.body_expr, Mutability::Not); } diff --git a/crates/hir-ty/src/infer/pat.rs b/crates/hir-ty/src/infer/pat.rs index 2480f8babac..415b4e1d9f1 100644 --- a/crates/hir-ty/src/infer/pat.rs +++ b/crates/hir-ty/src/infer/pat.rs @@ -56,7 +56,7 @@ impl PatLike for PatId { } } -impl<'a> InferenceContext<'a> { +impl InferenceContext<'_> { /// Infers type for tuple struct pattern or its corresponding assignee expression. /// /// Ellipses found in the original pattern or expression must be filtered out. diff --git a/crates/hir-ty/src/infer/unify.rs b/crates/hir-ty/src/infer/unify.rs index e33d8f1795e..e322c5dbfec 100644 --- a/crates/hir-ty/src/infer/unify.rs +++ b/crates/hir-ty/src/infer/unify.rs @@ -22,7 +22,7 @@ use crate::{ TraitEnvironment, Ty, TyBuilder, TyExt, TyKind, VariableKind, }; -impl<'a> InferenceContext<'a> { +impl InferenceContext<'_> { pub(super) fn canonicalize + HasInterner>( &mut self, t: T, @@ -547,7 +547,7 @@ impl<'a> InferenceTable<'a> { table: &'a mut InferenceTable<'b>, highest_known_var: InferenceVar, } - impl<'a, 'b> TypeFolder for VarFudger<'a, 'b> { + impl TypeFolder for VarFudger<'_, '_> { fn as_dyn(&mut self) -> &mut dyn TypeFolder { self } @@ -798,7 +798,7 @@ impl<'a> InferenceTable<'a> { } } -impl<'a> fmt::Debug for InferenceTable<'a> { +impl fmt::Debug for InferenceTable<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("InferenceTable").field("num_vars", &self.type_variable_table.len()).finish() } @@ -826,7 +826,7 @@ mod resolve { pub(super) var_stack: &'a mut Vec, pub(super) fallback: F, } - impl<'a, 'b, F> TypeFolder for Resolver<'a, 'b, F> + impl TypeFolder for Resolver<'_, '_, F> where F: Fn(InferenceVar, VariableKind, GenericArg, DebruijnIndex) -> GenericArg, { diff --git a/crates/hir-ty/src/lower.rs b/crates/hir-ty/src/lower.rs index 9951a1c750b..e21f77a2d74 100644 --- a/crates/hir-ty/src/lower.rs +++ b/crates/hir-ty/src/lower.rs @@ -959,10 +959,10 @@ impl<'a> TyLoweringContext<'a> { } pub(crate) fn lower_where_predicate( - &'a self, - where_predicate: &'a WherePredicate, + &self, + where_predicate: &WherePredicate, ignore_bindings: bool, - ) -> impl Iterator + 'a { + ) -> impl Iterator { match where_predicate { WherePredicate::ForLifetime { target, bound, .. } | WherePredicate::TypeBound { target, bound } => { diff --git a/crates/hir-ty/src/traits.rs b/crates/hir-ty/src/traits.rs index f40b7db3a55..3c7cfbaed3a 100644 --- a/crates/hir-ty/src/traits.rs +++ b/crates/hir-ty/src/traits.rs @@ -170,7 +170,7 @@ fn solve( struct LoggingRustIrDatabaseLoggingOnDrop<'a>(LoggingRustIrDatabase>); -impl<'a> Drop for LoggingRustIrDatabaseLoggingOnDrop<'a> { +impl Drop for LoggingRustIrDatabaseLoggingOnDrop<'_> { fn drop(&mut self) { eprintln!("chalk program:\n{}", self.0); } diff --git a/crates/hir-ty/src/utils.rs b/crates/hir-ty/src/utils.rs index 3636580630d..0c38fe5d6ab 100644 --- a/crates/hir-ty/src/utils.rs +++ b/crates/hir-ty/src/utils.rs @@ -89,7 +89,7 @@ struct SuperTraits<'a> { seen: FxHashSet, } -impl<'a> SuperTraits<'a> { +impl SuperTraits<'_> { fn elaborate(&mut self, trait_ref: &TraitRef) { direct_super_trait_refs(self.db, trait_ref, |trait_ref| { if !self.seen.contains(&trait_ref.trait_id) { @@ -99,7 +99,7 @@ impl<'a> SuperTraits<'a> { } } -impl<'a> Iterator for SuperTraits<'a> { +impl Iterator for SuperTraits<'_> { type Item = TraitRef; fn next(&mut self) -> Option { diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index 5a76a9185a2..0c46e2a4fe5 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -1631,7 +1631,7 @@ pub struct SemanticsScope<'a> { resolver: Resolver, } -impl<'a> SemanticsScope<'a> { +impl SemanticsScope<'_> { pub fn module(&self) -> Module { Module { id: self.resolver.module() } } diff --git a/crates/ide-assists/src/handlers/pull_assignment_up.rs b/crates/ide-assists/src/handlers/pull_assignment_up.rs index a5c7fea403d..f222b3eb903 100644 --- a/crates/ide-assists/src/handlers/pull_assignment_up.rs +++ b/crates/ide-assists/src/handlers/pull_assignment_up.rs @@ -102,7 +102,7 @@ struct AssignmentsCollector<'a> { assignments: Vec<(ast::BinExpr, ast::Expr)>, } -impl<'a> AssignmentsCollector<'a> { +impl AssignmentsCollector<'_> { fn collect_match(&mut self, match_expr: &ast::MatchExpr) -> Option<()> { for arm in match_expr.match_arm_list()?.arms() { match arm.expr()? { diff --git a/crates/ide-db/src/path_transform.rs b/crates/ide-db/src/path_transform.rs index 73e6a920ee4..1d0cb426a57 100644 --- a/crates/ide-db/src/path_transform.rs +++ b/crates/ide-db/src/path_transform.rs @@ -195,7 +195,7 @@ fn postorder(item: &SyntaxNode) -> impl Iterator { }) } -impl<'a> Ctx<'a> { +impl Ctx<'_> { fn apply(&self, item: &SyntaxNode) { // `transform_path` may update a node's parent and that would break the // tree traversal. Thus all paths in the tree are collected into a vec diff --git a/crates/ide-db/src/search.rs b/crates/ide-db/src/search.rs index 16f35981838..f3c0f79c589 100644 --- a/crates/ide-db/src/search.rs +++ b/crates/ide-db/src/search.rs @@ -338,21 +338,21 @@ pub struct FindUsages<'a> { search_self_mod: bool, } -impl<'a> FindUsages<'a> { +impl FindUsages<'_> { /// Enable searching for `Self` when the definition is a type or `self` for modules. - pub fn include_self_refs(mut self) -> FindUsages<'a> { + pub fn include_self_refs(mut self) -> Self { self.include_self_kw_refs = def_to_ty(self.sema, &self.def); self.search_self_mod = true; self } /// Limit the search to a given [`SearchScope`]. - pub fn in_scope(self, scope: SearchScope) -> FindUsages<'a> { + pub fn in_scope(self, scope: SearchScope) -> Self { self.set_scope(Some(scope)) } /// Limit the search to a given [`SearchScope`]. - pub fn set_scope(mut self, scope: Option) -> FindUsages<'a> { + pub fn set_scope(mut self, scope: Option) -> Self { assert!(self.scope.is_none()); self.scope = scope; self diff --git a/crates/ide-diagnostics/src/lib.rs b/crates/ide-diagnostics/src/lib.rs index 55a4a482d3b..f883ea8d4fc 100644 --- a/crates/ide-diagnostics/src/lib.rs +++ b/crates/ide-diagnostics/src/lib.rs @@ -194,7 +194,7 @@ struct DiagnosticsContext<'a> { resolve: &'a AssistResolveStrategy, } -impl<'a> DiagnosticsContext<'a> { +impl DiagnosticsContext<'_> { fn resolve_precise_location( &self, node: &InFile, diff --git a/crates/ide-ssr/src/search.rs b/crates/ide-ssr/src/search.rs index 0a85569b600..96c193bd539 100644 --- a/crates/ide-ssr/src/search.rs +++ b/crates/ide-ssr/src/search.rs @@ -22,7 +22,7 @@ pub(crate) struct UsageCache { usages: Vec<(Definition, UsageSearchResult)>, } -impl<'db> MatchFinder<'db> { +impl MatchFinder<'_> { /// Adds all matches for `rule` to `matches_out`. Matches may overlap in ways that make /// replacement impossible, so further processing is required in order to properly nest matches /// and remove overlapping matches. This is done in the `nesting` module. diff --git a/crates/mbe/src/expander/matcher.rs b/crates/mbe/src/expander/matcher.rs index 474826079d7..1a7b7eed295 100644 --- a/crates/mbe/src/expander/matcher.rs +++ b/crates/mbe/src/expander/matcher.rs @@ -884,7 +884,7 @@ impl<'a> Iterator for OpDelimitedIter<'a> { } } -impl<'a> TtIter<'a> { +impl TtIter<'_> { fn expect_separator(&mut self, separator: &Separator) -> bool { let mut fork = self.clone(); let ok = match separator { diff --git a/crates/mbe/src/syntax_bridge.rs b/crates/mbe/src/syntax_bridge.rs index 8cbf0f8fc0b..b90a067d2ac 100644 --- a/crates/mbe/src/syntax_bridge.rs +++ b/crates/mbe/src/syntax_bridge.rs @@ -509,12 +509,12 @@ trait TokenConverter: Sized { fn id_alloc(&mut self) -> &mut TokenIdAlloc; } -impl<'a> SrcToken> for usize { - fn kind(&self, ctx: &RawConverter<'a>) -> SyntaxKind { +impl SrcToken> for usize { + fn kind(&self, ctx: &RawConverter<'_>) -> SyntaxKind { ctx.lexed.kind(*self) } - fn to_char(&self, ctx: &RawConverter<'a>) -> Option { + fn to_char(&self, ctx: &RawConverter<'_>) -> Option { ctx.lexed.text(*self).chars().next() } @@ -522,12 +522,12 @@ impl<'a> SrcToken> for usize { ctx.lexed.text(*self).into() } - fn synthetic_id(&self, _ctx: &RawConverter<'a>) -> Option { + fn synthetic_id(&self, _ctx: &RawConverter<'_>) -> Option { None } } -impl<'a> TokenConverter for RawConverter<'a> { +impl TokenConverter for RawConverter<'_> { type Token = usize; fn convert_doc_comment(&self, &token: &usize, span: tt::TokenId) -> Option> { @@ -800,7 +800,7 @@ fn delim_to_str(d: tt::DelimiterKind, closing: bool) -> Option<&'static str> { Some(&texts[idx..texts.len() - (1 - idx)]) } -impl<'a> TtTreeSink<'a> { +impl TtTreeSink<'_> { /// Parses a float literal as if it was a one to two name ref nodes with a dot inbetween. /// This occurs when a float literal is used as a field access. fn float_split(&mut self, has_pseudo_dot: bool) { diff --git a/crates/mbe/src/tt_iter.rs b/crates/mbe/src/tt_iter.rs index 59dbf156800..79ff8ca28e8 100644 --- a/crates/mbe/src/tt_iter.rs +++ b/crates/mbe/src/tt_iter.rs @@ -197,4 +197,4 @@ impl<'a> Iterator for TtIter<'a> { } } -impl<'a> std::iter::ExactSizeIterator for TtIter<'a> {} +impl std::iter::ExactSizeIterator for TtIter<'_> {} diff --git a/crates/parser/src/shortcuts.rs b/crates/parser/src/shortcuts.rs index 5cdb39700dd..6e3ae656b02 100644 --- a/crates/parser/src/shortcuts.rs +++ b/crates/parser/src/shortcuts.rs @@ -24,7 +24,7 @@ pub enum StrStep<'a> { Error { msg: &'a str, pos: usize }, } -impl<'a> LexedStr<'a> { +impl LexedStr<'_> { pub fn to_input(&self) -> crate::Input { let mut res = crate::Input::default(); let mut was_joint = false; diff --git a/crates/profile/src/tree.rs b/crates/profile/src/tree.rs index 62f0c30b529..1290fba36fa 100644 --- a/crates/profile/src/tree.rs +++ b/crates/profile/src/tree.rs @@ -72,7 +72,7 @@ struct NodeIter<'a, T> { next: Option>, } -impl<'a, T> Iterator for NodeIter<'a, T> { +impl Iterator for NodeIter<'_, T> { type Item = Idx; fn next(&mut self) -> Option> { diff --git a/crates/rust-analyzer/src/bin/logger.rs b/crates/rust-analyzer/src/bin/logger.rs index 867907dca39..1f923f6cf8d 100644 --- a/crates/rust-analyzer/src/bin/logger.rs +++ b/crates/rust-analyzer/src/bin/logger.rs @@ -32,10 +32,10 @@ pub(crate) struct LoggerConfig { struct MakeWriterStderr; -impl<'a> MakeWriter<'a> for MakeWriterStderr { +impl MakeWriter<'_> for MakeWriterStderr { type Writer = Stderr; - fn make_writer(&'a self) -> Self::Writer { + fn make_writer(&self) -> Self::Writer { io::stderr() } } diff --git a/crates/rust-analyzer/src/dispatch.rs b/crates/rust-analyzer/src/dispatch.rs index 9a876f4b97f..5e5cd9a0269 100644 --- a/crates/rust-analyzer/src/dispatch.rs +++ b/crates/rust-analyzer/src/dispatch.rs @@ -32,7 +32,7 @@ pub(crate) struct RequestDispatcher<'a> { pub(crate) global_state: &'a mut GlobalState, } -impl<'a> RequestDispatcher<'a> { +impl RequestDispatcher<'_> { /// Dispatches the request onto the current thread, given full access to /// mutable global state. Unlike all other methods here, this one isn't /// guarded by `catch_unwind`, so, please, don't make bugs :-) @@ -306,7 +306,7 @@ pub(crate) struct NotificationDispatcher<'a> { pub(crate) global_state: &'a mut GlobalState, } -impl<'a> NotificationDispatcher<'a> { +impl NotificationDispatcher<'_> { pub(crate) fn on_sync_mut( &mut self, f: fn(&mut GlobalState, N::Params) -> anyhow::Result<()>, diff --git a/crates/rust-analyzer/tests/slow-tests/support.rs b/crates/rust-analyzer/tests/slow-tests/support.rs index 21053c86cee..3c52ef5ef7f 100644 --- a/crates/rust-analyzer/tests/slow-tests/support.rs +++ b/crates/rust-analyzer/tests/slow-tests/support.rs @@ -25,7 +25,7 @@ pub(crate) struct Project<'a> { config: serde_json::Value, } -impl<'a> Project<'a> { +impl Project<'_> { pub(crate) fn with_fixture(fixture: &str) -> Project<'_> { Project { fixture, @@ -48,17 +48,17 @@ impl<'a> Project<'a> { } } - pub(crate) fn tmp_dir(mut self, tmp_dir: TestDir) -> Project<'a> { + pub(crate) fn tmp_dir(mut self, tmp_dir: TestDir) -> Self { self.tmp_dir = Some(tmp_dir); self } - pub(crate) fn root(mut self, path: &str) -> Project<'a> { + pub(crate) fn root(mut self, path: &str) -> Self { self.roots.push(path.into()); self } - pub(crate) fn with_config(mut self, config: serde_json::Value) -> Project<'a> { + pub(crate) fn with_config(mut self, config: serde_json::Value) -> Self { fn merge(dst: &mut serde_json::Value, src: serde_json::Value) { match (dst, src) { (Value::Object(dst), Value::Object(src)) => { diff --git a/crates/tt/src/buffer.rs b/crates/tt/src/buffer.rs index 0615a3763df..cade2e9f67a 100644 --- a/crates/tt/src/buffer.rs +++ b/crates/tt/src/buffer.rs @@ -134,7 +134,7 @@ pub enum TokenTreeRef<'a, Span> { Leaf(&'a Leaf, &'a TokenTree), } -impl<'a, Span: Clone> TokenTreeRef<'a, Span> { +impl TokenTreeRef<'_, Span> { pub fn cloned(&self) -> TokenTree { match self { TokenTreeRef::Subtree(subtree, tt) => match tt { @@ -153,13 +153,13 @@ pub struct Cursor<'a, Span> { ptr: EntryPtr, } -impl<'a, Span> PartialEq for Cursor<'a, Span> { +impl PartialEq for Cursor<'_, Span> { fn eq(&self, other: &Cursor<'_, Span>) -> bool { self.ptr == other.ptr && std::ptr::eq(self.buffer, other.buffer) } } -impl<'a, Span> Eq for Cursor<'a, Span> {} +impl Eq for Cursor<'_, Span> {} impl<'a, Span> Cursor<'a, Span> { /// Check whether it is eof