Do not emit wrong E0308 suggestion for closure mismatch

This commit is contained in:
Esteban Küber 2023-01-08 01:53:39 +00:00
parent d85d38b7b8
commit ebbc5dafd3
2 changed files with 4 additions and 5 deletions

View file

@ -1379,7 +1379,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
}
// If we've reached our target type with just removing `&`, then just print now.
if steps == 0 {
if steps == 0 && !remove.trim().is_empty() {
return Some((
prefix_span,
format!("consider removing the `{}`", remove.trim()),
@ -1438,6 +1438,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else {
(prefix_span, format!("{}{}", prefix, "*".repeat(steps)))
};
if suggestion.trim().is_empty() {
return None;
}
return Some((
span,

View file

@ -13,10 +13,6 @@ note: function defined here
|
LL | fn f(inner: fn(&str, &S)) {
| ^ -------------------
help: consider removing the ``
|
LL | f(inner);
|
error: aborting due to previous error