diff --git a/clippy_lints/src/else_if_without_else.rs b/clippy_lints/src/else_if_without_else.rs index 21a77e2263f..da6e860e236 100644 --- a/clippy_lints/src/else_if_without_else.rs +++ b/clippy_lints/src/else_if_without_else.rs @@ -62,7 +62,7 @@ impl EarlyLintPass for ElseIfWithoutElse { els.span, "if expression with an `else if`, but without a final `else`", "add an `else` block here", - "".to_string() + String::new() ); } diff --git a/clippy_lints/src/loops.rs b/clippy_lints/src/loops.rs index 7472700ddbc..3adc4302730 100644 --- a/clippy_lints/src/loops.rs +++ b/clippy_lints/src/loops.rs @@ -956,7 +956,7 @@ fn detect_manual_memcpy<'a, 'tcx>( return if offset.negate { format!("({} - {})", snippet(cx, end.span, ".len()"), offset.value) } else { - "".to_owned() + String::new() }; } } @@ -1067,14 +1067,14 @@ fn check_for_loop_range<'a, 'tcx>( let starts_at_zero = is_integer_literal(start, 0); let skip = if starts_at_zero { - "".to_owned() + String::new() } else { format!(".skip({})", snippet(cx, start.span, "..")) }; let take = if let Some(end) = *end { if is_len_call(end, indexed) { - "".to_owned() + String::new() } else { match limits { ast::RangeLimits::Closed => { @@ -1085,7 +1085,7 @@ fn check_for_loop_range<'a, 'tcx>( } } } else { - "".to_owned() + String::new() }; let (ref_mut, method) = if visitor.indexed_mut.contains(&indexed) { diff --git a/clippy_lints/src/misc.rs b/clippy_lints/src/misc.rs index f52d3ccf5a4..dcc4dca3929 100644 --- a/clippy_lints/src/misc.rs +++ b/clippy_lints/src/misc.rs @@ -287,7 +287,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { let tyopt = if let Some(ref ty) = l.ty { format!(": &{mutopt}{ty}", mutopt=mutopt, ty=snippet(cx, ty.span, "_")) } else { - "".to_owned() + String::new() }; span_lint_and_then(cx, TOPLEVEL_REF_ARG, diff --git a/clippy_lints/src/ranges.rs b/clippy_lints/src/ranges.rs index 6616099eb9e..6292af92e26 100644 --- a/clippy_lints/src/ranges.rs +++ b/clippy_lints/src/ranges.rs @@ -146,7 +146,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { expr.span, "an inclusive range would be more readable", |db| { - let start = start.map_or("".to_owned(), |x| Sugg::hir(cx, x, "x").to_string()); + let start = start.map_or(String::new(), |x| Sugg::hir(cx, x, "x").to_string()); let end = Sugg::hir(cx, y, "y"); if let Some(is_wrapped) = &snippet_opt(cx, expr.span) { if is_wrapped.starts_with('(') && is_wrapped.ends_with(')') { @@ -175,7 +175,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { expr.span, "an exclusive range would be more readable", |db| { - let start = start.map_or("".to_owned(), |x| Sugg::hir(cx, x, "x").to_string()); + let start = start.map_or(String::new(), |x| Sugg::hir(cx, x, "x").to_string()); let end = Sugg::hir(cx, y, "y"); db.span_suggestion(expr.span, "use", diff --git a/clippy_lints/src/swap.rs b/clippy_lints/src/swap.rs index 1c409263499..cd3a7259aae 100644 --- a/clippy_lints/src/swap.rs +++ b/clippy_lints/src/swap.rs @@ -119,13 +119,13 @@ fn check_manual_swap(cx: &LateContext<'_, '_>, block: &Block) { snippet(cx, idx1.span, ".."), snippet(cx, idx2.span, ".."))) } else { - (false, "".to_owned(), "".to_owned()) + (false, String::new(), String::new()) } } else if let (Some(first), Some(second)) = (Sugg::hir_opt(cx, lhs1), Sugg::hir_opt(cx, rhs1)) { (true, format!(" `{}` and `{}`", first, second), format!("std::mem::swap({}, {})", first.mut_addr(), second.mut_addr())) } else { - (true, "".to_owned(), "".to_owned()) + (true, String::new(), String::new()) }; let span = w[0].span.to(second.span); @@ -169,7 +169,7 @@ fn check_suspicious_swap(cx: &LateContext<'_, '_>, block: &Block) { second.mut_addr().to_string(), ) } else { - ("".to_owned(), "".to_owned(), "".to_owned()) + (String::new(), String::new(), String::new()) }; let span = first.span.to(second.span); diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 2766ea58d2d..857238e9002 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -319,7 +319,7 @@ fn check_ty_rptr(cx: &LateContext<'_, '_>, ast_ty: &hir::Ty, is_local: bool, lt: } let ltopt = if lt.is_elided() { - "".to_owned() + String::new() } else { format!("{} ", lt.name.ident().name.as_str()) };