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

error[E0119]: conflicting implementations of trait bitflags::<unnamed>::convert::From<&_> for type types::to_sql::ToSqlOutput<'_> #313

Closed
mingjunyang opened this issue Nov 28, 2017 · 9 comments · Fixed by #352

Comments

@mingjunyang
Copy link

# rustc --version
rustc 1.24.0-nightly (560a5da9f 2017-11-27)

# cargo --version 
cargo 0.24.0-nightly (abd137ad1 2017-11-12)
[lib]
name = "xxxx"
path = "src/lib.rs"
# crate-type = ["dylib"]

[build-dependencies]

[dependencies]
log = "0.3"
env_logger = "0.4"
futures = "0.1"
hyper = "0.11"
hyper-tls="0.1"
tokio-core = "0.1"
tokio-io = "0.1"
tokio-tls="0.1"
websocket = "0.20"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
url= "1.4"
regex = "0.2"
uuid = { version = "0.4", features = ["serde", "v4"] }
encoding = "0.2"
chrono = { version = "0.4", features = ["serde", "rustc-serialize"] }
select = "0.4"

[dependencies.rusqlite]
version = "0.13"
features = ["bundled"]

[features]
default = []

Error message

 Compiling websocket v0.20.2
   Compiling rusqlite v0.13.0
error[E0119]: conflicting implementations of trait `bitflags::<unnamed>::convert::From<&_>` for type `types::to_sql::ToSqlOutput<'_>`:
  --> $HOME/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/rusqlite-0.13.0/src/types/to_sql.rs:26:1
   |
18 | / impl<'a, T: ?Sized> From<&'a T> for ToSqlOutput<'a>
19 | |     where &'a T: Into<ValueRef<'a>>
20 | | {
21 | |     fn from(t: &'a T) -> Self {
22 | |         ToSqlOutput::Borrowed(t.into())
23 | |     }
24 | | }
   | |_- first implementation here
25 | 
26 | / impl<'a, T: Into<Value>> From<T> for ToSqlOutput<'a> {
27 | |     fn from(t: T) -> Self {
28 | |         ToSqlOutput::Owned(t.into())
29 | |     }
30 | | }
   | |_^ conflicting implementation for `types::to_sql::ToSqlOutput<'_>`

error: aborting due to previous error

error: Could not compile `rusqlite`.
warning: build failed, waiting for other jobs to finish...
error: build failed

@SergioBenitez
Copy link

This also affects v0.12. This appears to be caused by a change in the latest nightly; the issue does not occur with older nightlies.

@SergioBenitez
Copy link

This will be fixed by rust-lang/rust#46329. Note, however, that it appears that these two implementations will eventually result in an error.

@mingjunyang
Copy link
Author

I update rust

rustc 1.24.0-nightly (73bca2b9f 2017-11-28)

this issuse is fixed.

@arielb1
Copy link

arielb1 commented Dec 4, 2017

@jgallagher

This is a soundness issue that will eventually become a hard error. How hard would it be for you to avoid this pattern?

@jgallagher
Copy link
Contributor

I'm not sure? Sorry, having a hard time understanding what the issue is exactly. I can remove one of the impls without affecting this crate, but don't know if that would break something downstream.

@arielb1
Copy link

arielb1 commented Dec 6, 2017

@jgallagher

The problem is that anyone could implement a type satisfying &'a MyType: Into<ValueRef<'a>> and &'a MyType: Into<Value>, which would then cause your impls to collide.

The coherence rules do not allow you to leave a "coherence minefield" for descendant crates, where them implementing traits that you do not own for types that you do not own will cause their dependencies' impls to explode, so your impls can't be allowed.

Because of a bug in rustc, your impls were allowed, so a downstream crate could cause an impl overlap and associated badness. I'm not sure what is the best way to fix this - I'm just telling you that your code can cause soundness problems downstream.

@jgallagher
Copy link
Contributor

Ah, thanks for the explanation. I misspoke earlier - I cannot remove one of the impls without making other changes. Is the right way to fix this to remove one of the impls and add explicit impls for concrete types for the other one, a la aa64e2f?

@arielb1
Copy link

arielb1 commented Dec 6, 2017

@jgallagher

Anything that will avoid errors with the most recent nightly is OK.

@traviscross
Copy link
Contributor

The fix in aa64e2f looks correct and reasonable to me.

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

Successfully merging a pull request may close this issue.

5 participants