diff options
| author | Philipp Krones <hello@philkrones.com> | 2024-01-26 09:42:12 +0100 |
|---|---|---|
| committer | Philipp Krones <hello@philkrones.com> | 2024-01-26 09:42:12 +0100 |
| commit | 9ce0b837ad1a18770d0f261093c68ee351b91cc7 (patch) | |
| tree | 8b999268f7115cf2842633e18d699a72fdbaa318 | |
| parent | 798865c593b8ad255ed1e19ee2502c8d91f16c65 (diff) | |
| download | rust-9ce0b837ad1a18770d0f261093c68ee351b91cc7.tar.gz rust-9ce0b837ad1a18770d0f261093c68ee351b91cc7.zip | |
Clippy: Fix empty suggestion in from_over_into
Co-authored-by: y21 <30553356+y21@users.noreply.github.com>
| -rw-r--r-- | clippy_lints/src/from_over_into.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/clippy_lints/src/from_over_into.rs b/clippy_lints/src/from_over_into.rs index 93527bcdf5c..1933a00891b 100644 --- a/clippy_lints/src/from_over_into.rs +++ b/clippy_lints/src/from_over_into.rs @@ -181,9 +181,6 @@ fn convert_to_from( let from = snippet_opt(cx, self_ty.span)?; let into = snippet_opt(cx, target_ty.span)?; - let return_type = matches!(sig.decl.output, FnRetTy::Return(_)) - .then_some(String::from("Self")) - .unwrap_or_default(); let mut suggestions = vec![ // impl Into<T> for U -> impl From<T> for U // ~~~~ ~~~~ @@ -200,10 +197,13 @@ fn convert_to_from( // fn into([mut] self) -> T -> fn into([mut] v: T) -> T // ~~~~ ~~~~ (self_ident.span, format!("val: {from}")), + ]; + + if let FnRetTy::Return(_) = sig.decl.output { // fn into(self) -> T -> fn into(self) -> Self // ~ ~~~~ - (sig.decl.output.span(), return_type), - ]; + suggestions.push((sig.decl.output.span(), String::from("Self"))); + } let mut finder = SelfFinder { cx, |
