Skip to content

Building SQLx with -Z features fails #526

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

Closed
jplatte opened this issue Jul 16, 2020 · 7 comments
Closed

Building SQLx with -Z features fails #526

jplatte opened this issue Jul 16, 2020 · 7 comments

Comments

@jplatte
Copy link
Contributor

jplatte commented Jul 16, 2020

Here's what I've found fails:

  • cargo build -Z features=all
  • cargo build -Z features=all --no-default-features --features runtime-async-std,migrate
  • cargo build -Z features=all --no-default-features --features runtime-async-std,any

I haven't (yet) been able to surface this just compiling sqlx-core.

@jplatte
Copy link
Contributor Author

jplatte commented Jul 16, 2020

Okay, I think I've found the pattern: This happens whenever the async-std runtime is enabled (none of the other runtimes have this issue) and at least some additional features are used (migrate and any work, others may too).

I think what must be happening here is that sqlx is using some feature(s) without activating its feature flag, but with the old feature resolver they are enabled through a build or dev dependency. The actix and tokio runtimes apparently also enable this feaure, but the async-std runtime does not.

@jplatte
Copy link
Contributor Author

jplatte commented Jul 16, 2020

Error:

   Compiling sqlx-core v0.4.0-pre (/home/jplatte/Projekte/_work/sqlx/sqlx-core)
error[E0599]: no method named `send` found for struct `futures_channel::mpsc::Sender<std::result::Result<T, error::Error>>` in the current scope
   --> sqlx-core/src/ext/async_stream.rs:29:32
    |
29  |                 let _ = sender.send(Err(error)).await;
    |                                ^^^^ method not found in `futures_channel::mpsc::Sender<std::result::Result<T, error::Error>>`
    | 
   ::: /home/jplatte/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-channel-0.3.5/src/mpsc/mod.rs:125:1
    |
125 | pub struct Sender<T>(Option<BoundedSenderInner<T>>);
    | ----------------------------------------------------
    | |
    | doesn't satisfy `_: futures_util::SinkExt<_>`
    | doesn't satisfy `_: futures_util::sink::Sink<_>`
    |
    = note: the method `send` exists but the following trait bounds were not satisfied:
            `futures_channel::mpsc::Sender<std::result::Result<T, error::Error>>: futures_util::sink::Sink<_>`
            which is required by `futures_channel::mpsc::Sender<std::result::Result<T, error::Error>>: futures_util::SinkExt<_>`
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use futures_util::sink::SinkExt;`

error[E0277]: the trait bound `futures_channel::mpsc::Sender<std::result::Result<_, error::Error>>: futures_util::sink::Sink<_>` is not satisfied
   --> sqlx-core/src/ext/async_stream.rs:66:29
    |
66  |                     let _ = futures_util::sink::SinkExt::send(&mut sender, Ok($v)).await;
    |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `futures_util::sink::Sink<_>` is not implemented for `futures_channel::mpsc::Sender<std::result::Result<_, error::Error>>`
    | 
   ::: /home/jplatte/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/sink/mod.rs:208:21
    |
208 |         where Self: Unpin,
    |                     ----- required by this bound in `futures_util::SinkExt::send`
    | 
   ::: sqlx-core/src/pool/executor.rs:32:17
    |
32  |                 r#yield!(v);
    |                 ------------ in this macro invocation
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `futures_channel::mpsc::Sender<std::result::Result<_, error::Error>>: futures_util::sink::Sink<std::result::Result<either::Either<<DB as database::Database>::Done, <DB as database::Database>::Row>, _>>` is not satisfied
  --> sqlx-core/src/ext/async_stream.rs:66:29
   |
66 |                     let _ = futures_util::sink::SinkExt::send(&mut sender, Ok($v)).await;
   |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `futures_util::sink::Sink<std::result::Result<either::Either<<DB as database::Database>::Done, <DB as database::Database>::Row>, _>>` is not implemented for `futures_channel::mpsc::Sender<std::result::Result<_, error::Error>>`
   | 
  ::: sqlx-core/src/pool/executor.rs:32:17
   |
32 |                 r#yield!(v);
   |                 ------------ in this macro invocation
   |
   = note: required because of the requirements on the impl of `futures_core::Future` for `futures_util::sink::Send<'_, futures_channel::mpsc::Sender<std::result::Result<_, error::Error>>, std::result::Result<either::Either<<DB as database::Database>::Done, <DB as database::Database>::Row>, _>>`
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `futures_channel::mpsc::Sender<std::result::Result<_, error::Error>>: futures_util::sink::Sink<_>` is not satisfied
   --> sqlx-core/src/ext/async_stream.rs:66:29
    |
66  |                       let _ = futures_util::sink::SinkExt::send(&mut sender, Ok($v)).await;
    |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `futures_util::sink::Sink<_>` is not implemented for `futures_channel::mpsc::Sender<std::result::Result<_, error::Error>>`
    | 
   ::: /home/jplatte/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/sink/mod.rs:208:21
    |
208 |           where Self: Unpin,
    |                       ----- required by this bound in `futures_util::SinkExt::send`
    | 
   ::: sqlx-core/src/query.rs:249:17
    |
249 | /                 r#yield!(match v {
250 | |                     Either::Left(v) => Either::Left(v),
251 | |                     Either::Right(row) => {
252 | |                         Either::Right((self.mapper)(row)?)
253 | |                     }
254 | |                 });
    | |___________________- in this macro invocation
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `futures_channel::mpsc::Sender<std::result::Result<_, error::Error>>: futures_util::sink::Sink<std::result::Result<either::Either<<DB as database::Database>::Done, O>, _>>` is not satisfied
   --> sqlx-core/src/ext/async_stream.rs:66:29
    |
