diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index a9d15274fa..b45689ec37 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -1812,14 +1812,12 @@ impl Macro { pub fn is_builtin_derive(&self, db: &dyn HirDatabase) -> bool { match self.id { - MacroId::Macro2Id(it) => match it.lookup(db.upcast()).expander { - MacroExpander::BuiltInDerive(_) => true, - _ => false, - }, - MacroId::MacroRulesId(it) => match it.lookup(db.upcast()).expander { - MacroExpander::BuiltInDerive(_) => true, - _ => false, - }, + MacroId::Macro2Id(it) => { + matches!(it.lookup(db.upcast()).expander, MacroExpander::BuiltInDerive(_)) + } + MacroId::MacroRulesId(it) => { + matches!(it.lookup(db.upcast()).expander, MacroExpander::BuiltInDerive(_)) + } MacroId::ProcMacroId(_) => false, } } diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index 6a761c505c..8e6b5283f1 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs @@ -504,10 +504,8 @@ impl DefCollector<'_> { } else { PathKind::Abs }; - let path = ModPath::from_segments( - path_kind.clone(), - [krate.clone(), name![prelude], edition].into_iter(), - ); + let path = + ModPath::from_segments(path_kind, [krate.clone(), name![prelude], edition].into_iter()); // Fall back to the older `std::prelude::v1` for compatibility with Rust <1.52.0 // FIXME remove this fallback let fallback_path = diff --git a/crates/hir_def/src/path.rs b/crates/hir_def/src/path.rs index a6141174c8..aea1e3ec34 100644 --- a/crates/hir_def/src/path.rs +++ b/crates/hir_def/src/path.rs @@ -120,7 +120,7 @@ impl Path { let res = Path { type_anchor: self.type_anchor.clone(), mod_path: Interned::new(ModPath::from_segments( - self.mod_path.kind.clone(), + self.mod_path.kind, self.mod_path.segments()[..self.mod_path.segments().len() - 1].iter().cloned(), )), generic_args: self.generic_args[..self.generic_args.len() - 1].to_vec().into(), diff --git a/crates/hir_expand/src/fixup.rs b/crates/hir_expand/src/fixup.rs index 63ab5e9b4a..c924478cec 100644 --- a/crates/hir_expand/src/fixup.rs +++ b/crates/hir_expand/src/fixup.rs @@ -176,7 +176,7 @@ mod tests { ); let mut actual = tt.to_string(); - actual.push_str("\n"); + actual.push('\n'); expect.indent(false); expect.assert_eq(&actual); diff --git a/crates/ide/src/annotations.rs b/crates/ide/src/annotations.rs index 8bfcf3beb8..676d4d51df 100644 --- a/crates/ide/src/annotations.rs +++ b/crates/ide/src/annotations.rs @@ -79,7 +79,7 @@ pub(crate) fn annotations( .map(|variant| { variant.source(db).and_then(|node| name_range(db, node, file_id)) }) - .filter_map(std::convert::identity) + .flatten() .for_each(|range| { annotations.push(Annotation { range, diff --git a/crates/ide/src/file_structure.rs b/crates/ide/src/file_structure.rs index 409f3901f5..68fd0952b4 100644 --- a/crates/ide/src/file_structure.rs +++ b/crates/ide/src/file_structure.rs @@ -138,7 +138,7 @@ fn structure_node(node: &SyntaxNode) -> Option { collapse_ws(param_list.syntax(), &mut detail); } if let Some(ret_type) = it.ret_type() { - detail.push_str(" "); + detail.push(' '); collapse_ws(ret_type.syntax(), &mut detail); } diff --git a/crates/ide_assists/src/handlers/generate_delegate_methods.rs b/crates/ide_assists/src/handlers/generate_delegate_methods.rs index 31b438b15e..f6e0d619de 100644 --- a/crates/ide_assists/src/handlers/generate_delegate_methods.rs +++ b/crates/ide_assists/src/handlers/generate_delegate_methods.rs @@ -156,7 +156,7 @@ pub(crate) fn generate_delegate_methods(acc: &mut Assists, ctx: &AssistContext) } None => { let offset = strukt.syntax().text_range().end(); - let snippet = format!("\n\n{}", impl_def.syntax().to_string()); + let snippet = format!("\n\n{}", impl_def.syntax()); builder.insert(offset, snippet); } } diff --git a/crates/ide_assists/src/handlers/merge_match_arms.rs b/crates/ide_assists/src/handlers/merge_match_arms.rs index 83d7f0338a..c87bd7f152 100644 --- a/crates/ide_assists/src/handlers/merge_match_arms.rs +++ b/crates/ide_assists/src/handlers/merge_match_arms.rs @@ -103,10 +103,7 @@ fn are_same_types( for (other_arm_type_name, other_arm_type) in arm_types { match (current_arm_types.get(&other_arm_type_name), other_arm_type) { (Some(Some(current_arm_type)), Some(other_arm_type)) - if other_arm_type.original == current_arm_type.original => - { - () - } + if other_arm_type.original == current_arm_type.original => {} _ => return false, } } diff --git a/crates/ide_assists/src/utils/gen_trait_fn_body.rs b/crates/ide_assists/src/utils/gen_trait_fn_body.rs index f6ca3b2110..30b994806b 100644 --- a/crates/ide_assists/src/utils/gen_trait_fn_body.rs +++ b/crates/ide_assists/src/utils/gen_trait_fn_body.rs @@ -206,7 +206,7 @@ fn gen_debug_impl(adt: &ast::Adt, func: &ast::Fn) -> Option<()> { // => .field(field) let method_name = make::name_ref("field"); - let field_path = &format!("{}", name); + let field_path = &name.to_string(); let field_path = make::expr_path(make::ext::ident_path(field_path)); let args = make::arg_list(vec![field_path]); expr = make::expr_method_call(expr, method_name, args); diff --git a/crates/ide_db/src/famous_defs.rs b/crates/ide_db/src/famous_defs.rs index 142feff4cd..cc9f2f9151 100644 --- a/crates/ide_db/src/famous_defs.rs +++ b/crates/ide_db/src/famous_defs.rs @@ -108,7 +108,7 @@ impl FamousDefs<'_, '_> { self.test(), self.proc_macro(), ]) - .filter_map(|it| it) + .flatten() } fn find_trait(&self, path: &str) -> Option { diff --git a/crates/rust-analyzer/tests/slow-tests/main.rs b/crates/rust-analyzer/tests/slow-tests/main.rs index a55d3c2405..eb7e73236a 100644 --- a/crates/rust-analyzer/tests/slow-tests/main.rs +++ b/crates/rust-analyzer/tests/slow-tests/main.rs @@ -533,7 +533,7 @@ mod bar; fn main() {{}} "#, - PROJECT = project.to_string(), + PROJECT = project, ); let server = diff --git a/crates/text_edit/src/lib.rs b/crates/text_edit/src/lib.rs index bd3fcb870a..922d24bc75 100644 --- a/crates/text_edit/src/lib.rs +++ b/crates/text_edit/src/lib.rs @@ -94,7 +94,7 @@ impl TextEdit { let text_size = TextSize::of(&*text); let mut total_len = text_size; - let mut max_total_len = text_size.clone(); + let mut max_total_len = text_size; for indel in &self.indels { total_len += TextSize::of(&indel.insert); total_len -= indel.delete.len();