rust/src/test/run-pass/proc-macro/auxiliary/double.rs

25 lines
823 B
Rust
Raw Normal View History

2016-11-07 22:06:40 -06:00
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// no-prefer-dynamic
#![crate_type = "proc-macro"]
extern crate proc_macro;
use proc_macro::TokenStream;
2018-06-11 18:29:12 -05:00
// Outputs another copy of the struct. Useful for testing the tokens
// seen by the proc_macro.
2016-11-07 22:06:40 -06:00
#[proc_macro_derive(Double)]
pub fn derive(input: TokenStream) -> TokenStream {
format!("mod foo {{ {} }}", input.to_string()).parse().unwrap()
}