Skip to content

Strange error suggestions when deriving Diffus #104

@taladar

Description

@taladar

I am trying to derive Diffus on the following data type

#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Diffus)]
  struct LDAPEntry {
      dn: String,
      attrs: HashMap<String, Vec<String>>,
      bin_attrs: HashMap<String, Vec<Vec<u8>>>,
  }

which gives me some strange suggestions in the error it produces (on Rust 1.57.0)

error[E0277]: the trait bound `std::string::String: Same` is not satisfied
  --> src/bin/sync_ldap_subtree.rs:58:56
   |
58 | #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Diffus)]
   |                                                        ^^^^^^ the trait `Same` is not implemented for `std::string::String`
   |
   = note: required because of the requirements on the impl of `Diffable<'_>` for `Vec<std::string::String>`
   = note: 1 redundant requirement hidden
   = note: required because of the requirements on the impl of `Diffable<'diffus_a>` for `HashMap<std::string::String, Vec<std::string::String>>`
   = note: required because it appears within the type `diffus::edit::Edit<'diffus_a, HashMap<std::string::String, Vec<std::string::String>>>`
   = note: only the last field of a struct may have a dynamically sized type
   = help: change the field's type to have a statically known size
   = note: this error originates in the derive macro `Diffus` (in Nightly builds, run with -Z macro-backtrace for more info)
help: borrowed types always have a statically known size
   |
58 | #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, &Diffus)]
   |                                                        +
help: the `Box` type always has a statically known size and allocates its contents in the heap
   |
58 | #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Box<Diffus>)]
   |                                                        ++++      +

error[E0277]: the trait bound `Vec<u8>: Same` is not satisfied
  --> src/bin/sync_ldap_subtree.rs:58:56
   |
58 | #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Diffus)]
   |                                                        ^^^^^^ the trait `Same` is not implemented for `Vec<u8>`
   |
   = note: required because of the requirements on the impl of `Diffable<'_>` for `Vec<Vec<u8>>`
   = note: 1 redundant requirement hidden
   = note: required because of the requirements on the impl of `Diffable<'diffus_a>` for `HashMap<std::string::String, Vec<Vec<u8>>>`
note: required by a bound in `diffus::edit::Edit`
  --> /home/taladar/.cargo/registry/src/github.com-1ecc6299db9ec823/diffus-0.10.0/src/edit/mod.rs:11:22
   |
11 | pub enum Edit<'a, T: Diffable<'a> + ?Sized> {
   |                      ^^^^^^^^^^^^ required by this bound in `diffus::edit::Edit`
   = note: this error originates in the derive macro `Diffus` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0277`.

I am reasonably sure that neither &Diffus nor Box make sense in the derive macro parameters?

Changing it to &Diffus experimentally yields

error: expected unsuffixed literal or identifier, found `&`
  --> src/bin/sync_ldap_subtree.rs:58:56
   |
58 | #[derive(Debug, Serialize, Deserialize, PartialEq, Eq, &Diffus)]
   |                                                        ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions