diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-09-08 01:42:12 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-11-04 14:56:07 +0300 |
| commit | e7cedc9972ae753402fece658b5b9f580f4fc5f3 (patch) | |
| tree | 1a9b86a156544b097f67ee1ffa02178c17ad6195 /src/test/ui/proc-macro | |
| parent | cba93685377bc74a2fde1eb8e7a086039b038e94 (diff) | |
| download | rust-e7cedc9972ae753402fece658b5b9f580f4fc5f3.tar.gz rust-e7cedc9972ae753402fece658b5b9f580f4fc5f3.zip | |
expand: Feature gate out-of-line modules in proc macro input
Diffstat (limited to 'src/test/ui/proc-macro')
| -rw-r--r-- | src/test/ui/proc-macro/attributes-on-modules-fail.rs | 29 | ||||
| -rw-r--r-- | src/test/ui/proc-macro/attributes-on-modules-fail.stderr | 76 | ||||
| -rw-r--r-- | src/test/ui/proc-macro/attributes-on-modules.rs | 13 | ||||
| -rw-r--r-- | src/test/ui/proc-macro/attributes-on-modules.stderr | 12 | ||||
| -rw-r--r-- | src/test/ui/proc-macro/module.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/proc-macro/outer/inner.rs | 1 |
6 files changed, 132 insertions, 0 deletions
diff --git a/src/test/ui/proc-macro/attributes-on-modules-fail.rs b/src/test/ui/proc-macro/attributes-on-modules-fail.rs new file mode 100644 index 00000000000..c8bc0b34374 --- /dev/null +++ b/src/test/ui/proc-macro/attributes-on-modules-fail.rs @@ -0,0 +1,29 @@ +// aux-build:test-macros.rs + +#[macro_use] +extern crate test_macros; + +#[identity_attr] //~ ERROR custom attributes cannot be applied to modules +mod m { + pub struct X; + + type A = Y; //~ ERROR cannot find type `Y` in this scope +} + +struct Y; +type A = X; //~ ERROR cannot find type `X` in this scope + +#[derive(Copy)] //~ ERROR `derive` may only be applied to structs, enums and unions +mod n {} + +#[empty_attr] +mod module; //~ ERROR non-inline modules in proc macro input are unstable + +#[empty_attr] //~ ERROR custom attributes cannot be applied to modules +mod outer { + mod inner; //~ ERROR non-inline modules in proc macro input are unstable + + mod inner_inline {} // OK +} + +fn main() {} diff --git a/src/test/ui/proc-macro/attributes-on-modules-fail.stderr b/src/test/ui/proc-macro/attributes-on-modules-fail.stderr new file mode 100644 index 00000000000..34a5a5aaa54 --- /dev/null +++ b/src/test/ui/proc-macro/attributes-on-modules-fail.stderr @@ -0,0 +1,76 @@ +error[E0658]: custom attributes cannot be applied to modules + --> $DIR/attributes-on-modules-fail.rs:6:1 + | +LL | #[identity_attr] + | ^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/54727 + = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable + +error: `derive` may only be applied to structs, enums and unions + --> $DIR/attributes-on-modules-fail.rs:16:1 + | +LL | #[derive(Copy)] + | ^^^^^^^^^^^^^^^ + +error[E0658]: non-inline modules in proc macro input are unstable + --> $DIR/attributes-on-modules-fail.rs:20:1 + | +LL | mod module; + | ^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/54727 + = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable + +error[E0658]: non-inline modules in proc macro input are unstable + --> $DIR/attributes-on-modules-fail.rs:24:5 + | +LL | mod inner; + | ^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/54727 + = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable + +error[E0658]: custom attributes cannot be applied to modules + --> $DIR/attributes-on-modules-fail.rs:22:1 + | +LL | #[empty_attr] + | ^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/54727 + = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable + +error[E0412]: cannot find type `Y` in this scope + --> $DIR/attributes-on-modules-fail.rs:10:14 + | +LL | type A = Y; + | ---------^- similarly named type alias `A` defined here + | +help: a type alias with a similar name exists + | +LL | type A = A; + | ^ +help: possible candidate is found in another module, you can import it into scope + | +LL | use Y; + | + +error[E0412]: cannot find type `X` in this scope + --> $DIR/attributes-on-modules-fail.rs:14:10 + | +LL | type A = X; + | ---------^- similarly named type alias `A` defined here + | +help: a type alias with a similar name exists + | +LL | type A = A; + | ^ +help: possible candidate is found in another module, you can import it into scope + | +LL | use m::X; + | + +error: aborting due to 7 previous errors + +Some errors have detailed explanations: E0412, E0658. +For more information about an error, try `rustc --explain E0412`. diff --git a/src/test/ui/proc-macro/attributes-on-modules.rs b/src/test/ui/proc-macro/attributes-on-modules.rs new file mode 100644 index 00000000000..12c3ac6d947 --- /dev/null +++ b/src/test/ui/proc-macro/attributes-on-modules.rs @@ -0,0 +1,13 @@ +// aux-build:test-macros.rs + +#[macro_use] +extern crate test_macros; + +#[identity_attr] //~ ERROR custom attributes cannot be applied to modules +mod m { + pub struct S; +} + +fn main() { + let s = m::S; +} diff --git a/src/test/ui/proc-macro/attributes-on-modules.stderr b/src/test/ui/proc-macro/attributes-on-modules.stderr new file mode 100644 index 00000000000..df75f0bf4b1 --- /dev/null +++ b/src/test/ui/proc-macro/attributes-on-modules.stderr @@ -0,0 +1,12 @@ +error[E0658]: custom attributes cannot be applied to modules + --> $DIR/attributes-on-modules.rs:6:1 + | +LL | #[identity_attr] + | ^^^^^^^^^^^^^^^^ + | + = note: for more information, see https://github.com/rust-lang/rust/issues/54727 + = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/proc-macro/module.rs b/src/test/ui/proc-macro/module.rs new file mode 100644 index 00000000000..5777ed89983 --- /dev/null +++ b/src/test/ui/proc-macro/module.rs @@ -0,0 +1 @@ +// ignore-test diff --git a/src/test/ui/proc-macro/outer/inner.rs b/src/test/ui/proc-macro/outer/inner.rs new file mode 100644 index 00000000000..5777ed89983 --- /dev/null +++ b/src/test/ui/proc-macro/outer/inner.rs @@ -0,0 +1 @@ +// ignore-test |
