diff --git a/crates/assists/src/handlers/add_missing_impl_members.rs b/crates/assists/src/handlers/add_missing_impl_members.rs index 1ac5fefd6a..51b5a2eb07 100644 --- a/crates/assists/src/handlers/add_missing_impl_members.rs +++ b/crates/assists/src/handlers/add_missing_impl_members.rs @@ -146,7 +146,7 @@ fn add_missing_impl_members_inner( let target = impl_def.syntax().text_range(); acc.add(AssistId(assist_id, AssistKind::QuickFix), label, target, |builder| { - let impl_item_list = impl_def.assoc_item_list().unwrap_or(make::assoc_item_list()); + let impl_item_list = impl_def.assoc_item_list().unwrap_or_else(make::assoc_item_list); let n_existing_items = impl_item_list.assoc_items().count(); let source_scope = ctx.sema.scope_for_def(trait_); diff --git a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs index d1eadaa996..f5f03ef362 100644 --- a/crates/assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/assists/src/handlers/extract_struct_from_enum_variant.rs @@ -91,7 +91,7 @@ fn existing_struct_def(db: &RootDatabase, variant_name: &str, variant: &EnumVari .module(db) .scope(db, None) .into_iter() - .any(|(name, _)| name.to_string() == variant_name.to_string()) + .any(|(name, _)| name.to_string() == variant_name) } #[allow(dead_code)] diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs index 567fd91afb..5721a66c4a 100644 --- a/crates/hir/src/code_model.rs +++ b/crates/hir/src/code_model.rs @@ -145,7 +145,7 @@ impl Crate { } }).flat_map(|t| t).next(); - doc_url.map(|s| s.trim_matches('"').trim_end_matches("/").to_owned() + "/") + doc_url.map(|s| s.trim_matches('"').trim_end_matches('/').to_owned() + "/") } } diff --git a/crates/ide/src/link_rewrite.rs b/crates/ide/src/link_rewrite.rs index 107787bb91..a16f90e171 100644 --- a/crates/ide/src/link_rewrite.rs +++ b/crates/ide/src/link_rewrite.rs @@ -120,7 +120,7 @@ fn rewrite_intra_doc_link( /// Try to resolve path to local documentation via path-based links (i.e. `../gateway/struct.Shard.html`). fn rewrite_url_link(db: &RootDatabase, def: ModuleDef, target: &str) -> Option { - if !(target.contains("#") || target.contains(".html")) { + if !(target.contains('#') || target.contains(".html")) { return None; } @@ -190,7 +190,7 @@ fn strip_prefixes_suffixes(mut s: &str) -> &str { prefixes.clone().for_each(|prefix| s = s.trim_start_matches(*prefix)); suffixes.clone().for_each(|suffix| s = s.trim_end_matches(*suffix)); }); - s.trim_start_matches("@").trim() + s.trim_start_matches('@').trim() } static TYPES: ([&str; 7], [&str; 0]) = diff --git a/crates/ssr/src/resolving.rs b/crates/ssr/src/resolving.rs index 5d2cbec47a..347cc4aad8 100644 --- a/crates/ssr/src/resolving.rs +++ b/crates/ssr/src/resolving.rs @@ -205,7 +205,7 @@ impl<'db> ResolutionScope<'db> { /// Returns the function in which SSR was invoked, if any. pub(crate) fn current_function(&self) -> Option { - self.node.ancestors().find(|node| node.kind() == SyntaxKind::FN).map(|node| node.clone()) + self.node.ancestors().find(|node| node.kind() == SyntaxKind::FN) } fn resolve_path(&self, path: &ast::Path) -> Option { diff --git a/crates/syntax/src/ast/edit.rs b/crates/syntax/src/ast/edit.rs index dda0a03190..77233ab31a 100644 --- a/crates/syntax/src/ast/edit.rs +++ b/crates/syntax/src/ast/edit.rs @@ -159,7 +159,7 @@ impl ast::AssocItemList { let whitespace = last_token_before_curly.clone().into_token().and_then(ast::Whitespace::cast)?; let text = whitespace.syntax().text(); - let newline = text.rfind("\n")?; + let newline = text.rfind('\n')?; let keep = tokens::WsBuilder::new(&text[newline..]); Some(self.replace_children( first_token_after_items..=last_token_before_curly,