BurntSushi/quickcheck

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

Aberta

#261 aberto em 27 de nov. de 2020

 (1 comentário) (0 reação) (0 responsável)Rust (161 forks)github user discovery
enhancementhelp wanted

Métricas do repositório

Stars
 (2.763 estrelas)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

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.

Guia do colaborador