Skip to content

Commit

Permalink
fix empty suggestion ICE in from_over_into
Browse files Browse the repository at this point in the history
  • Loading branch information
y21 committed Oct 19, 2024
1 parent 38cf3f3 commit 4de65a1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions clippy_lints/src/from_over_into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
// ~~~~ ~~~~
Expand All @@ -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,
Expand Down

0 comments on commit 4de65a1

Please sign in to comment.