about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authoryukang <moorekang@gmail.com>2022-11-25 13:19:21 +0800
committeryukang <moorekang@gmail.com>2022-11-25 13:19:21 +0800
commit7cd4b673d050508544f0b200ab6a840bebc38f0f (patch)
tree6f3a1b897d2f4999d214f004276a74d28010f53d /src/test/ui
parent1dda298ad39a64e019a3511139c5b13ac0a18e54 (diff)
downloadrust-7cd4b673d050508544f0b200ab6a840bebc38f0f.tar.gz
rust-7cd4b673d050508544f0b200ab6a840bebc38f0f.zip
fix #104700, account for item-local in inner scope for E0425
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/resolve/issue-104700-inner_scope.rs11
-rw-r--r--src/test/ui/resolve/issue-104700-inner_scope.stderr21
2 files changed, 32 insertions, 0 deletions
diff --git a/src/test/ui/resolve/issue-104700-inner_scope.rs b/src/test/ui/resolve/issue-104700-inner_scope.rs
new file mode 100644
index 00000000000..e8f28c113e3
--- /dev/null
+++ b/src/test/ui/resolve/issue-104700-inner_scope.rs
@@ -0,0 +1,11 @@
+fn main() {
+    let foo = 1;
+    {
+        let bar = 2;
+        let test_func = |x| x > 3;
+    }
+    if bar == 2 { //~ ERROR cannot find value
+        println!("yes");
+    }
+    test_func(1); //~ ERROR cannot find function
+}
diff --git a/src/test/ui/resolve/issue-104700-inner_scope.stderr b/src/test/ui/resolve/issue-104700-inner_scope.stderr
new file mode 100644
index 00000000000..051b234fc72
--- /dev/null
+++ b/src/test/ui/resolve/issue-104700-inner_scope.stderr
@@ -0,0 +1,21 @@
+error[E0425]: cannot find value `bar` in this scope
+  --> $DIR/issue-104700-inner_scope.rs:7:8
+   |
+LL |     if bar == 2 {
+   |        ^^^
+   |
+help: the binding `bar` is available in a different scope in the same function
+  --> $DIR/issue-104700-inner_scope.rs:4:13
+   |
+LL |         let bar = 2;
+   |             ^^^
+
+error[E0425]: cannot find function `test_func` in this scope
+  --> $DIR/issue-104700-inner_scope.rs:10:5
+   |
+LL |     test_func(1);
+   |     ^^^^^^^^^ not found in this scope
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0425`.