diff --git a/gcc/testsuite/rust/compile/name_resolution13.rs b/gcc/testsuite/rust/compile/name_resolution13.rs index 52a152bf51a5..33edbf9312e2 100644 --- a/gcc/testsuite/rust/compile/name_resolution13.rs +++ b/gcc/testsuite/rust/compile/name_resolution13.rs @@ -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; diff --git a/gcc/testsuite/rust/compile/name_resolution14.rs b/gcc/testsuite/rust/compile/name_resolution14.rs new file mode 100644 index 000000000000..eaef6a52f160 --- /dev/null +++ b/gcc/testsuite/rust/compile/name_resolution14.rs @@ -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!(); +} diff --git a/gcc/testsuite/rust/compile/name_resolution15.rs b/gcc/testsuite/rust/compile/name_resolution15.rs new file mode 100644 index 000000000000..45f38da768af --- /dev/null +++ b/gcc/testsuite/rust/compile/name_resolution15.rs @@ -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!(); +} diff --git a/gcc/testsuite/rust/compile/name_resolution16.rs b/gcc/testsuite/rust/compile/name_resolution16.rs new file mode 100644 index 000000000000..230722ef819c --- /dev/null +++ b/gcc/testsuite/rust/compile/name_resolution16.rs @@ -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!(); +} diff --git a/gcc/testsuite/rust/compile/name_resolution17.rs b/gcc/testsuite/rust/compile/name_resolution17.rs new file mode 100644 index 000000000000..485947647a95 --- /dev/null +++ b/gcc/testsuite/rust/compile/name_resolution17.rs @@ -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 diff --git a/gcc/testsuite/rust/compile/name_resolution18.rs b/gcc/testsuite/rust/compile/name_resolution18.rs new file mode 100644 index 000000000000..5940149d3bbf --- /dev/null +++ b/gcc/testsuite/rust/compile/name_resolution18.rs @@ -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" } diff --git a/gcc/testsuite/rust/compile/name_resolution19.rs b/gcc/testsuite/rust/compile/name_resolution19.rs new file mode 100644 index 000000000000..9a2c84375c7a --- /dev/null +++ b/gcc/testsuite/rust/compile/name_resolution19.rs @@ -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); +} diff --git a/gcc/testsuite/rust/compile/name_resolution20.rs b/gcc/testsuite/rust/compile/name_resolution20.rs new file mode 100644 index 000000000000..e6c2dd5ea8f9 --- /dev/null +++ b/gcc/testsuite/rust/compile/name_resolution20.rs @@ -0,0 +1,11 @@ +// { dg-options "-frust-name-resolution-2.0" } + +pub mod foo { + pub macro bar() {} +} + +use foo::bar; + +fn main() { + bar!(); +} diff --git a/gcc/testsuite/rust/compile/name_resolution21.rs b/gcc/testsuite/rust/compile/name_resolution21.rs new file mode 100644 index 000000000000..3d0af2b37b76 --- /dev/null +++ b/gcc/testsuite/rust/compile/name_resolution21.rs @@ -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!(); +}