Description
I am working on a library which at some point converts a mysql_common::value::Value
to a type DataType
via DataType::try_from(<value>)
. I am using an impl TryFrom<mysql_common::value::Value> for DataType
defined in a separate crate, which worked well initially. However, this other crate has since then bumped up the dependencies, such that my project was now using a version of Value
incompatible to the one used by the other crate.
The compiler complained (see error message) that "the trait std::convert::From<mysql_common::value::Value>
is not implemented for DataType
", and that the conversion was infallible. I think it would have been clearer and easier to debug had the compiler error message rather said that TryFrom
was implemented for a type by the same name but incompatible (different version), rather than fall back on a blanket implementation error message which was deceptive in this case.
Error message
error[E0277]: the trait bound `noria::data::DataType: std::convert::From<mysql_common::value::Value>` is not satisfied
--> src/lib.rs:283:19
|
283 | match DataType::try_from(value) {
| ^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<mysql_common::value::Value>` is not implemented for `noria::data::DataType`
|
= help: the following implementations were found:
<noria::data::DataType as std::convert::From<&'a nom_sql::common::Literal>>
<noria::data::DataType as std::convert::From<&'a noria::data::DataType>>
<noria::data::DataType as std::convert::From<&'a str>>
<noria::data::DataType as std::convert::From<chrono::naive::datetime::NaiveDateTime>>
and 11 others
= note: required because of the requirements on the impl of `std::convert::Into<noria::data::DataType>` for `mysql_common::value::Value`
= note: required because of the requirements on the impl of `std::convert::TryFrom<mysql_common::value::Value>` for `noria::data::DataType`
error[E0308]: mismatched types
--> src/lib.rs:285:77
|
285 | Err(e) => return Err(WriteProxyErr::MysqlToNoriaDatatypeErr(e)),
| ^ expected `&str`, found enum `std::convert::Infallible`
Meta
rustc 1.44.0-nightly (94d3463 2020-04-09)
binary: rustc
commit-hash: 94d3463
commit-date: 2020-04-09
host: x86_64-unknown-linux-gnu
release: 1.44.0-nightly
LLVM version: 9.0