Local variables and functions or global variables have different
resolution when binded to a variable. This was not covered before, even
though it was handled by the new name resolution. This commit highlight
this behavior from the new name resolution mechanism.
gcc/testsuite/ChangeLog:
* rust/compile/name_resolution11.rs: New test.
* rust/compile/name_resolution12.rs: New test.
* rust/compile/name_resolution13.rs: New test.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
--- /dev/null
+// { dg-additional-options "-frust-name-resolution-2.0 -frust-compile-until=lowering" }
+fn foo() {
+ let b = 10;
+ fn bar() {
+ let a = foo;
+ }
+}
--- /dev/null
+// { dg-additional-options "-frust-name-resolution-2.0 -frust-compile-until=lowering" }
+
+const TOTO: i32 = 10;
+
+fn foo() {
+ let b = 10;
+ fn bar() {
+ let e = TOTO;
+ }
+}
--- /dev/null
+// { dg-additional-options "-frust-name-resolution-2.0 -frust-compile-until=lowering" }
+
+fn foo() {
+ let b = 10;
+ fn bar() {
+ let c = b;
+ // { dg-error "cannot find value .b. in this scope .E0425." "" { target *-*-* } .-1 }
+ }
+}