Open
Description
Hello! Bear with me as I am new to Arbitrary.
I have this type from juniper:
pub struct Arguments<'a, S> {
pub items: Vec<(Spanning<&'a str>, Spanning<InputValue<S>>)>,
}
Spanning
and InputValue
successfully derive(arbitrary::Arbitrary))
. When I try to derive on Arguments
, I get the following error:
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
--> juniper/src/ast.rs:59:42
|
59 | #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
| ^^^^^^^^^^^^^^^^^^^^
|
note: first, the lifetime cannot outlive the lifetime `'a` as defined here...
--> juniper/src/ast.rs:60:22
|
60 | pub struct Arguments<'a, S> {
| ^^
note: ...so that the types are compatible
--> juniper/src/ast.rs:59:42
|
59 | #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
| ^^^^^^^^^^^^^^^^^^^^
= note: expected `<&'a str as Arbitrary<'_>>`
found `<&str as Arbitrary<'_>>`
note: but, the lifetime must be valid for the lifetime `'arbitrary` as defined here...
--> juniper/src/ast.rs:59:42
|
59 | #[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
| ^^^^^^^^^^^^^^^^^^^^
note: ...so that the types are compatible
Manually implenting it works:
impl<'a, S> arbitrary::Arbitrary<'a> for Arguments<'a, S>
where
S: arbitrary::Arbitrary<'a>,
{
fn arbitrary(u: &mut arbitrary::Unstructured<'a>) -> arbitrary::Result<Self> {
let items: Vec<(Spanning<&'a str>, Spanning<InputValue<S>>)> = u.arbitrary()?;
Ok(Self { items })
}
}
Even though I am unblocked, I figured I'd file as one would expect the derive to work in this case.
Metadata
Metadata
Assignees
Labels
No labels