BurntSushi / BurntSushi/quickcheck

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

Open
#261 1 comment 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
Rust
Stars
2.8k
Forks
165
PR merge metrics
No merged PRs in 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.