]> git.lizzy.rs Git - rust.git/commit
syntax: unify all MacResult's into a single trait.
authorHuon Wilson <dbau.pp+github@gmail.com>
Tue, 15 Apr 2014 12:00:14 +0000 (22:00 +1000)
committerHuon Wilson <dbau.pp+github@gmail.com>
Wed, 16 Apr 2014 07:53:27 +0000 (17:53 +1000)
commit99dd5911a1026da0a374b697e4a0407a631eb388
tree4e88a1416f3c7336e83d2c1797aa0de76d8ca84b
parent168b2d1a3f4569706fe4f9a2baee04e37f85d297
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).
18 files changed:
src/libfourcc/lib.rs
src/libhexfloat/lib.rs
src/libsyntax/ext/asm.rs
src/libsyntax/ext/base.rs
src/libsyntax/ext/bytes.rs
src/libsyntax/ext/cfg.rs
src/libsyntax/ext/concat.rs
src/libsyntax/ext/concat_idents.rs
src/libsyntax/ext/env.rs
src/libsyntax/ext/expand.rs
src/libsyntax/ext/fmt.rs
src/libsyntax/ext/format.rs
src/libsyntax/ext/log_syntax.rs
src/libsyntax/ext/quote.rs
src/libsyntax/ext/source_util.rs
src/libsyntax/ext/trace_macros.rs
src/libsyntax/ext/tt/macro_rules.rs
src/test/auxiliary/macro_crate_test.rs