Skip to content

Commit

Permalink
Remove redundant to_strings
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Oct 15, 2021
1 parent 47014d8 commit 75e9f8c
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions clippy_dev/src/update_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,8 @@ mod tests {
Lint::new("should_assert_eq2", "group2", "abc", None, "module_name"),
];
let expected = vec![
format!("[`should_assert_eq`]: {}#should_assert_eq", DOCS_LINK.to_string()),
format!("[`should_assert_eq2`]: {}#should_assert_eq2", DOCS_LINK.to_string()),
format!("[`should_assert_eq`]: {}#should_assert_eq", DOCS_LINK),
format!("[`should_assert_eq2`]: {}#should_assert_eq2", DOCS_LINK),
];
assert_eq!(expected, gen_changelog_lint_list(lints.iter()));
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/if_then_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ impl LateLintPass<'_> for IfThenPanic {
if let Expr{kind: ExprKind::Unary(UnOp::Not, not_expr), ..} = e {
sugg::Sugg::hir_with_applicability(cx, not_expr, "..", &mut applicability).maybe_par().to_string()
} else {
format!("!{}", sugg::Sugg::hir_with_applicability(cx, e, "..", &mut applicability).maybe_par().to_string())
format!("!{}", sugg::Sugg::hir_with_applicability(cx, e, "..", &mut applicability).maybe_par())
}
} else {
format!("!{}", sugg::Sugg::hir_with_applicability(cx, cond, "..", &mut applicability).maybe_par().to_string())
format!("!{}", sugg::Sugg::hir_with_applicability(cx, cond, "..", &mut applicability).maybe_par())
};

span_lint_and_sugg(
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/inherent_to_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ fn show_lint(cx: &LateContext<'_>, item: &ImplItem<'_>) {
item.span,
&format!(
"type `{}` implements inherent method `to_string(&self) -> String` which shadows the implementation of `Display`",
self_type.to_string()
self_type
),
None,
&format!("remove the inherent method from type `{}`", self_type.to_string()),
&format!("remove the inherent method from type `{}`", self_type),
);
} else {
span_lint_and_help(
Expand All @@ -150,10 +150,10 @@ fn show_lint(cx: &LateContext<'_>, item: &ImplItem<'_>) {
item.span,
&format!(
"implementation of inherent method `to_string(&self) -> String` for type `{}`",
self_type.to_string()
self_type
),
None,
&format!("implement trait `Display` for type `{}` instead", self_type.to_string()),
&format!("implement trait `Display` for type `{}` instead", self_type),
);
}
}
2 changes: 1 addition & 1 deletion clippy_lints/src/suspicious_operation_groupings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ fn suggestion_with_swapped_ident(
Some(format!(
"{}{}{}",
snippet_with_applicability(cx, expr.span.with_hi(current_ident.span.lo()), "..", applicability),
new_ident.to_string(),
new_ident,
snippet_with_applicability(cx, expr.span.with_lo(current_ident.span.hi()), "..", applicability),
))
})
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/transmute/transmute_int_to_char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub(super) fn check<'tcx>(
diag.span_suggestion(
e.span,
"consider using",
format!("std::char::from_u32({}).unwrap()", arg.to_string()),
format!("std::char::from_u32({}).unwrap()", arg),
Applicability::Unspecified,
);
},
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/transmute/transmute_int_to_float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub(super) fn check<'tcx>(
diag.span_suggestion(
e.span,
"consider using",
format!("{}::from_bits({})", to_ty, arg.to_string()),
format!("{}::from_bits({})", to_ty, arg),
Applicability::Unspecified,
);
},
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/transmute/transmute_num_to_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub(super) fn check<'tcx>(
diag.span_suggestion(
e.span,
"consider using `to_ne_bytes()`",
format!("{}.to_ne_bytes()", arg.to_string()),
format!("{}.to_ne_bytes()", arg),
Applicability::Unspecified,
);
},
Expand Down

0 comments on commit 75e9f8c

Please sign in to comment.