summaryrefslogtreecommitdiffstats
path: root/tests/ui/macros/auxiliary/proc_macro_def.rs
blob: 0497e4ae07d9a199e23081ab0312c8e285e8fc89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// force-host
// no-prefer-dynamic

#![crate_type = "proc-macro"]
#![feature(proc_macro_quote)]

extern crate proc_macro;

use proc_macro::*;

#[proc_macro_attribute]
pub fn attr_tru(_attr: TokenStream, item: TokenStream) -> TokenStream {
    let name = item.into_iter().nth(1).unwrap();
    quote!(fn $name() -> bool { true })
}

#[proc_macro_attribute]
pub fn attr_identity(_attr: TokenStream, item: TokenStream) -> TokenStream {
    quote!($item)
}

#[proc_macro]
pub fn tru(_ts: TokenStream) -> TokenStream {
    quote!(true)
}

#[proc_macro]
pub fn ret_tru(_ts: TokenStream) -> TokenStream {
    quote!(return true;)
}

#[proc_macro]
pub fn identity(ts: TokenStream) -> TokenStream {
    quote!($ts)
}