/src/test/auxiliary/syntax_extension_with_dll_deps_2.rs

https://gitlab.com/pranith/rust · Rust · 34 lines · 18 code · 6 blank · 10 comment · 0 complexity · 5bfa8b07704d4ac81385dab946d0b09a MD5 · raw file

  1. // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
  2. // file at the top-level directory of this distribution and at
  3. // http://rust-lang.org/COPYRIGHT.
  4. //
  5. // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
  6. // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
  7. // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
  8. // option. This file may not be copied, modified, or distributed
  9. // except according to those terms.
  10. // force-host
  11. #![crate_type = "dylib"]
  12. #![feature(plugin_registrar, quote, rustc_private)]
  13. extern crate syntax_extension_with_dll_deps_1 as other;
  14. extern crate syntax;
  15. extern crate rustc;
  16. use syntax::ast::{TokenTree, Item, MetaItem};
  17. use syntax::codemap::Span;
  18. use syntax::ext::base::*;
  19. use rustc::plugin::Registry;
  20. #[plugin_registrar]
  21. pub fn plugin_registrar(reg: &mut Registry) {
  22. reg.register_macro("foo", expand_foo);
  23. }
  24. fn expand_foo(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree])
  25. -> Box<MacResult+'static> {
  26. let answer = other::the_answer();
  27. MacEager::expr(quote_expr!(cx, $answer))
  28. }