]> git.lizzy.rs Git - rust.git/commitdiff
Do not emit wrong E0308 suggestion for closure mismatch
authorEsteban Küber <esteban@kuber.com.ar>
Sun, 8 Jan 2023 01:53:39 +0000 (01:53 +0000)
committerEsteban Küber <esteban@kuber.com.ar>
Sun, 8 Jan 2023 01:53:39 +0000 (01:53 +0000)
compiler/rustc_hir_typeck/src/demand.rs
src/test/ui/type/closure-with-wrong-borrows.stderr

index 0f191c21a0a63e483618da407f8696eff96c3944..f15cf5e3ef94817938698d13293bb383dbba2914 100644 (file)
@@ -1379,7 +1379,7 @@ pub fn check_ref(
                         }
                     }
                     // 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 @@ pub fn check_ref(
                         } else {
                             (prefix_span, format!("{}{}", prefix, "*".repeat(steps)))
                         };
+                        if suggestion.trim().is_empty() {
+                            return None;
+                        }
 
                         return Some((
                             span,
index e13db6c325add41b02f4dde6a40ffd97a1fac39d..7370bc76467656bcdd0d70ed44c1ce967d04c837 100644 (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