Skip to main content

pistonite_pm/
lib.rs

1//! Batteries-included proc-macro utils
2//!
3//! This re-exports the common libraries - `syn`, `quote`, and `proc-macro2`,
4//! that you need to work with proc-macros, as well as utilities
5//! to interop between them.
6//!
7//! # Re-exports
8//! Most of `quote`, `proc_macro`, and `proc_macro2` are re-exported,
9//! and they can be used with the `pm::` prefix. Types that have the same
10//! name in `proc_macro` and `proc_macro2` are suffixed with `2` in
11//! the `proc_macro2` export.
12//!
13//! Types from `syn` can be used as with `syn::` prefix, by adding
14//! the prelude import `use pm::pre::*`.
15
16mod util;
17#[allow(unused)]
18pub use util::*;
19
20// lib re-exports
21pub mod lib {
22    pub use proc_macro2;
23    pub use quote;
24    pub use syn;
25}
26
27// type re-exports
28pub use proc_macro2::{
29    Delimiter as Delimiter2, Group as Group2, Ident as Ident2, LexError as LexError2,
30    Literal as Literal2, Punct as Punct2, Spacing as Spacing2, Span as Span2,
31    TokenStream as TokenStream2, TokenTree as TokenTree2,
32};
33pub use quote::{ToTokens, format_ident, quote, quote_spanned};
34pub use syn::{Error, Result};
35
36#[cfg(feature = "proc-macro")]
37extern crate proc_macro;
38#[cfg(feature = "proc-macro")]
39pub use proc_macro::{
40    Delimiter, Group, Ident, LexError, Literal, Punct, Spacing, Span, TokenStream, TokenTree,
41};
42
43// prelude traits
44pub mod pre {
45    #[cfg(feature = "proc-macro")]
46    pub use crate::Span;
47    pub use crate::Span2;
48    #[cfg(feature = "proc-macro")]
49    pub use crate::TokenStream;
50    pub use crate::TokenStream2;
51    pub use crate::lib::quote::ToTokens as _;
52    pub use syn;
53}