Skip to content

Commit 3beb6b1

Browse files
committed
Address review comments
1 parent cb609a9 commit 3beb6b1

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

clippy_lints/src/methods/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1893,7 +1893,7 @@ declare_clippy_lint! {
18931893
/// and other `to_owned`-like functions.
18941894
///
18951895
/// ### Why is this bad?
1896-
/// The unnecessary calls result in unnecessary allocations.
1896+
/// The unnecessary calls result in useless allocations.
18971897
///
18981898
/// ### Example
18991899
/// ```rust

clippy_lints/src/methods/unnecessary_to_owned.rs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,17 @@ fn check_addr_of_expr(
107107
then {
108108
let (target_ty, n_target_refs) = peel_mid_ty_refs(target_ty);
109109
let (receiver_ty, n_receiver_refs) = peel_mid_ty_refs(receiver_ty);
110-
if_chain! {
111-
if receiver_ty == target_ty;
112-
if n_target_refs >= n_receiver_refs;
113-
then {
114-
span_lint_and_sugg(
115-
cx,
116-
UNNECESSARY_TO_OWNED,
117-
parent.span,
118-
&format!("unnecessary use of `{}`", method_name),
119-
"use",
120-
format!("{:&>width$}{}", "", receiver_snippet, width = n_target_refs - n_receiver_refs),
121-
Applicability::MachineApplicable,
122-
);
123-
return true;
124-
}
110+
if receiver_ty == target_ty && n_target_refs >= n_receiver_refs {
111+
span_lint_and_sugg(
112+
cx,
113+
UNNECESSARY_TO_OWNED,
114+
parent.span,
115+
&format!("unnecessary use of `{}`", method_name),
116+
"use",
117+
format!("{:&>width$}{}", "", receiver_snippet, width = n_target_refs - n_receiver_refs),
118+
Applicability::MachineApplicable,
119+
);
120+
return true;
125121
}
126122
if_chain! {
127123
if let Some(deref_trait_id) = cx.tcx.get_diagnostic_item(sym::Deref);

0 commit comments

Comments
 (0)