diff options
author | Marc Poulhiès <dkm@kataplop.net> | 2021-08-12 11:50:54 +0200 |
---|---|---|
committer | Marc <dkm@kataplop.net> | 2021-08-18 22:59:54 +0200 |
commit | b34ea0af5e92fd34a4eb21edb39a8715b47e84f8 (patch) | |
tree | da149f0cb0bfd3019cc153eea6bd9eb074f6715a | |
parent | ed9a473c741f85685e8d9160155c16a92c010ca7 (diff) | |
download | gcc-b34ea0af5e92fd34a4eb21edb39a8715b47e84f8.zip gcc-b34ea0af5e92fd34a4eb21edb39a8715b47e84f8.tar.gz gcc-b34ea0af5e92fd34a4eb21edb39a8715b47e84f8.tar.bz2 |
tests: add tests for Module
Add tests for Module support.
ref #432
-rw-r--r-- | gcc/testsuite/rust/compile/torture/mod1.rs | 12 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/torture/mod2.rs | 15 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/torture/mod3.rs | 25 | ||||
-rw-r--r-- | gcc/testsuite/rust/execute/torture/mod1.rs | 25 |
4 files changed, 77 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/torture/mod1.rs b/gcc/testsuite/rust/compile/torture/mod1.rs new file mode 100644 index 0000000..ca272f7 --- /dev/null +++ b/gcc/testsuite/rust/compile/torture/mod1.rs @@ -0,0 +1,12 @@ +// This is testing name resolution + +mod _foo { + struct _A; +} + +mod _bar { + mod _barbis { + struct _B; + } +} + diff --git a/gcc/testsuite/rust/compile/torture/mod2.rs b/gcc/testsuite/rust/compile/torture/mod2.rs new file mode 100644 index 0000000..6a2d1ed --- /dev/null +++ b/gcc/testsuite/rust/compile/torture/mod2.rs @@ -0,0 +1,15 @@ +mod foomod { + pub struct Foo { // { dg-warning "unused name" } + } +} + +impl foomod::Foo { + pub fn new() -> Self { + foomod::Foo { + } + } +} + +fn main() { + let _a = foomod::Foo::new(); +} diff --git a/gcc/testsuite/rust/compile/torture/mod3.rs b/gcc/testsuite/rust/compile/torture/mod3.rs new file mode 100644 index 0000000..e241839 --- /dev/null +++ b/gcc/testsuite/rust/compile/torture/mod3.rs @@ -0,0 +1,25 @@ +mod A { + pub mod B { // { dg-warning "unused name" } + pub mod C { // { dg-warning "unused name" } + pub struct Foo { + pub f: i32, + } + impl Foo { + pub fn new() -> Self { // { dg-warning "unused name" } + Foo { + f: 23i32, + } + } + } + } + } +} + +fn main() ->i32 { + let a = A::B::C::Foo::new(); + let b = A::B::C::Foo { + f: -23i32, + }; + + a.f - b.f +} diff --git a/gcc/testsuite/rust/execute/torture/mod1.rs b/gcc/testsuite/rust/execute/torture/mod1.rs new file mode 100644 index 0000000..37e7ce3 --- /dev/null +++ b/gcc/testsuite/rust/execute/torture/mod1.rs @@ -0,0 +1,25 @@ +mod A { + pub mod B { // { dg-warning "unused name" } + pub mod C { // { dg-warning "unused name" } + pub struct Foo { + pub f: i32, + } + impl Foo { + pub fn new() -> Self { // { dg-warning "unused name" } + Foo { + f: 23i32, + } + } + } + } + } +} + +fn main() ->i32 { + let a = A::B::C::Foo::new(); + let b = A::B::C::Foo { + f: -23i32, + }; + + a.f + b.f +} |