]> git.lizzy.rs Git - rust.git/blob - src/test/incremental/auxiliary/issue-54059.rs
Rollup merge of #100823 - WaffleLapkin:less_offsets, r=scottmcm
[rust.git] / src / test / incremental / auxiliary / issue-54059.rs
1 // force-host
2 // no-prefer-dynamic
3
4 // check that having extern "C" functions in a proc macro doesn't crash.
5
6 #![crate_type="proc-macro"]
7 #![allow(non_snake_case)]
8
9 extern crate proc_macro;
10
11 macro_rules! proc_macro_tokenstream {
12     () => {
13         ::proc_macro::TokenStream
14     };
15 }
16
17 macro_rules! proc_macro_expr_impl {
18     ($(
19         $( #[$attr:meta] )*
20         pub fn $func:ident($input:ident: &str) -> String $body:block
21     )+) => {
22         $(
23             // Parses an input that looks like:
24             //
25             // ```
26             // #[allow(unused)]
27             // enum ProcMacroHack {
28             //     Input = (stringify!(ARGS), 0).1,
29             // }
30             // ```
31             $( #[$attr] )*
32             #[proc_macro_derive($func)]
33             pub fn $func(input: proc_macro_tokenstream!()) -> proc_macro_tokenstream!() {
34                 unsafe { rust_dbg_extern_identity_u64(0); }
35                 panic!()
36             }
37         )+
38     };
39 }
40
41 proc_macro_expr_impl! {
42     pub fn base2_impl(input: &str) -> String {
43         panic!()
44     }
45 }
46
47 #[link(name="rust_test_helpers")]
48 extern "C" {
49     pub fn rust_dbg_extern_identity_u64(v: u64) -> u64;
50 }