]> git.proxmox.com Git - rustc.git/blob - src/test/incremental/auxiliary/issue_54059.rs
New upstream version 1.32.0~beta.2+dfsg1
[rustc.git] / src / test / incremental / auxiliary / issue_54059.rs
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
11 // force-host
12 // no-prefer-dynamic
13
14 // check that having extern "C" functions in a proc macro doesn't crash.
15
16 #![crate_type="proc-macro"]
17 #![allow(non_snake_case)]
18
19 extern crate proc_macro;
20
21 macro_rules! proc_macro_tokenstream {
22 () => {
23 ::proc_macro::TokenStream
24 };
25 }
26
27 macro_rules! proc_macro_expr_impl {
28 ($(
29 $( #[$attr:meta] )*
30 pub fn $func:ident($input:ident: &str) -> String $body:block
31 )+) => {
32 $(
33 // Parses an input that looks like:
34 //
35 // ```
36 // #[allow(unused)]
37 // enum ProcMacroHack {
38 // Input = (stringify!(ARGS), 0).1,
39 // }
40 // ```
41 $( #[$attr] )*
42 #[proc_macro_derive($func)]
43 pub fn $func(input: proc_macro_tokenstream!()) -> proc_macro_tokenstream!() {
44 unsafe { rust_dbg_extern_identity_u64(0); }
45 panic!()
46 }
47 )+
48 };
49 }
50
51 proc_macro_expr_impl! {
52 pub fn base2_impl(input: &str) -> String {
53 panic!()
54 }
55 }
56
57 #[link(name="rust_test_helpers")]
58 extern "C" {
59 pub fn rust_dbg_extern_identity_u64(v: u64) -> u64;
60 }