about summary refs log tree commit diff
path: root/tests/coverage/auxiliary/try_in_macro_helper.rs
blob: 27d2af15b055c7c66c0efaa1f6b4e88576b548af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//@ edition: 2024
// (The proc-macro crate doesn't need to be instrumented.)
//@ compile-flags: -Cinstrument-coverage=off

use proc_macro::TokenStream;

/// Minimized form of `#[derive(arbitrary::Arbitrary)]` that still triggers
/// the original bug.
const CODE: &str = "
    impl Arbitrary for MyEnum {
        fn try_size_hint() -> Option<usize> {
            Some(0)?;
            None
        }
    }
";

#[proc_macro_attribute]
pub fn attr(_attr: TokenStream, _item: TokenStream) -> TokenStream {
    CODE.parse().unwrap()
}

#[proc_macro]
pub fn bang(_item: TokenStream) -> TokenStream {
    CODE.parse().unwrap()
}

#[proc_macro_derive(Arbitrary)]
pub fn derive_arbitrary(_item: TokenStream) -> TokenStream {
    CODE.parse().unwrap()
}