Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cmichi opened this issue Nov 27, 2020 · 1 comment
Open

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

cmichi opened this issue Nov 27, 2020 · 1 comment

Comments

@cmichi
Copy link

cmichi commented Nov 27, 2020

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.

@BurntSushi
Copy link
Owner

Someone is welcome to submit a PR fixing this, if possible. I don't use or really work on the #[quickcheck] macro. It's almost never worth the added dependencies IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants