BurntSushi/quickcheck

Trivial cast error when using `#[quickcheck]` inside macro

開放

#261 建立於 2020年11月27日

 (1 則留言) (0 個反應) (0 位負責人)Rust (161 個分叉)github user discovery
enhancementhelp wanted

倉庫指標

星標
 (2,763 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

This is a minimal example:

crate::my_macro!(u32);

#[macro_export]
macro_rules! my_macro {
    ($my_type:ty) => {
        #[quickcheck]
        fn fuzz_my_type(my: $my_type) {
            // ...
        }
    }
}

Results in

error: trivial cast: `fn(u32) {fuzz_my_type::fuzz_my_type}` as `fn(u32)`
   --> ~/fuzz_tests.rs:13:9
    |
  2 |   crate::my_macro!(u32);
    |   ---------------------- in this macro invocation
... 
 13 | /         #[quickcheck]
 14 | |         fn fuzz_my_type(my: $my_type) {
    | |_______________________^

It works if I add #[allow(trivial_casts)], but it should work without flags to the compiler.

貢獻者指南