Skip to content

Number of compilation errors using select! macro #1404

@Thomasdezeeuw

Description

@Thomasdezeeuw

I've tried version "0.3.0-alpha.11" and master at commit 8479bd2.

// Both these values implement `Future` and `FusedFuture`:
let mut timeout = Timer::timeout(&mut ctx, Duration::from_millis(100)).fuse();
let mut msg_future = ctx.receive().fuse();

select! {
    msg = msg_future => println!("Got a message: {}", msg),
    _ = timeout => {
        println!("Getting impatient!");
        return;
    },
};

It causes the following compilation errors.

error[E0433]: failed to resolve: could not find `FusedFuture` in `future`
  --> src/actor/context.rs:87:9
   |
25 | /         select! {
26 | |             msg = msg_future => println!("Got a message: {}", msg),
27 | |             _ = timeout => {
28 | |                 println!("Getting impatient!");
29 | |                 continue;
30 | |             },
31 | |         };
   | |__________^ could not find `FusedFuture` in `future`
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0433]: failed to resolve: could not find `Poll` in `task`
  --> src/actor/context.rs:87:9
   |
25 | /         select! {
26 | |             msg = msg_future => println!("Got a message: {}", msg),
27 | |             _ = timeout => {
28 | |                 println!("Getting impatient!");
29 | |                 continue;
30 | |             },
31 | |         };
   | |__________^ could not find `Poll` in `task`
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0412]: cannot find type `LocalWaker` in module `futures_util::task`
  --> src/actor/context.rs:87:9
   |
25 | /         select! {
26 | |             msg = msg_future => println!("Got a message: {}", msg),
27 | |             _ = timeout => {
28 | |                 println!("Getting impatient!");
29 | |                 continue;
30 | |             },
31 | |         };
   | |__________^ did you mean `LocalWakerRef`?
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
help: possible candidates are found in other modules, you can import them into scope
   |
5  | use core::task::LocalWaker;
   |
5  | use futures_core::task::LocalWaker;
   |
5  | use futures_util::core_reexport::task::LocalWaker;
   |
5  | use std::task::LocalWaker;
   |

error[E0412]: cannot find type `Poll` in module `futures_util::task`
  --> src/actor/context.rs:87:9
   |
25 | /         select! {
26 | |             msg = msg_future => println!("Got a message: {}", msg),
27 | |             _ = timeout => {
28 | |                 println!("Getting impatient!");
29 | |                 continue;
30 | |             },
31 | |         };
   | |__________^ not found in `futures_util::task`
   |
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
help: possible candidates are found in other modules, you can import them into scope
   |
5  | use core::task::Poll;
   |
5  | use futures_core::Poll;
   |
5  | use futures_core::task::Poll;
   |
5  | use futures_util::core_reexport::task::Poll;
   |
and 1 other candidates

error[E0277]: the size for values of type `[_]` cannot be known at compilation time
  --> src/actor/context.rs:87:9
   |
25 | /         select! {
26 | |             msg = msg_future => println!("Got a message: {}", msg),
27 | |             _ = timeout => {
28 | |                 println!("Getting impatient!");
29 | |                 continue;
30 | |             },
31 | |         };
   | |__________^ doesn't have a size known at compile-time
   |
   = help: the trait `std::marker::Sized` is not implemented for `[_]`
   = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
   = note: all local variables must have a statically known size
   = help: unsized locals are gated as an unstable feature
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

I'm a little lost as to what is wrong with the code. Also the code did work with version "0.3.0-alpha.10", but I rewrote it for alpha 11 and can't figure these errors out.

Any help would be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions