Redo exported macro serialization

The old method of serializing the AST gives totally bogus spans if the
expansion of an imported macro causes compilation errors. The best
solution seems to be to serialize the actual textual macro definition
and load it the same way the std-macros are. I'm not totally confident
that getting the source from the CodeMap will always do the right thing,
but it seems to work in simple cases.
This commit is contained in:
Steven Fackler 2014-01-21 23:09:53 -08:00
parent f8477c9da5
commit d908e97da3
10 changed files with 31 additions and 15 deletions

View file

@ -130,10 +130,10 @@ pub fn parse_item_from_source_str(
name: @str,
source: @str,
cfg: ast::CrateConfig,
attrs: ~[ast::Attribute],
sess: @ParseSess
) -> Option<@ast::Item> {
let mut p = new_parser_from_source_str(sess, cfg, name, source);
let attrs = p.parse_outer_attributes();
maybe_aborted(p.parse_item(attrs),p)
}