about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authoryukang <moorekang@gmail.com>2022-11-25 15:25:04 +0800
committeryukang <moorekang@gmail.com>2022-11-25 15:25:04 +0800
commit68ea51602a492a02ed5d23580ac06f9c4cc830f5 (patch)
treeee7777bb1938a3a42ed63d3a281f27e37d9df488 /compiler
parent7cd4b673d050508544f0b200ab6a840bebc38f0f (diff)
downloadrust-68ea51602a492a02ed5d23580ac06f9c4cc830f5.tar.gz
rust-68ea51602a492a02ed5d23580ac06f9c4cc830f5.zip
fix the crossing function issue
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_resolve/src/late.rs2
-rw-r--r--compiler/rustc_resolve/src/late/diagnostics.rs2
2 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs
index 8faef4c6374..18dabfe8993 100644
--- a/compiler/rustc_resolve/src/late.rs
+++ b/compiler/rustc_resolve/src/late.rs
@@ -876,6 +876,8 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
                             // Ignore errors in function bodies if this is rustdoc
                             // Be sure not to set this until the function signature has been resolved.
                             let previous_state = replace(&mut this.in_func_body, true);
+                            // We only care block in the same function
+                            this.last_block_rib = None;
                             // Resolve the function body, potentially inside the body of an async closure
                             this.with_lifetime_rib(
                                 LifetimeRibKind::Elided(LifetimeRes::Infer),
diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs
index b3dd5bb28a7..d82aecaadc3 100644
--- a/compiler/rustc_resolve/src/late/diagnostics.rs
+++ b/compiler/rustc_resolve/src/late/diagnostics.rs
@@ -616,7 +616,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
         }
 
         // Try to find in last block rib
-        if let Some(rib) = &self.last_block_rib {
+        if let Some(rib) = &self.last_block_rib && let RibKind::NormalRibKind = rib.kind {
             for (ident, &res) in &rib.bindings {
                 if let Res::Local(_) = res && path.len() == 1 &&
                     ident.span.eq_ctxt(path[0].ident.span) &&