From 7cd4b673d050508544f0b200ab6a840bebc38f0f Mon Sep 17 00:00:00 2001 From: yukang Date: Fri, 25 Nov 2022 13:19:21 +0800 Subject: fix #104700, account for item-local in inner scope for E0425 --- src/test/ui/resolve/issue-104700-inner_scope.rs | 11 +++++++++++ src/test/ui/resolve/issue-104700-inner_scope.stderr | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/test/ui/resolve/issue-104700-inner_scope.rs create mode 100644 src/test/ui/resolve/issue-104700-inner_scope.stderr (limited to 'src/test/ui') 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`. -- cgit 1.4.1-3-g733a5