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 while compiling: futures_io::if_std::AsyncRead is not implemented for std::io::Empty #84

Closed
chrisdickinson opened this issue Oct 22, 2019 · 5 comments

Comments

@chrisdickinson
Copy link

Hi! I was poking around the Rust async ecosystem out of curiosity, and when I tried to install surf in an empty project I got this error:

   Compiling surf v1.0.2
error[E0277]: the trait bound `std::io::Empty: futures_io::if_std::AsyncRead` is not satisfied
  --> /Users/cdickinson/.cargo/registry/src/github.com-1ecc6299db9ec823/surf-1.0.2/src/http_client/mod.rs:64:21
   |
64 |             reader: Box::new(std::io::empty()),
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `futures_io::if_std::AsyncRead` is not implemented for `std::io::Empty`
   |
   = note: required for the cast to the object type `dyn futures_io::if_std::AsyncRead + std::marker::Send + std::marker::Unpin`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
error: could not compile `surf`.

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

The verbose output is here:

     Running `rustc --edition=2018 --crate-name surf /Users/cdickinson/.cargo/registry/src/github.com-1ecc6299db9ec823/surf-1.0.2/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 --cfg 'feature="curl-client"' --cfg 'feature="default"' --cfg 'feature="isahc"' --cfg 'feature="js-sys"' --cfg 'feature="middleware-logger"' --cfg 'feature="native-client"' --cfg 'feature="wasm-bindgen"' --cfg 'feature="wasm-bindgen-futures"' --cfg 'feature="wasm-client"' --cfg 'feature="web-sys"' -C metadata=1c3e514c0a858c33 -C extra-filename=-1c3e514c0a858c33 --out-dir /Users/cdickinson/projects/personal/ds/target/debug/deps -L dependency=/Users/cdickinson/projects/personal/ds/target/debug/deps --extern futures=/Users/cdickinson/projects/personal/ds/target/debug/deps/libfutures-365de1e9e66eb651.rmeta --extern http=/Users/cdickinson/projects/personal/ds/target/debug/deps/libhttp-bbece310474301d6.rmeta --extern isahc=/Users/cdickinson/projects/personal/ds/target/debug/deps/libisahc-c4452edccdc968ce.rmeta --extern log=/Users/cdickinson/projects/personal/ds/target/debug/deps/liblog-d5fa1487881b71e9.rmeta --extern mime=/Users/cdickinson/projects/personal/ds/target/debug/deps/libmime-6b951b76af8ba87e.rmeta --extern mime_guess=/Users/cdickinson/projects/personal/ds/target/debug/deps/libmime_guess-fba49381eb3931b8.rmeta --extern serde=/Users/cdickinson/projects/personal/ds/target/debug/deps/libserde-600cba9868aa7ea8.rmeta --extern serde_json=/Users/cdickinson/projects/personal/ds/target/debug/deps/libserde_json-12247f39cf48300d.rmeta --extern serde_urlencoded=/Users/cdickinson/projects/personal/ds/target/debug/deps/libserde_urlencoded-9519514955e6e3f5.rmeta --extern url=/Users/cdickinson/projects/personal/ds/target/debug/deps/liburl-691a7168f39f84f4.rmeta --cap-lints allow -L native=/Users/cdickinson/projects/personal/ds/target/debug/build/libnghttp2-sys-d38528ac152f3c05/out/i/lib`
error[E0277]: the trait bound `std::io::Empty: futures_io::if_std::AsyncRead` is not satisfied
  --> /Users/cdickinson/.cargo/registry/src/github.com-1ecc6299db9ec823/surf-1.0.2/src/http_client/mod.rs:64:21
   |
64 |             reader: Box::new(std::io::empty()),
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `futures_io::if_std::AsyncRead` is not implemented for `std::io::Empty`
   |
   = note: required for the cast to the object type `dyn futures_io::if_std::AsyncRead + std::marker::Send + std::marker::Unpin`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
error: could not compile `surf`.

The dep is installed like so:

[dependencies]
surf = "1.0.2"

And my toolchain info is:

→ rustup toolchain list
stable-x86_64-apple-darwin
nightly-2018-12-27-x86_64-apple-darwin
nightly-x86_64-apple-darwin (default)

A quick google didn't turn up any results, so it might be that I'm just holding it wrong! Any pointers would be much appreciated – & thanks for your great work on the async ecosystem 💖

@abreis
Copy link

abreis commented Oct 23, 2019

See issue #73, which was fixed in 29ca24a.

Until a new release of surf comes out with the fix, you can use the git master in your Cargo.toml:

surf = { git = "https://github.com/rustasync/surf" }

@awestlake87
Copy link

You can also lock futures-preview = { version "= 0.3.0-alpha.18" }. That worked for me

@marcelbuesing
Copy link

Would be great to make a new release for this fix

@yoshuawuyts
Copy link
Member

Hi all, sorry for taking a while to respond to this. Putting out a new release today just so thing will work again on stable. Will update this issue once we do. Thanks heaps!

@yoshuawuyts
Copy link
Member

Published 1.0.3 which fixes this problem, and compiles on std. Thanks all!

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

5 participants