Avoid returning original macro if expansion fails.

Closes #11692. Instead of returning the original expression, a dummy expression
(with identical span) is returned. This prevents infinite loops of failed
expansions as well as odd double error messages in certain situations.
This commit is contained in:
Douglas Young
2014-02-18 16:14:12 +00:00
parent 517e38997d
commit 0bdfd0f4c7
11 changed files with 53 additions and 28 deletions

View File

@@ -21,7 +21,7 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
tts: &[ast::TokenTree]) -> base::MacResult {
let es = match base::get_exprs_from_tts(cx, sp, tts) {
Some(e) => e,
None => return base::MacResult::dummy_expr()
None => return base::MacResult::dummy_expr(sp)
};
let mut accumulator = ~"";
for e in es.move_iter() {