diff options
| author | y21 <30553356+y21@users.noreply.github.com> | 2024-10-19 19:24:09 +0200 |
|---|---|---|
| committer | y21 <30553356+y21@users.noreply.github.com> | 2024-10-19 19:24:09 +0200 |
| commit | 4de65a113f3f15cfc674c7b77cfa3afe1ddbe090 (patch) | |
| tree | a68fa802d3152f9b159e673bebbdd4df6021e0be | |
| parent | 38cf3f3234ff0ad60c8ff7e2c47b2ff6a731c49d (diff) | |
| download | rust-4de65a113f3f15cfc674c7b77cfa3afe1ddbe090.tar.gz rust-4de65a113f3f15cfc674c7b77cfa3afe1ddbe090.zip | |
fix empty suggestion ICE in from_over_into
| -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 0aac81fa388..d5a2e06863d 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 = self_ty.span.get_source_text(cx)?; let into = target_ty.span.get_source_text(cx)?; - 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, |
