Rust: Compiler suggests to import private trait

Created on 20 Jan 2019  ยท  4Comments  ยท  Source: rust-lang/rust

cargo test --color=always --no-run
   Compiling grip-rust v0.0.4-alpha (/home/alik/CLionProjects/grip/rust)
error[E0603]: module `future` is private
  --> src/networking_queue/mod.rs:46:18
   |
46 | use tokio::util::future::FutureExt;
   |                  ^^^^^^

warning: unused import: `tokio::util::future::FutureExt`
  --> src/networking_queue/mod.rs:46:5
   |
46 | use tokio::util::future::FutureExt;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: #[warn(unused_imports)] on by default

error[E0599]: no method named `timeout` found for type `futures::Map<futures::MapErr<futures::future::Select2<futures::OrElse<futures::Map<futures::AndThen<hyper::client::ResponseFuture, futures::stream::Concat2<hyper::Body>, [closure@src/networking_queue/mod.rs:175:59: 175:95]>, [closure@src/networking_queue/mod.rs:177:54: 180:50 request:_]>, futures::FutureResult<networking_queue::Queue::new::{{closure}}::{{closure}}::{{closure}}::State, ()>, [closure@src/networking_queue/mod.rs:181:58: 183:50]>, futures::OrElse<futures::Map<futures::Receiver<()>, [closure@src/networking_queue/mod.rs:185:58: 185:77]>, futures::FutureResult<networking_queue::Queue::new::{{closure}}::{{closure}}::{{closure}}::State, ()>, [closure@src/networking_queue/mod.rs:186:62: 186:93]>>, [closure@src/networking_queue/mod.rs:188:58: 188:110]>, [closure@src/networking_queue/mod.rs:189:54: 191:50]>` in the current scope
   --> src/networking_queue/mod.rs:192:50
    |
192 |                                                 .timeout(Duration::from_millis(1))
    |                                                  ^^^^^^^
    |
    = 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 tokio::util::future::FutureExt;`

error: aborting due to 2 previous errors

Some errors occurred: E0599, E0603.
For more information about an error, try `rustc --explain E0599`.
error: Could not compile `grip-rust`.

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

Process finished with exit code 101

Version

โฏ rustc --version
rustc 1.32.0 (9fda7c223 2019-01-16)

I'm not sure if code really matters (because error message is self-explanatory), but you can get it here

  1. Compiler suggests to import private trait
  2. Compiler complains that trait is unused, but well.. It is trait which can't be imported in the first place.
A-diagnostics A-lint A-resolve A-traits

Most helpful comment

"language of the gods" seems a bit excessive, but thank you.

All 4 comments

It is fine to get such errors in C++, but not in this language of the gods, so I'm expecting 2 things.

  1. Proper compiler suggestion to import trait, which is reexported somewhere else (In this case use tokio::prelude::FutureExt;)
  2. Compiler should not warn about unused import, which can't be imported

"language of the gods" seems a bit excessive, but thank you.

Point 2 is being tracked in #48244. Since the title of this issue is broad, you may want to rename it to focus on your first point.

Closing in favor of more targeted #26454. The second point has already been fixed.

Was this page helpful?
0 / 5 - 0 ratings