]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
Improve diagnostic when passing arg to closure and missing borrow.
[rust.git] / compiler / rustc_trait_selection / src / traits / error_reporting / mod.rs
index 30ff07ee6c372b6df900d11c4f980d5adefe268f..da6244acb3151eed4629278ba00ede3d4132da4e 100644 (file)
@@ -1234,6 +1234,7 @@ fn report_selection_error(
                     _ => None,
                 };
 
+                let found_node = found_did.and_then(|did| self.tcx.hir().get_if_local(did));
                 let found_span = found_did.and_then(|did| self.tcx.hir().span_if_local(did));
 
                 if self.reported_closure_mismatch.borrow().contains(&(span, found_span)) {
@@ -1287,6 +1288,7 @@ fn report_selection_error(
                         found_trait_ref,
                         expected_trait_ref,
                         obligation.cause.code(),
+                        found_node,
                     )
                 } else {
                     let (closure_span, closure_arg_span, found) = found_did