diff options
| author | Douglas Young <rcxdude@gmail.com> | 2014-02-18 16:14:12 +0000 |
|---|---|---|
| committer | Douglas Young <rcxdude@gmail.com> | 2014-02-18 16:17:51 +0000 |
| commit | 0bdfd0f4c76fa29a4be774937bc72165390b06d6 (patch) | |
| tree | e595de26e0a25bd8b8258a82ef653553c499d42e /src/libsyntax/ext/format.rs | |
| parent | 517e38997db9f60612676c9f83dab6ed35c1b5df (diff) | |
| download | rust-0bdfd0f4c76fa29a4be774937bc72165390b06d6.tar.gz rust-0bdfd0f4c76fa29a4be774937bc72165390b06d6.zip | |
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.
Diffstat (limited to 'src/libsyntax/ext/format.rs')
| -rw-r--r-- | src/libsyntax/ext/format.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index 01d348595b8..13b1afb4c00 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -811,7 +811,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span, expr, "format argument must be a string literal.") { Some((fmt, _)) => fmt, - None => return efmt + None => return MacResult::raw_dummy_expr(sp) }; let mut parser = parse::Parser::new(fmt.get()); @@ -829,7 +829,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span, match parser.errors.shift() { Some(error) => { cx.ecx.span_err(efmt.span, "invalid format string: " + error); - return efmt; + return MacResult::raw_dummy_expr(sp); } None => {} } |
