aboutsummaryrefslogtreecommitdiff
path: root/crates/proc_macro_test/src
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2021-05-31 16:32:56 +0100
committerJonas Schievink <[email protected]>2021-05-31 16:32:56 +0100
commitcfcadcb2959d2dbaf7d95e8b9a33c48b75480e9f (patch)
tree65fdc84b5cb70a59b67ce7464f62dfe9c5da8eec /crates/proc_macro_test/src
parent70e347332d8b37c374db949bd966ff0bec8b32ab (diff)
Simplify proc_macro_srv tests
Diffstat (limited to 'crates/proc_macro_test/src')
-rw-r--r--crates/proc_macro_test/src/lib.rs38
1 files changed, 34 insertions, 4 deletions
diff --git a/crates/proc_macro_test/src/lib.rs b/crates/proc_macro_test/src/lib.rs
index ec2a114a3..4b26d2472 100644
--- a/crates/proc_macro_test/src/lib.rs
+++ b/crates/proc_macro_test/src/lib.rs
@@ -3,16 +3,46 @@
3use proc_macro::TokenStream; 3use proc_macro::TokenStream;
4 4
5#[proc_macro] 5#[proc_macro]
6pub fn function_like_macro(args: TokenStream) -> TokenStream { 6pub fn fn_like_noop(args: TokenStream) -> TokenStream {
7 args 7 args
8} 8}
9 9
10#[proc_macro]
11pub fn fn_like_panic(args: TokenStream) -> TokenStream {
12 panic!("fn_like_panic!({})", args);
13}
14
15#[proc_macro]
16pub fn fn_like_error(args: TokenStream) -> TokenStream {
17 format!("compile_error!(\"fn_like_error!({})\");", args).parse().unwrap()
18}
19
10#[proc_macro_attribute] 20#[proc_macro_attribute]
11pub fn attribute_macro(_args: TokenStream, item: TokenStream) -> TokenStream { 21pub fn attr_noop(_args: TokenStream, item: TokenStream) -> TokenStream {
12 item 22 item
13} 23}
14 24
15#[proc_macro_derive(DummyTrait)] 25#[proc_macro_attribute]
16pub fn derive_macro(_item: TokenStream) -> TokenStream { 26pub fn attr_panic(args: TokenStream, item: TokenStream) -> TokenStream {
27 panic!("#[attr_panic {}] {}", args, item);
28}
29
30#[proc_macro_attribute]
31pub fn attr_error(args: TokenStream, item: TokenStream) -> TokenStream {
32 format!("compile_error!(\"#[attr_error({})] {}\");", args, item).parse().unwrap()
33}
34
35#[proc_macro_derive(DeriveEmpty)]
36pub fn derive_empty(_item: TokenStream) -> TokenStream {
17 TokenStream::new() 37 TokenStream::new()
18} 38}
39
40#[proc_macro_derive(DerivePanic)]
41pub fn derive_panic(item: TokenStream) -> TokenStream {
42 panic!("#[derive(DerivePanic)] {}", item);
43}
44
45#[proc_macro_derive(DeriveError)]
46pub fn derive_error(item: TokenStream) -> TokenStream {
47 format!("compile_error!(\"#[derive(DeriveError)] {}\");", item).parse().unwrap()
48}