about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs17
-rw-r--r--src/test/ui/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr4
-rw-r--r--src/test/ui/issues/issue-23046.rs4
-rw-r--r--src/test/ui/issues/issue-23046.stderr13
4 files changed, 10 insertions, 28 deletions
diff --git a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
index 2f3089f1a92..21023a06bb2 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs
@@ -91,17 +91,6 @@ impl<'a, 'tcx> Visitor<'tcx> for FindHirNodeVisitor<'a, 'tcx> {
         if let (None, Some(ty)) =
             (self.found_local_pattern, self.node_ty_contains_target(local.hir_id))
         {
-            // FIXME: There's a trade-off here - we can either check that our target span
-            // is contained in `local.span` or not. If we choose to check containment
-            // we can avoid some spurious suggestions (see #72690), but we lose
-            // the ability to report on things like:
-            //
-            // ```
-            // let x = vec![];
-            // ```
-            //
-            // because the target span will be in the macro expansion of `vec![]`.
-            // At present we choose not to check containment.
             self.found_local_pattern = Some(&*local.pat);
             self.found_node_ty = Some(ty);
         }
@@ -113,10 +102,8 @@ impl<'a, 'tcx> Visitor<'tcx> for FindHirNodeVisitor<'a, 'tcx> {
             if let (None, Some(ty)) =
                 (self.found_arg_pattern, self.node_ty_contains_target(param.hir_id))
             {
-                if self.target_span.contains(param.pat.span) {
-                    self.found_arg_pattern = Some(&*param.pat);
-                    self.found_node_ty = Some(ty);
-                }
+                self.found_arg_pattern = Some(&*param.pat);
+                self.found_node_ty = Some(ty);
             }
         }
         intravisit::walk_body(self, body);
diff --git a/src/test/ui/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr b/src/test/ui/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr
index 0c6d11cd321..2005bd4dd5c 100644
--- a/src/test/ui/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr
+++ b/src/test/ui/closure-expected-type/expect-two-infer-vars-supply-ty-with-bound-region.stderr
@@ -1,8 +1,8 @@
 error[E0282]: type annotations needed
-  --> $DIR/expect-two-infer-vars-supply-ty-with-bound-region.rs:8:5
+  --> $DIR/expect-two-infer-vars-supply-ty-with-bound-region.rs:8:27
    |
 LL |     with_closure(|x: u32, y| {});
-   |     ^^^^^^^^^^^^ cannot infer type for type parameter `B` declared on the function `with_closure`
+   |                           ^ consider giving this closure parameter a type
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-23046.rs b/src/test/ui/issues/issue-23046.rs
index 75be4a11efd..a68369616d8 100644
--- a/src/test/ui/issues/issue-23046.rs
+++ b/src/test/ui/issues/issue-23046.rs
@@ -14,7 +14,7 @@ pub fn let_<'var, VAR, F: for<'v> Fn(Expr<'v, VAR>) -> Expr<'v, VAR>>
 }
 
 fn main() {
-    let ex = |x| {
-        let_(add(x,x), |y| { //~ ERROR type annotations needed
+    let ex = |x| { //~ ERROR type annotations needed
+        let_(add(x,x), |y| {
             let_(add(x, x), |x|x)})};
 }
diff --git a/src/test/ui/issues/issue-23046.stderr b/src/test/ui/issues/issue-23046.stderr
index 77555fce7c4..12b2eb48e7e 100644
--- a/src/test/ui/issues/issue-23046.stderr
+++ b/src/test/ui/issues/issue-23046.stderr
@@ -1,13 +1,8 @@
-error[E0282]: type annotations needed for the closure `fn(Expr<'_, _>) -> Expr<'_, _>`
-  --> $DIR/issue-23046.rs:18:9
+error[E0282]: type annotations needed for `Expr<'_, VAR>`
+  --> $DIR/issue-23046.rs:17:15
    |
-LL |         let_(add(x,x), |y| {
-   |         ^^^^ cannot infer type for type parameter `VAR` declared on the function `let_`
-   |
-help: give this closure an explicit return type without `_` placeholders
-   |
-LL |             let_(add(x, x), |x|-> Expr<'_, _> { x })})};
-   |                                ^^^^^^^^^^^^^^^^   ^
+LL |     let ex = |x| {
+   |               ^ consider giving this closure parameter the explicit type `Expr<'_, VAR>`, where the type parameter `VAR` is specified
 
 error: aborting due to previous error