Skip to content

Commit ebbc5da

Browse files
committed
Do not emit wrong E0308 suggestion for closure mismatch
1 parent d85d38b commit ebbc5da

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

compiler/rustc_hir_typeck/src/demand.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1379,7 +1379,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13791379
}
13801380
}
13811381
// If we've reached our target type with just removing `&`, then just print now.
1382-
if steps == 0 {
1382+
if steps == 0 && !remove.trim().is_empty() {
13831383
return Some((
13841384
prefix_span,
13851385
format!("consider removing the `{}`", remove.trim()),
@@ -1438,6 +1438,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
14381438
} else {
14391439
(prefix_span, format!("{}{}", prefix, "*".repeat(steps)))
14401440
};
1441+
if suggestion.trim().is_empty() {
1442+
return None;
1443+
}
14411444

14421445
return Some((
14431446
span,

src/test/ui/type/closure-with-wrong-borrows.stderr

-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ note: function defined here
1313
|
1414
LL | fn f(inner: fn(&str, &S)) {
1515
| ^ -------------------
16-
help: consider removing the ``
17-
|
18-
LL | f(inner);
19-
|
2016

2117
error: aborting due to previous error
2218

0 commit comments

Comments
 (0)