From 8fe696d3c4f79fe936d8697691b171aef3ef535d Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Sun, 7 Apr 2019 10:34:19 +0200 Subject: [PATCH] Add a proc-macro UI test example to the test project Taken from work on https://github.com/rust-lang/rust-clippy/issues/3741. I think this is a useful test to have because it tests * the `run-pass` header * the `aux-build` header, building auxiliary files * the `no-prefer-dynamic` header * proc-macro crate interactions with all of the above * running of UI tests that include auxiliary files There's no tests for any of the above right now. --- test-project/tests/ui/auxiliary/simple_proc_macro.rs | 12 ++++++++++++ test-project/tests/ui/some-proc-macro.rs | 12 ++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 test-project/tests/ui/auxiliary/simple_proc_macro.rs create mode 100644 test-project/tests/ui/some-proc-macro.rs diff --git a/test-project/tests/ui/auxiliary/simple_proc_macro.rs b/test-project/tests/ui/auxiliary/simple_proc_macro.rs new file mode 100644 index 0000000..d398ae1 --- /dev/null +++ b/test-project/tests/ui/auxiliary/simple_proc_macro.rs @@ -0,0 +1,12 @@ +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::{TokenStream}; + +#[proc_macro] +pub fn macro_test(input_stream: TokenStream) -> TokenStream { + TokenStream::new() +} diff --git a/test-project/tests/ui/some-proc-macro.rs b/test-project/tests/ui/some-proc-macro.rs new file mode 100644 index 0000000..9e4e4c2 --- /dev/null +++ b/test-project/tests/ui/some-proc-macro.rs @@ -0,0 +1,12 @@ +// run-pass +// aux-build:simple_proc_macro.rs + +#![feature(proc_macro_hygiene)] + +extern crate simple_proc_macro; +use simple_proc_macro::macro_test; + +fn main() { + println!("hi"); + macro_test!(2); +}