Skip to content

Commit 9c897a2

Browse files
committed
Simplify implementation
1 parent 4a324c9 commit 9c897a2

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

clippy_lints/src/from_over_into.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -194,24 +194,14 @@ fn convert_to_from(
194194
// impl Into<T> for U -> impl Into<T> for T
195195
// ~ ~
196196
(self_ty.span, into.to_owned()),
197-
// fn into(self) -> T -> fn from(self) -> T
198-
// ~~~~ ~~~~
197+
// fn into(self: U) -> T -> fn from(self) -> T
198+
// ~~~~ ~~~~
199199
(impl_item.ident.span, String::from("from")),
200+
// fn into([mut] self: U) -> T -> fn into([mut] val: T) -> T
201+
// ~~~~~~~ ~~~~~~
202+
(self_ident.span.to(self_param.ty_span), format!("val: {from}")),
200203
];
201204

202-
if self_ident.span.overlaps(self_param.ty_span) {
203-
// fn into([mut] self) -> T -> fn into([mut] val: T) -> T
204-
// ~~~~ ~~~~~~
205-
suggestions.push((self_ident.span, format!("val: {from}")));
206-
} else {
207-
// fn into([mut] self: U) -> T -> fn into([mut] val: U) -> T
208-
// ~~~~ ~~~
209-
suggestions.push((self_ident.span, String::from("val")));
210-
// fn into([mut] val: U) -> T -> fn into([mut] val: T) -> T
211-
// ~ ~
212-
suggestions.push((self_param.ty_span, from.to_owned()));
213-
}
214-
215205
if let FnRetTy::Return(_) = sig.decl.output {
216206
// fn into(self) -> T -> fn into(self) -> Self
217207
// ~ ~~~~

0 commit comments

Comments
 (0)