diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-04-15 22:00:14 +1000 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-04-16 17:53:27 +1000 |
| commit | 99dd5911a1026da0a374b697e4a0407a631eb388 (patch) | |
| tree | 4e88a1416f3c7336e83d2c1797aa0de76d8ca84b /src/libsyntax/ext/trace_macros.rs | |
| parent | 168b2d1a3f4569706fe4f9a2baee04e37f85d297 (diff) | |
| download | rust-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/libsyntax/ext/trace_macros.rs')
| -rw-r--r-- | src/libsyntax/ext/trace_macros.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libsyntax/ext/trace_macros.rs b/src/libsyntax/ext/trace_macros.rs index 173cf4c9ad9..d428251604c 100644 --- a/src/libsyntax/ext/trace_macros.rs +++ b/src/libsyntax/ext/trace_macros.rs @@ -17,7 +17,7 @@ use parse::token::{keywords, is_keyword}; pub fn expand_trace_macros(cx: &mut ExtCtxt, sp: Span, tt: &[ast::TokenTree]) - -> base::MacResult { + -> ~base::MacResult { match tt { [ast::TTTok(_, ref tok)] if is_keyword(keywords::True, tok) => { cx.set_trace_macros(true); @@ -28,5 +28,5 @@ pub fn expand_trace_macros(cx: &mut ExtCtxt, _ => cx.span_err(sp, "trace_macros! accepts only `true` or `false`"), } - base::MacResult::dummy_any(sp) + base::DummyResult::any(sp) } |
