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:
Keegan McAllister
2014-12-30 19:10:46 -08:00
parent 24aa7f0e38
commit 677b7cad3d
12 changed files with 141 additions and 131 deletions

View File

@@ -1115,7 +1115,7 @@ pub fn noop_fold_mod<T: Folder>(Mod {inner, view_items, items}: Mod, folder: &mu
}
}
pub fn noop_fold_crate<T: Folder>(Crate {module, attrs, config, exported_macros, span}: Crate,
pub fn noop_fold_crate<T: Folder>(Crate {module, attrs, config, mut exported_macros, span}: Crate,
folder: &mut T) -> Crate {
let config = folder.fold_meta_items(config);
@@ -1146,6 +1146,10 @@ pub fn noop_fold_crate<T: Folder>(Crate {module, attrs, config, exported_macros,
}, Vec::new(), span)
};
for def in exported_macros.iter_mut() {
def.id = folder.new_id(def.id);
}
Crate {
module: module,
attrs: attrs,