This error occurs when #[derive(Arbitrary)]
is used on a type which has any
lifetime parameters. For example:
#[derive(Debug, Arbitrary)]
struct Foo<'a> {
bar: &'a str,
}
Due to the lack of generic associated types (GATs) on stable Rust,
it is currently impossible to define a Strategy
which generates a type
that is lifetime-generic (e.g. &'a T
). Thus, proptest cannot implement
Arbitrary
for such types either and therefore you cannot #[derive(Arbitrary)]
for such types. Once GATs are available, we will try to lift this restriction.
To follow the progress, consult the tracking issue on the matter.
This error occurs when #[derive(Arbitrary)]
is used on a union
type.
An example:
#[derive(Debug, Arbitrary)]
union IU32 {
signed: i32,
unsigned: u32,
}
There are two main reasons for the error.
-
It is not possible to
#[derive(Debug)]
onunion
types and manual implementations cannot know which variant is valid so there are not many valid implementations which are possible. -
Second, we cannot mechanically tell which variant out of
signed
andunsigned
to generate. While we could allow you to tell the macro, with an attribute such as#[proptest(select)]
on the variant, we have opted for a more conservative approach for the time being. If you have a use case for#[derive(Arbitrary)]
onunion
types, please reach out on the issue tracker.