Reformat metadata for exported macros
Instead of copy-pasting the whole macro_rules! item from the original .rs file, we serialize a separate name, attributes list, and body, the latter as pretty-printed TTs. The compilation of macro_rules! macros is decoupled somewhat from the expansion of macros in item position. This filters out comments, and facilitates selective imports.
This commit is contained in:
@@ -476,7 +476,7 @@ pub struct Crate {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub config: CrateConfig,
|
||||
pub span: Span,
|
||||
pub exported_macros: Vec<P<Item>>
|
||||
pub exported_macros: Vec<MacroDef>,
|
||||
}
|
||||
|
||||
pub type MetaItem = Spanned<MetaItem_>;
|
||||
@@ -1698,6 +1698,19 @@ pub enum InlinedItem {
|
||||
IIForeign(P<ForeignItem>),
|
||||
}
|
||||
|
||||
/// A macro definition, in this crate or imported from another.
|
||||
///
|
||||
/// Not parsed directly, but created on macro import or `macro_rules!` expansion.
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
|
||||
pub struct MacroDef {
|
||||
pub ident: Ident,
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub id: NodeId,
|
||||
pub span: Span,
|
||||
pub imported_from: Option<Ident>,
|
||||
pub body: Vec<TokenTree>,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use serialize::json;
|
||||
|
||||
Reference in New Issue
Block a user