/src/test/run-pass-fulldeps/proc-macro/auxiliary/test-macros.rs

https://gitlab.com/jianglu/rust · Rust · 36 lines · 19 code · 7 blank · 10 comment · 0 complexity · 8653d5e3d09a8359f987594884ab16b2 MD5 · raw file

  1. // Copyright 2018 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. // no-prefer-dynamic
  11. #![crate_type = "proc-macro"]
  12. #![feature(proc_macro)]
  13. extern crate proc_macro;
  14. use proc_macro::TokenStream;
  15. #[proc_macro_attribute]
  16. pub fn nop_attr(_attr: TokenStream, input: TokenStream) -> TokenStream {
  17. assert!(_attr.to_string().is_empty());
  18. input
  19. }
  20. #[proc_macro_attribute]
  21. pub fn no_output(_attr: TokenStream, _input: TokenStream) -> TokenStream {
  22. assert!(_attr.to_string().is_empty());
  23. assert!(!_input.to_string().is_empty());
  24. "".parse().unwrap()
  25. }
  26. #[proc_macro]
  27. pub fn emit_input(input: TokenStream) -> TokenStream {
  28. input
  29. }