You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error[E0277]: the trait bound `<T as Foo>::FooT: serde::Serialize` is not satisfied
--> src/lib.rs:13:10
|
13 | #[derive(Serialize)]
| ^^^^^^^^^ the trait `serde::Serialize` is not implemented for `<T as Foo>::FooT`
|
= help: consider adding a `where <T as Foo>::FooT: serde::Serialize` bound
= note: required because of the requirements on the impl of `serde::Serialize` for `Bar<<T as Foo>::FooT>`
= note: required by `serde::ser::SerializeStruct::serialize_field`
error: aborting due to previous error
This seems similar to rust-lang/rust#31518, but if we change Serialize to Clone it would work.
The text was updated successfully, but these errors were encountered:
Your code would compile if Serde were to infer a bound of <T as Foo>::FooT: Serialize but I believe this would be a breaking change because it is not clear that Bar needs to serialize T::FooT. For example the following currently works without that bound.
but if we change Serialize to Clone it would work.
The derived Clone impl compiles by itself but falls apart when you try to use it. As discussed in rust-lang/rust#26925, with the current derive API it is impossible to tell what the right bounds should be. For example:
traitFoo{typeFooT;}#[derive(Clone)]structBar<T>{bar:T,}#[derive(Clone)]structBaz<T:Foo>{baz:Bar<T::FooT>,}fnmain(){structS;implFooforS{typeFooT = usize;}// Should be clonable because T::FooT = usize is clonable.let baz = Baz::<S>{baz:Bar{bar:0}};
baz.clone();}
error[E0599]: no method named `clone` found for type `Baz<main::S>` in the current scope
--> src/main.rs:23:9
|
11 | struct Baz<T: Foo> {
| ------------------ method `clone` not found for this
...
23 | baz.clone();
| ^^^^^
|
= note: the method `clone` exists but the following trait bounds were not satisfied:
`Baz<main::S> : std::clone::Clone`
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `clone`, perhaps you need to implement it:
candidate #1: `std::clone::Clone`
This fails to compile on 1.25.0.
This seems similar to rust-lang/rust#31518, but if we change
Serialize
toClone
it would work.The text was updated successfully, but these errors were encountered: