Skip to content

Commit 9ce0b83

Browse files
flip1995y21
andcommitted
Clippy: Fix empty suggestion in from_over_into
Co-authored-by: y21 <30553356+y21@users.noreply.github.com>
1 parent 798865c commit 9ce0b83

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

clippy_lints/src/from_over_into.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,6 @@ fn convert_to_from(
181181
let from = snippet_opt(cx, self_ty.span)?;
182182
let into = snippet_opt(cx, target_ty.span)?;
183183

184-
let return_type = matches!(sig.decl.output, FnRetTy::Return(_))
185-
.then_some(String::from("Self"))
186-
.unwrap_or_default();
187184
let mut suggestions = vec![
188185
// impl Into<T> for U -> impl From<T> for U
189186
// ~~~~ ~~~~
@@ -200,10 +197,13 @@ fn convert_to_from(
200197
// fn into([mut] self) -> T -> fn into([mut] v: T) -> T
201198
// ~~~~ ~~~~
202199
(self_ident.span, format!("val: {from}")),
200+
];
201+
202+
if let FnRetTy::Return(_) = sig.decl.output {
203203
// fn into(self) -> T -> fn into(self) -> Self
204204
// ~ ~~~~
205-
(sig.decl.output.span(), return_type),
206-
];
205+
suggestions.push((sig.decl.output.span(), String::from("Self")));
206+
}
207207

208208
let mut finder = SelfFinder {
209209
cx,

0 commit comments

Comments
 (0)