]> git.lizzy.rs Git - rust.git/blob - src/test/ui/auxiliary/proc_macro_def.rs
Rollup merge of #71633 - a1phyr:infallible_error, r=dtolnay
[rust.git] / src / test / ui / auxiliary / proc_macro_def.rs
1 // force-host
2 // no-prefer-dynamic
3
4 #![crate_type = "proc-macro"]
5 #![feature(proc_macro_quote)]
6
7 extern crate proc_macro;
8
9 use proc_macro::*;
10
11 #[proc_macro_attribute]
12 pub fn attr_tru(_attr: TokenStream, item: TokenStream) -> TokenStream {
13     let name = item.into_iter().nth(1).unwrap();
14     quote!(fn $name() -> bool { true })
15 }
16
17 #[proc_macro_attribute]
18 pub fn attr_identity(_attr: TokenStream, item: TokenStream) -> TokenStream {
19     quote!($item)
20 }
21
22 #[proc_macro]
23 pub fn tru(_ts: TokenStream) -> TokenStream {
24     quote!(true)
25 }
26
27 #[proc_macro]
28 pub fn ret_tru(_ts: TokenStream) -> TokenStream {
29     quote!(return true;)
30 }
31
32 #[proc_macro]
33 pub fn identity(ts: TokenStream) -> TokenStream {
34     quote!($ts)
35 }