Skip to content

Commit

Permalink
nr2.0: Add new test cases.
Browse files Browse the repository at this point in the history
gcc/testsuite/ChangeLog:

	* rust/compile/name_resolution13.rs: Add new module and remove compile
	step.
	* rust/compile/name_resolution14.rs: New test.
	* rust/compile/name_resolution15.rs: New test.
	* rust/compile/name_resolution16.rs: New test.
	* rust/compile/name_resolution17.rs: New test.
	* rust/compile/name_resolution18.rs: New test.
	* rust/compile/name_resolution19.rs: New test.
	* rust/compile/name_resolution20.rs: New test.
	* rust/compile/name_resolution21.rs: New test.
  • Loading branch information
CohenArthur authored and P-E-P committed Mar 26, 2024
1 parent e1064ca commit db7d499
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gcc/testsuite/rust/compile/name_resolution13.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// { dg-additional-options "-frust-name-resolution-2.0 -frust-compile-until=lowering" }
// { dg-options "-frust-name-resolution-2.0" }

pub mod foo {
pub macro bar() {}
}

fn foo() {
let b = 10;
Expand Down
15 changes: 15 additions & 0 deletions gcc/testsuite/rust/compile/name_resolution14.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// { dg-options "-frust-name-resolution-2.0" }

pub mod foo {
pub macro bar() {}
}

use foo::biz; // { dg-error "unresolved import .foo::biz. .E0433." }

use foo::{bar, baz, biz};
// { dg-error "unresolved import .foo::baz. .E0433." "" { target *-*-* } .-1 }
// { dg-error "unresolved import .foo::biz. .E0433." "" { target *-*-* } .-2 }

fn main() {
bar!();
}
20 changes: 20 additions & 0 deletions gcc/testsuite/rust/compile/name_resolution15.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// { dg-additional-options "-frust-name-resolution-2.0" }
#![feature(decl_macro)]

pub mod foo {
pub struct Foo {
pub a: i32,
}
pub fn Foo() {}
pub macro Foo() {{}}
}

pub use foo::Foo;

use self::Foo as Fo;

fn main() {
let _a = Fo();
let _b = Fo { a: 15 };
let _c = Fo!();
}
18 changes: 18 additions & 0 deletions gcc/testsuite/rust/compile/name_resolution16.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// { dg-additional-options "-frust-name-resolution-2.0" }
#![feature(decl_macro)]

pub mod foo {
pub struct Foo {
pub a: i32,
}
pub fn Foo() {}
pub macro Foo() {{}}
}

pub use foo::Foo;

fn main() {
let _a = Foo();
let _b = Foo { a: 15 };
let _c = Foo!();
}
10 changes: 10 additions & 0 deletions gcc/testsuite/rust/compile/name_resolution17.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// { dg-options "-frust-name-resolution-2.0" }

struct Foo;
fn Foo() {} // { dg-error ".Foo. defined multiple times" }

struct Marker;
struct Bar {
a: Marker,
}
fn Bar() {} // ok, since `Bar` is not a value here
15 changes: 15 additions & 0 deletions gcc/testsuite/rust/compile/name_resolution18.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// { dg-options "-frust-name-resolution-2.0" }

struct Marker;

struct Foo {
a: Marker,
}

pub mod foo {
struct Foo {
b: Marker,
}
}

use foo::Foo; // { dg-error ".Foo. defined multiple times" }
20 changes: 20 additions & 0 deletions gcc/testsuite/rust/compile/name_resolution19.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
struct Marker;

fn foo(a: Marker, b: Marker) -> Marker {
let a = b;

a
}

fn bar() {
let a = 15;

fn inner() {
// inner functions cannot capture dynamic environment
let b = a; // { dg-error "cannot find value .a. in this scope" }
}
}

fn main() {
let m = foo(Marker, Marker);
}
11 changes: 11 additions & 0 deletions gcc/testsuite/rust/compile/name_resolution20.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// { dg-options "-frust-name-resolution-2.0" }

pub mod foo {
pub macro bar() {}
}

use foo::bar;

fn main() {
bar!();
}
12 changes: 12 additions & 0 deletions gcc/testsuite/rust/compile/name_resolution21.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// { dg-additional-options "-frust-name-resolution-2.0" }

pub mod foo {
pub macro bar() {}
}

use foo::bar;
use foo::bar; // { dg-error ".bar. defined multiple times" }

fn main() {
bar!();
}

0 comments on commit db7d499

Please sign in to comment.