diff options
Diffstat (limited to 'third_party/rust/proc-macro-hack/tests')
9 files changed, 54 insertions, 0 deletions
diff --git a/third_party/rust/proc-macro-hack/tests/compiletest.rs b/third_party/rust/proc-macro-hack/tests/compiletest.rs new file mode 100644 index 0000000000..f9aea23b51 --- /dev/null +++ b/third_party/rust/proc-macro-hack/tests/compiletest.rs @@ -0,0 +1,6 @@ +#[rustversion::attr(not(nightly), ignore)] +#[test] +fn ui() { + let t = trybuild::TestCases::new(); + t.compile_fail("tests/ui/*.rs"); +} diff --git a/third_party/rust/proc-macro-hack/tests/ui/private.rs b/third_party/rust/proc-macro-hack/tests/ui/private.rs new file mode 100644 index 0000000000..1ab84446c7 --- /dev/null +++ b/third_party/rust/proc-macro-hack/tests/ui/private.rs @@ -0,0 +1,8 @@ +use proc_macro_hack::proc_macro_hack; + +#[proc_macro_hack] +fn my_macro(input: TokenStream) -> TokenStream { + unimplemented!() +} + +fn main() {} diff --git a/third_party/rust/proc-macro-hack/tests/ui/private.stderr b/third_party/rust/proc-macro-hack/tests/ui/private.stderr new file mode 100644 index 0000000000..d3a3ea7ed4 --- /dev/null +++ b/third_party/rust/proc-macro-hack/tests/ui/private.stderr @@ -0,0 +1,5 @@ +error: functions tagged with `#[proc_macro_hack]` must be `pub` + --> tests/ui/private.rs:4:1 + | +4 | fn my_macro(input: TokenStream) -> TokenStream { + | ^^ diff --git a/third_party/rust/proc-macro-hack/tests/ui/unexpected-arg.rs b/third_party/rust/proc-macro-hack/tests/ui/unexpected-arg.rs new file mode 100644 index 0000000000..376fc0d986 --- /dev/null +++ b/third_party/rust/proc-macro-hack/tests/ui/unexpected-arg.rs @@ -0,0 +1,8 @@ +use proc_macro_hack::proc_macro_hack; + +#[proc_macro_hack(fake_call_site)] +pub fn my_macro(input: TokenStream) -> TokenStream { + unimplemented!() +} + +fn main() {} diff --git a/third_party/rust/proc-macro-hack/tests/ui/unexpected-arg.stderr b/third_party/rust/proc-macro-hack/tests/ui/unexpected-arg.stderr new file mode 100644 index 0000000000..f32f05a1cd --- /dev/null +++ b/third_party/rust/proc-macro-hack/tests/ui/unexpected-arg.stderr @@ -0,0 +1,5 @@ +error: unexpected argument to proc_macro_hack macro implementation; args are only accepted on the macro declaration (the `pub use`) + --> tests/ui/unexpected-arg.rs:3:19 + | +3 | #[proc_macro_hack(fake_call_site)] + | ^^^^^^^^^^^^^^ diff --git a/third_party/rust/proc-macro-hack/tests/ui/unexpected.rs b/third_party/rust/proc-macro-hack/tests/ui/unexpected.rs new file mode 100644 index 0000000000..122ded5191 --- /dev/null +++ b/third_party/rust/proc-macro-hack/tests/ui/unexpected.rs @@ -0,0 +1,6 @@ +use proc_macro_hack::proc_macro_hack; + +#[proc_macro_hack] +pub struct What; + +fn main() {} diff --git a/third_party/rust/proc-macro-hack/tests/ui/unexpected.stderr b/third_party/rust/proc-macro-hack/tests/ui/unexpected.stderr new file mode 100644 index 0000000000..60761b5149 --- /dev/null +++ b/third_party/rust/proc-macro-hack/tests/ui/unexpected.stderr @@ -0,0 +1,5 @@ +error: unexpected input to #[proc_macro_hack] + --> tests/ui/unexpected.rs:4:5 + | +4 | pub struct What; + | ^^^^^^ diff --git a/third_party/rust/proc-macro-hack/tests/ui/unknown-arg.rs b/third_party/rust/proc-macro-hack/tests/ui/unknown-arg.rs new file mode 100644 index 0000000000..aa9b82c8f4 --- /dev/null +++ b/third_party/rust/proc-macro-hack/tests/ui/unknown-arg.rs @@ -0,0 +1,6 @@ +use proc_macro_hack::proc_macro_hack; + +#[proc_macro_hack(fake_call_site, support_nexted)] +pub use demo::some_macro; + +fn main() {} diff --git a/third_party/rust/proc-macro-hack/tests/ui/unknown-arg.stderr b/third_party/rust/proc-macro-hack/tests/ui/unknown-arg.stderr new file mode 100644 index 0000000000..772e6673d0 --- /dev/null +++ b/third_party/rust/proc-macro-hack/tests/ui/unknown-arg.stderr @@ -0,0 +1,5 @@ +error: expected one of: `support_nested`, `internal_macro_calls`, `fake_call_site`, `only_hack_old_rustc` + --> tests/ui/unknown-arg.rs:3:35 + | +3 | #[proc_macro_hack(fake_call_site, support_nexted)] + | ^^^^^^^^^^^^^^ |