A dependency compiles on it's own, but does not compile as dependency (lettre & nom)


#1

Hello there.

I was just in need to update my dependencies — two days ago — and keep struggling, after one dependency does not compile anymore. It’s one of the dependencies, that was not updated. So I can’t get, why it’s not compiling anymore.
I already investigated via #rust on IRC and the Gitter channels of the repos, but it seems, nobody could help me to fix it.

The dependency, that does not compile: lettre=0.8.2 is struggling with nom=3.2.1.

my rust-version

(last nightly that has no problems with diesel.rs)

❯ rustup default nightly-2018-05-14
info: using existing install for 'nightly-2018-05-14-x86_64-unknown-linux-gnu'
info: default toolchain set to 'nightly-2018-05-14-x86_64-unknown-linux-gnu'

  nightly-2018-05-14-x86_64-unknown-linux-gnu unchanged - rustc 1.27.0-nightly (9fae15374 2018-05-13)

the errors

(tried with lettre=0.8.2 and via git checkout (=0.9.0) — the errors stays the same)

❯ RUST_BACKTRACE=full cargo run
   Compiling lettre v0.9.0 (https://github.com/lettre/lettre#e225afbe)
error[E0432]: unresolved import `nom::simple_errors`
 --> /home/sblei/.cargo/git/checkouts/lettre-53652803723a9045/e225afb/lettre/src/smtp/response.rs:4:10
  |
4 | use nom::simple_errors::Err as NomError;
  |          ^^^^^^^^^^^^^ Could not find `simple_errors` in `nom`

error[E0433]: failed to resolve. Could not find `simple_errors` in `nom`
  --> /home/sblei/.cargo/git/checkouts/lettre-53652803723a9045/e225afb/lettre/src/smtp/error.rs:40:18
   |
40 |     Parsing(nom::simple_errors::Err),
   |                  ^^^^^^^^^^^^^ Could not find `simple_errors` in `nom`

error[E0433]: failed to resolve. Could not find `simple_errors` in `nom`
  --> /home/sblei/.cargo/git/checkouts/lettre-53652803723a9045/e225afb/lettre/src/smtp/error.rs:98:16
   |
98 | impl From<nom::simple_errors::Err> for Error {
   |                ^^^^^^^^^^^^^ Could not find `simple_errors` in `nom`

error[E0433]: failed to resolve. Could not find `simple_errors` in `nom`
  --> /home/sblei/.cargo/git/checkouts/lettre-53652803723a9045/e225afb/lettre/src/smtp/error.rs:99:23
   |
99 |     fn from(err: nom::simple_errors::Err) -> Error {
   |                       ^^^^^^^^^^^^^ Could not find `simple_errors` in `nom`

error[E0119]: conflicting implementations of trait `std::convert::From<[type error]>` for type `smtp::error::Error`:
   --> /home/sblei/.cargo/git/checkouts/lettre-53652803723a9045/e225afb/lettre/src/smtp/error.rs:104:1
    |
98  | impl From<nom::simple_errors::Err> for Error {
    | -------------------------------------------- first implementation here
...
104 | impl From<DecodeError> for Error {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `smtp::error::Error`

error[E0119]: conflicting implementations of trait `std::convert::From<[type error]>` for type `smtp::error::Error`:
   --> /home/sblei/.cargo/git/checkouts/lettre-53652803723a9045/e225afb/lettre/src/smtp/error.rs:110:1
    |
98  | impl From<nom::simple_errors::Err> for Error {
    | -------------------------------------------- first implementation here
...
110 | impl From<FromUtf8Error> for Error {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `smtp::error::Error`

                               at libstd/panicking.rs:289
                            error[E0119]: conflicting implementations of trait `std::convert::From<[type error]>` for type `smtp::error::Error`:
   --> /home/sblei/.cargo/git/checkouts/lettre-53652803723a9045/e225afb/lettre/src/smtp/error.rs:116:1
    |
98  | impl From<nom::simple_errors::Err> for Error {
    | -------------------------------------------- first implementation here
...
116 | impl From<Response> for Error {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `smtp::error::Error`
   at
libstd/panic.rs:374
                               at libstd/rt.rs:58
  86:     0x55d12eb2cbb3 - mainerror[E0119]: conflicting implementations of trait `std::convert::From<[type error]>` for type `smtp::error::Error`:
   --> /home/sblei/.cargo/git/checkouts/lettre-53652803723a9045/e225afb/lettre/src/smtp/error.rs:126:1
    |
98  | impl From<nom::simple_errors::Err> for Error {
    | -------------------------------------------- first implementation here
...
126 | impl From<&'static str> for Error {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `smtp::error::Error`

lettre does compile on it’s own:

❯ cd /home/sblei/.cargo/git/checkouts/lettre-53652803723a9045/e225afb/lettre/

~/.cargo/git/checkouts/lettre-53652803723a9045/e225afb/lettre master*
❯ cargo build --all-features
   Compiling pkg-config v0.3.11
   Compiling unicode-xid v0.0.4
   Compiling cc v1.0.17
   Compiling unicode-xid v0.1.0
   Compiling quote v0.3.15
   Compiling libc v0.2.42
   Compiling openssl v0.9.24
   Compiling serde v1.0.66
   Compiling foreign-types-shared v0.1.1
   Compiling cfg-if v0.1.3
   Compiling bitflags v0.9.1
   Compiling lazy_static v1.0.1
   Compiling rustc-demangle v0.1.8
   Compiling safemem v0.2.0
   Compiling byteorder v1.2.3
   Compiling itoa v0.4.1
   Compiling lazy_static v0.2.11
   Compiling dtoa v0.4.2
   Compiling bufstream v0.1.3
   Compiling synom v0.11.3
   Compiling proc-macro2 v0.4.6
   Compiling memchr v1.0.2
   Compiling hostname v0.1.5
   Compiling backtrace-sys v0.1.23
   Compiling openssl-sys v0.9.33
   Compiling foreign-types v0.3.2
   Compiling log v0.4.2
   Compiling base64 v0.9.2
   Compiling nom v3.2.1
   Compiling syn v0.11.11
   Compiling quote v0.6.3
   Compiling syn v0.14.2
   Compiling backtrace v0.3.8
   Compiling synstructure v0.6.1
   Compiling failure_derive v0.1.1
   Compiling serde_derive v1.0.66
   Compiling native-tls v0.1.5
   Compiling failure v0.1.1
   Compiling serde_json v1.0.20
   Compiling lettre v0.9.0 (file:///home/sblei/.cargo/git/checkouts/lettre-53652803723a9045/e225afb/lettre)
    Finished dev [unoptimized + debuginfo] target(s) in 22.16s

dependencies

~/.cargo/git/checkouts/lettre-53652803723a9045/e225afb/lettre master*
❯ cargo tree | ag \ nom
├── nom v3.2.1
~/Projects/macsi-rust-api develop*
❯ cargo tree | ag \ nom
│   ├── nom v3.2.1
├── nom v3.2.1 (*)

What I’ve tried so far to fix this:

I was trying to add nom=3.2.1 as dependency to my Cargo.toml, also with all features activated. But no luck. The errors keeps the same.

Then I’ve switched the nightly version — it keeps the same.

Cleaned cargo builds & cleaned the .cargo/registry — still the same.

I’ve imported nom::simple_errors::* in my own crate — just no import error.


I hope, this was enough information, so anybody could help.
Maybe, I’ve missed something to say or to do. But I do not know anymore.

Thanks in advance for your help.
Sebastian


#2

Anyone could help? The problem still exists. :man_mechanic:


#3

This is a bug in nom – its “verbose-errors” Cargo cfg is not additive. I found this filed as Geal/nom#544. Unclear why it was closed recently because I don’t think the problem has been fixed. @geal


#4

Thanks so far. Then, I will try to downgrade the used lettre version or fork the repo and try to use another nom version.


#5

See my response here https://github.com/lettre/lettre/issues/298#issuecomment-400664149

This is an issue with nom v3 and conflicting dependencies that use nom v3 (conflicting = one uses simple_errors while another forces and uses verbose_errors). I believe nom v4 has a common/additive interface now that will not result in conflicts should one dependency ask for simple_errors and another ask for verbose_errors.


#6

This may be easier to work around in v4 but is not fixed. Here is the same non-additive bug at the 4.0.0 tag: