Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make this crate compatible with embedded-hal master #1

Closed
eldruin opened this issue Sep 30, 2018 · 11 comments
Closed

Make this crate compatible with embedded-hal master #1

eldruin opened this issue Sep 30, 2018 · 11 comments

Comments

@eldruin
Copy link
Contributor

eldruin commented Sep 30, 2018

Hi,
I ran into a compilation problem when using this crate with the embedded-hal master version.
In my pcf857x crate, if changing the embedded-hal dependency in the Cargo.toml file to:

embedded-hal = { git = "https://github.com/rust-embedded/embedded-hal" }

The tests cannot be run as the compiler complains that the prelude::Read and prelude::Write trait bounds were not satisfied.
Am I doing something wrong or is this crate incompatible with embedded-hal master?
There were some changes to embedded-hal's prelude. Could this be the cause?

PS: Thanks for this crate! I use it all the time :)

@dbrgn
Copy link
Owner

dbrgn commented Oct 3, 2018

Hi. I'm just back from vacations. I need a few days to clear my backlog and will revisit this issue later on.

At first glance, the problem is that your project depends on embedded-hal@master while the mock crate depends on embedded-hal@0.2. Even if the traits are compatible feature-wise, different versions are incompatible by design. I think a feature flag that uses master instead of a released version would help, although I'm not sure if that can be released to crates.io.

@dbrgn
Copy link
Owner

dbrgn commented Oct 16, 2018

I don't think crates with dependency to non-published crates can be published.

I'm not sure what the best way to implement this would be. Maybe I'll maintain a next branch that points to master and that can be used directly from Cargo.toml using a git dependency.

@ryankurte
Copy link
Collaborator

Will this still be an issue when we've released embedded-hal v0.3.0 and updated this to point at it?

@dbrgn
Copy link
Owner

dbrgn commented Oct 16, 2018

As long as people use the master version of embedded-hal, I think yes.

The dependency tree looks like this:

a
|- embedded-hal@master
|- embedded-hal-mock@0.4.0
   |- embedded-hal@0.3.0

This means that there are two versions of embedded-hal. The traits implemented by embedded-hal-mock for embedded-hal@0.3.0 are not compatible with the traits provided by embedded-hal@master, even if their source code is identical.

Of course if both @eldruin and we use the released embedded-hal 0.3.0, then it's going to work.

@eldruin
Copy link
Contributor Author

eldruin commented Oct 17, 2018

The traits implemented by embedded-hal-mock for embedded-hal@0.3.0 are not compatible with the traits provided by embedded-hal@master, even if their source code is identical.

This is quite unfortunate and I did not know about it, although I can understand the reasoning now.
I would like to release a new version of my crate once embedded-hal 0.3.0 is out, since the changes in that version address issues which arose in the pcf857x crate.
I do not need embedded-hal@master, I was just trying to test my crate against the new embedded-hal trait versions.
It would be great for me if a new version of embedded-hal-mock would be published using embedded-hal 0.3.0 once it is available.

@dbrgn
Copy link
Owner

dbrgn commented Oct 17, 2018

It would be great for me if a new version of embedded-hal-mock would be published using embedded-hal 0.3.0 once it is available.

That's the plan of course - we track embedded-hal releases 🙂

For development, would it help you if we had a branch called "next" that has a dependency on embedded-hal@master?

@eldruin
Copy link
Contributor Author

eldruin commented Oct 17, 2018

I think it would. At least I would have a better alternative to test something in embedded-hal@master than to clone this crate locally, modify it and use that.
However, I do not know how often this situation would come up.

@dbrgn dbrgn closed this as completed in d1c7248 Oct 17, 2018
@ryankurte
Copy link
Collaborator

@eldruin can you use a patch in your top level Cargo.yml file to achieve this?

[patch.crates-io]
embedded-hal-mock = { git = https://github.com/dbrgn/embedded-hal-mock }

If that / something similar works maybe we could document it for others too.

@dbrgn
Copy link
Owner

dbrgn commented Nov 6, 2018

Actually I created a branch, see d1c7248!

@ryankurte
Copy link
Collaborator

Oops, sorry, that should be:

[patch.crates-io]
embedded-hal = { git = "https://github.com/rust-embedded/embedded-hal" }

@dbrgn the branch works too, I was recently introduced to this / thought I would share the cargo way.

@dbrgn
Copy link
Owner

dbrgn commented Nov 8, 2018

Ahh I see, I didn't realize that it was in a patch section 🙂

Yes, that should work, and it's probably a better solution than the branch - as long as there are no breaking changes in embedded-hal 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants