about summary refs log tree commit diff
path: root/src/libhexfloat/lib.rs
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2014-04-15 22:00:14 +1000
committerHuon Wilson <dbau.pp+github@gmail.com>2014-04-16 17:53:27 +1000
commit99dd5911a1026da0a374b697e4a0407a631eb388 (patch)
tree4e88a1416f3c7336e83d2c1797aa0de76d8ca84b /src/libhexfloat/lib.rs
parent168b2d1a3f4569706fe4f9a2baee04e37f85d297 (diff)
downloadrust-99dd5911a1026da0a374b697e4a0407a631eb388.tar.gz
rust-99dd5911a1026da0a374b697e4a0407a631eb388.zip
syntax: unify all MacResult's into a single trait.
There's now one unified way to return things from a macro, instead of
being able to choose the `AnyMacro` trait or the `MRItem`/`MRExpr`
variants of the `MacResult` enum. This does simplify the logic handling
the expansions, but the biggest value of this is it makes macros in (for
example) type position easier to implement, as there's this single thing
to modify.

By my measurements (using `-Z time-passes` on libstd and librustc etc.),
this appears to have little-to-no impact on expansion speed. There are
presumably larger costs than the small number of extra allocations and
virtual calls this adds (notably, all `macro_rules!`-defined macros have
not changed in behaviour, since they had to use the `AnyMacro` trait
anyway).
Diffstat (limited to 'src/libhexfloat/lib.rs')
-rw-r--r--src/libhexfloat/lib.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libhexfloat/lib.rs b/src/libhexfloat/lib.rs
index 9f2f417080f..e65b84091e5 100644
--- a/src/libhexfloat/lib.rs
+++ b/src/libhexfloat/lib.rs
@@ -53,7 +53,7 @@ use syntax::ast;
 use syntax::ast::Name;
 use syntax::codemap::{Span, mk_sp};
 use syntax::ext::base;
-use syntax::ext::base::{SyntaxExtension, BasicMacroExpander, NormalTT, ExtCtxt, MRExpr};
+use syntax::ext::base::{SyntaxExtension, BasicMacroExpander, NormalTT, ExtCtxt, MacExpr};
 use syntax::ext::build::AstBuilder;
 use syntax::parse;
 use syntax::parse::token;
@@ -97,7 +97,7 @@ fn hex_float_lit_err(s: &str) -> Option<(uint, ~str)> {
     }
 }
 
-pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> base::MacResult {
+pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> ~base::MacResult {
     let (expr, ty_lit) = parse_tts(cx, tts);
 
     let ty = match ty_lit {
@@ -121,12 +121,12 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) ->
             }
             _ => {
                 cx.span_err(expr.span, "unsupported literal in hexfloat!");
-                return base::MacResult::dummy_expr(sp);
+                return base::DummyResult::expr(sp);
             }
         },
         _ => {
             cx.span_err(expr.span, "non-literal in hexfloat!");
-            return base::MacResult::dummy_expr(sp);
+            return base::DummyResult::expr(sp);
         }
     };
 
@@ -137,7 +137,7 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) ->
                 let pos = expr.span.lo + syntax::codemap::Pos::from_uint(err_pos + 1);
                 let span = syntax::codemap::mk_sp(pos,pos);
                 cx.span_err(span, format!("invalid hex float literal in hexfloat!: {}", err_str));
-                return base::MacResult::dummy_expr(sp);
+                return base::DummyResult::expr(sp);
             }
             _ => ()
         }
@@ -147,7 +147,7 @@ pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) ->
         None => ast::LitFloatUnsuffixed(s),
         Some (ty) => ast::LitFloat(s, ty)
     };
-    MRExpr(cx.expr_lit(sp, lit))
+    MacExpr::new(cx.expr_lit(sp, lit))
 }
 
 struct Ident {