about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorTim Neumann <mail@timnn.me>2015-08-10 20:40:46 +0200
committerTim Neumann <mail@timnn.me>2015-08-10 20:43:11 +0200
commitd46e84081f88f22198fbfcd5221faaf922e0500d (patch)
tree81c9a3bbaab8586673d96f05ba5bb7822fe1d9a3 /src/libsyntax/ext
parentc115c513632b45d1a4d1b3fb648755a7023269e7 (diff)
downloadrust-d46e84081f88f22198fbfcd5221faaf922e0500d.tar.gz
rust-d46e84081f88f22198fbfcd5221faaf922e0500d.zip
add and use Span.substitute_dummy method
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/tt/macro_rules.rs23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index 53e3127086c..d728fa59bd1 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -211,12 +211,8 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt,
                 best_fail_spot = sp;
                 best_fail_msg = (*msg).clone();
               },
-              Error(mut spp, ref msg) => {
-                if spp == DUMMY_SP {
-                    spp = sp;
-                }
-
-                panic!(cx.span_fatal(spp, &msg[..]))
+              Error(err_sp, ref msg) => {
+                panic!(cx.span_fatal(err_sp.substitute_dummy(sp), &msg[..]))
               }
             }
           }
@@ -224,11 +220,7 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt,
         }
     }
 
-    if best_fail_spot == DUMMY_SP {
-        best_fail_spot = sp;
-    }
-
-    panic!(cx.span_fatal(best_fail_spot, &best_fail_msg[..]));
+    panic!(cx.span_fatal(best_fail_spot.substitute_dummy(sp), &best_fail_msg[..]));
 }
 
 // Note that macro-by-example's input is also matched against a token tree:
@@ -283,12 +275,9 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt,
                                    arg_reader,
                                    &argument_gram) {
         Success(m) => m,
-        Failure(mut sp, str) | Error(mut sp, str) => {
-            if sp == DUMMY_SP {
-                sp = def.span;
-            }
-
-            panic!(cx.parse_sess().span_diagnostic.span_fatal(sp, &str[..]));
+        Failure(sp, str) | Error(sp, str) => {
+            panic!(cx.parse_sess().span_diagnostic
+                     .span_fatal(sp.substitute_dummy(def.span), &str[..]));
         }
     };