Skip to content

Commit

Permalink
Do not emit wrong E0308 suggestion for closure mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Jan 8, 2023
1 parent d85d38b commit ebbc5da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 4 additions & 1 deletion compiler/rustc_hir_typeck/src/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 0 additions & 4 deletions src/test/ui/type/closure-with-wrong-borrows.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ebbc5da

Please sign in to comment.