Skip to content

Commit

Permalink
Add multiple regression test in name resolution
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
P-E-P committed Dec 1, 2023
1 parent b831e5b commit dc962fa
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gcc/testsuite/rust/compile/name_resolution11.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// { dg-additional-options "-frust-name-resolution-2.0 -frust-compile-until=lowering" }
fn foo() {
let b = 10;
fn bar() {
let a = foo;
}
}
10 changes: 10 additions & 0 deletions gcc/testsuite/rust/compile/name_resolution12.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// { 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;
}
}
9 changes: 9 additions & 0 deletions gcc/testsuite/rust/compile/name_resolution13.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// { 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 }
}
}

0 comments on commit dc962fa

Please sign in to comment.