66  |                       let _ = futures_util::sink::SinkExt::send(&mut sender, Ok($v)).await;
    |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `futures_util::sink::Sink<std::result::Result<either::Either<<DB as database::Database>::Done, O>, _>>` is not implemented for `futures_channel::mpsc::Sender<std::result::Result<_, error::Error>>`
    | 
   ::: sqlx-core/src/query.rs:249:17
    |
249 | /                 r#yield!(match v {
250 | |                     Either::Left(v) => Either::Left(v),
251 | |                     Either::Right(row) => {
252 | |                         Either::Right((self.mapper)(row)?)
253 | |                     }
254 | |                 });
    | |___________________- in this macro invocation
    |
    = note: required because of the requirements on the impl of `futures_core::Future` for `futures_util::sink::Send<'_, futures_channel::mpsc::Sender<std::result::Result<_, error::Error>>, std::result::Result<either::Either<<DB as database::Database>::Done, O>, _>>`
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `futures_channel::mpsc::Sender<std::result::Result<_, error::Error>>: futures_util::sink::Sink<_>` is not satisfied
   --> sqlx-core/src/ext/async_stream.rs:66:29
    |
66  |                       let _ = futures_util::sink::SinkExt::send(&mut sender, Ok($v)).await;
    |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `futures_util::sink::Sink<_>` is not implemented for `futures_channel::mpsc::Sender<std::result::Result<_, error::Error>>`
    | 
   ::: /home/jplatte/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.5/src/sink/mod.rs:208:21
    |
208 |           where Self: Unpin,
    |                       ----- required by this bound in `futures_util::SinkExt::send`
    | 
   ::: sqlx-core/src/query_as.rs:89:17
    |
89  | /                 r#yield!(match v {
90  | |                     Either::Left(v) => Either::Left(v),
91  | |                     Either::Right(row) => Either::Right(O::from_row(&row)?),
92  | |                 });
    | |___________________- in this macro invocation
    |
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `futures_channel::mpsc::Sender<std::result::Result<_, error::Error>>: futures_util::sink::Sink<std::result::Result<either::Either<<DB as database::Database>::Done, O>, _>>` is not satisfied
  --> sqlx-core/src/ext/async_stream.rs:66:29
   |
66 |                       let _ = futures_util::sink::SinkExt::send(&mut sender, Ok($v)).await;
   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `futures_util::sink::Sink<std::result::Result<either::Either<<DB as database::Database>::Done, O>, _>>` is not implemented for `futures_channel::mpsc::Sender<std::result::Result<_, error::Error>>`
   | 
  ::: sqlx-core/src/query_as.rs:89:17
   |
89 | /                 r#yield!(match v {
90 | |                     Either::Left(v) => Either::Left(v),
91 | |                     Either::Right(row) => Either::Right(O::from_row(&row)?),
92 | |                 });
   | |___________________- in this macro invocation
   |
   = note: required because of the requirements on the impl of `futures_core::Future` for `futures_util::sink::Send<'_, futures_channel::mpsc::Sender<std::result::Result<_, error::Error>>, std::result::Result<either::Either<<DB as database::Database>::Done, O>, _>>`
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unused import: `SinkExt`
 --> sqlx-core/src/ext/async_stream.rs:8:40
  |
8 | use futures_util::{pin_mut, FutureExt, SinkExt};
  |                                        ^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error: aborting due to 7 previous errors; 1 warning emitted

Some errors have detailed explanations: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `sqlx-core`.

To learn more, run the command again with --verbose.

@mehcode
Copy link
Member

mehcode commented Jul 17, 2020

this almost looks like a bug in Cargo

    | doesn't satisfy `_: futures_util::SinkExt<_>`
    | doesn't satisfy `_: futures_util::sink::Sink<_>`
    |
    = note: the method `send` exists but the following trait bounds were not satisfied:
            `futures_channel::mpsc::Sender<std::result::Result<T, error::Error>>: futures_util::sink::Sink<_>`
            which is required by `futures_channel::mpsc::Sender<std::result::Result<T, error::Error>>: futures_util::SinkExt<_>`
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use futures_util::sink::SinkExt;`

and two versions of futures-util are definitely not in play

@mehcode
Copy link
Member

mehcode commented Jul 17, 2020

I dug a little bit. The impl of Send for futures_channel::mpsc::Sender is only gated on a sink feature in futures-channel. That's globally enabled in sqlx-core.

@jplatte
Copy link
Contributor Author

jplatte commented Jul 17, 2020

I guess one needs to build with --verbose to see what features flags are being passed.

this almost looks like a bug in Cargo

Seems plausible considering what you found and the fact the error is in sqlx-core but I haven't (so far) found a way of triggering it without telling cargo to build the main sqlx crate.

@jplatte
Copy link
Contributor Author

jplatte commented Dec 7, 2020

This seems to still be happening, but with different errors. This time I'm not sure it's a Cargo issue. But if it is, should maybe mention it on the tracking issue for the new feature resolver (rust-lang/rfcs#2957) which is now in FCP.

@jplatte
Copy link
Contributor Author

jplatte commented Jan 14, 2021

I can't reproduce this anymore, even by checking out an old version of SQLx.

@jplatte jplatte closed this as completed Jan 14, 2021
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

2 participants