2020-08-02 23:20:00 +08:00
|
|
|
// Test proc-macro crate can be built without additional RUSTFLAGS
|
2020-03-03 16:17:15 +08:00
|
|
|
// on musl target
|
2020-03-08 21:49:52 +08:00
|
|
|
// override -Ctarget-feature=-crt-static from compiletest
|
2021-08-28 14:40:17 +08:00
|
|
|
//@ compile-flags: --crate-type proc-macro -Ctarget-feature=
|
2020-05-05 18:12:50 -07:00
|
|
|
//@ ignore-sgx no support for proc-macro crate type
|
2020-03-03 19:17:24 +08:00
|
|
|
//@ build-pass
|
2023-02-01 13:35:36 -08:00
|
|
|
//@ force-host
|
|
|
|
//@ no-prefer-dynamic
|
2023-05-17 10:41:41 +02:00
|
|
|
//@ needs-dynamic-linking
|
2024-03-25 14:24:08 +00:00
|
|
|
//@ needs-unwind compiling proc macros with panic=abort causes a warning
|
2023-02-01 13:35:36 -08:00
|
|
|
|
2020-03-03 16:17:15 +08:00
|
|
|
#![crate_type = "proc-macro"]
|
|
|
|
|
2021-08-28 14:40:17 +08:00
|
|
|
// FIXME: This don't work when crate-type is specified by attribute
|
|
|
|
// `#![crate_type = "proc-macro"]`, not by `--crate-type=proc-macro`
|
2022-08-18 10:13:37 +08:00
|
|
|
// command line flag. This is because the list of `cfg` symbols is generated
|
2021-08-28 14:40:17 +08:00
|
|
|
// before attributes are parsed. See rustc_interface::util::add_configuration
|
|
|
|
#[cfg(target_feature = "crt-static")]
|
|
|
|
compile_error!("crt-static is enabled");
|
|
|
|
|
2020-03-03 16:17:15 +08:00
|
|
|
extern crate proc_macro;
|
|
|
|
|
|
|
|
use proc_macro::TokenStream;
|
|
|
|
|
|
|
|
#[proc_macro_derive(Foo)]
|
|
|
|
pub fn derive_foo(input: TokenStream) -> TokenStream {
|
|
|
|
input
|
|
|
|
}
|