TimelyDataflow / abomonation

A mortifying serialization library for Rust
MIT License
322 stars 30 forks source link

potential issue with unsafe_abomonate! on latest version #10

Closed sga001 closed 6 years ago

sga001 commented 6 years ago

Code very similar to the following works with Abomonation version 0.4.5 but not with 0.5:

#[macro_use]
extern crate abomonation;
extern crate timely;

use timely::dataflow::InputHandle;
use abomonation::Abomonation;

pub struct Foo {
  x: Vec<u8>,
  y: Vec<u8>,
}

pub struct Bar {
  z: Vec<u8>,
}

pub struct Baz {
  foo: Foo,
  bar: Bar,
}

unsafe_abomonate!(Foo: x, y);
unsafe_abomonate!(Bar: z);
unsafe_abomonate!(Baz: foo, bar);

fn main() {
  let input: InputHandle<u64, Baz> = InputHandle::new();
  // do other stuff
}

In version 0.5 I get the error: "the trait bound Baz: abomonation::Abomonation is not satisfied the trait abomonation::Abomonation is not implemented for Baz.

note: required because of the requirements of the impl of Timely::Data for Baz note: required by timely::dataflow::Handle"

Did anything change in the way unsafe_abomonate work? I noticed you removed a generics parameter, but I'm not sure if that has any effect here.

frankmcsherry commented 6 years ago

Hrm. unsafe_abomonate did change in that the trait changed (so it synthesizes new methods). But ...

Usually when I see this error, it translates to "you are using two versions of the crate, and while you implement the trait from one, I wanted the trait from the other". Is it possible that this is going on? Usually a cargo update will fix that (perhaps with a few cargo clean just to be sure).

Though, if you are using timely from crates.io it should still target Abom 0.4. and will not be 0.5. compatible until we drop a new timely release on crates; if you are using timely from github master, it should be pointing at github abom master; neither of these are crates 0.5, and so it may be that is where the tangle is (until timely gets a crates.io bump, or we pivot timely gh to point at crates, there is no use for abom 0.5 yet). This is all blocked on a new drop of abomonate_derive coming out, which we don't own (owner thinks early this week). Ideally nothing should pick up abom 0.5 "by accident" as it has an incompatible semver, but I may have screwed that up in various files.

Do any of these sound likely? If still not, I can try and reproduce if you have a Cargo.toml to go along with the above code.

sga001 commented 6 years ago

You are right. The two different versions of the crate appears to be the issue. Thanks.