diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2023-01-08 01:53:39 +0000 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2023-01-08 01:53:39 +0000 |
| commit | ebbc5dafd351551bdeab3e4edbdf9a03898a9017 (patch) | |
| tree | 139a5e436e25b35cdfcc2c402acb7f8854ad32c9 | |
| parent | d85d38b7b8ad9faa12231bbcc9a0214410c0719c (diff) | |
| download | rust-ebbc5dafd351551bdeab3e4edbdf9a03898a9017.tar.gz rust-ebbc5dafd351551bdeab3e4edbdf9a03898a9017.zip | |
Do not emit wrong E0308 suggestion for closure mismatch
| -rw-r--r-- | compiler/rustc_hir_typeck/src/demand.rs | 5 | ||||
| -rw-r--r-- | src/test/ui/type/closure-with-wrong-borrows.stderr | 4 |
2 files changed, 4 insertions, 5 deletions
diff --git a/compiler/rustc_hir_typeck/src/demand.rs b/compiler/rustc_hir_typeck/src/demand.rs index 0f191c21a0a..f15cf5e3ef9 100644 --- a/compiler/rustc_hir_typeck/src/demand.rs +++ b/compiler/rustc_hir_typeck/src/demand.rs @@ -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, diff --git a/src/test/ui/type/closure-with-wrong-borrows.stderr b/src/test/ui/type/closure-with-wrong-borrows.stderr index e13db6c325a..7370bc76467 100644 --- a/src/test/ui/type/closure-with-wrong-borrows.stderr +++ b/src/test/ui/type/closure-with-wrong-borrows.stderr @@ -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 |
