From cb816b1ea87b24f34eeecfdd98aeeb629915d661 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sat, 15 Aug 2020 00:19:47 +0200 Subject: Add a proc_macro_test crate This exports all 3 kinds of proc macros and is useful for testing --- crates/proc_macro_test/Cargo.toml | 10 ++++++++++ crates/proc_macro_test/src/lib.rs | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 crates/proc_macro_test/Cargo.toml create mode 100644 crates/proc_macro_test/src/lib.rs (limited to 'crates/proc_macro_test') diff --git a/crates/proc_macro_test/Cargo.toml b/crates/proc_macro_test/Cargo.toml new file mode 100644 index 000000000..7b0f64f31 --- /dev/null +++ b/crates/proc_macro_test/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "proc_macro_test" +version = "0.0.0" +license = "MIT OR Apache-2.0" +authors = ["rust-analyzer developers"] +edition = "2018" + +[lib] +doctest = false +proc-macro = true diff --git a/crates/proc_macro_test/src/lib.rs b/crates/proc_macro_test/src/lib.rs new file mode 100644 index 000000000..ec2a114a3 --- /dev/null +++ b/crates/proc_macro_test/src/lib.rs @@ -0,0 +1,18 @@ +//! Exports a few trivial procedural macros for testing. + +use proc_macro::TokenStream; + +#[proc_macro] +pub fn function_like_macro(args: TokenStream) -> TokenStream { + args +} + +#[proc_macro_attribute] +pub fn attribute_macro(_args: TokenStream, item: TokenStream) -> TokenStream { + item +} + +#[proc_macro_derive(DummyTrait)] +pub fn derive_macro(_item: TokenStream) -> TokenStream { + TokenStream::new() +} -- cgit v1.2.3