about summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2021-12-29 09:19:57 +0100
committerCamille GILLOT <gillot.camille@gmail.com>2022-02-12 01:26:17 +0100
commit10cf626d0ea7be3eb971691772b5eb30013d4f02 (patch)
tree467a503f0fff9afabdc84dcf5f6067452cff67d3 /compiler/rustc_borrowck/src
parentc6a3f5d6062f55779e52de24a6465cf87ffbdd19 (diff)
downloadrust-10cf626d0ea7be3eb971691772b5eb30013d4f02.tar.gz
rust-10cf626d0ea7be3eb971691772b5eb30013d4f02.zip
Bless nll tests.
Diffstat (limited to 'compiler/rustc_borrowck/src')
-rw-r--r--compiler/rustc_borrowck/src/region_infer/mod.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler/rustc_borrowck/src/region_infer/mod.rs b/compiler/rustc_borrowck/src/region_infer/mod.rs
index d9120ff2457..0f0d3eaa293 100644
--- a/compiler/rustc_borrowck/src/region_infer/mod.rs
+++ b/compiler/rustc_borrowck/src/region_infer/mod.rs
@@ -2156,6 +2156,24 @@ impl<'tcx> RegionInferenceContext<'tcx> {
                 }
             }
 
+            // When in async fn, prefer errors that come from inside the closure.
+            if !categorized_path[i].from_closure {
+                let span = categorized_path.iter().find_map(|p| {
+                    if p.from_closure
+                        && p.category == categorized_path[i].category
+                        && categorized_path[i].cause.span.contains(p.cause.span)
+                    {
+                        Some(p.cause.span)
+                    } else {
+                        None
+                    }
+                });
+
+                if let Some(span) = span {
+                    categorized_path[i].cause.span = span;
+                }
+            }
+
             return categorized_path[i].clone();
         }