Compile error with crossbeam-channel
cjbassi opened this issue · comments
Caleb Bassi commented
Minimal reproducible example:
// main.rs
#![feature(async_await)]
use std::time::Duration;
use crossbeam_channel::{select, tick};
async fn foo() {}
#[runtime::main]
async fn main() {
let ticker1 = tick(Duration::from_secs(1));
let ticker2 = tick(Duration::from_secs(1));
select! {
recv(ticker1) -> _ => {
foo().await;
}
recv(ticker2) -> _ => {
}
}
}
// Cargo.toml
[package]
name = "foo"
version = "0.1.0"
edition = "2018"
[dependencies]
crossbeam-channel = "0.3"
runtime = "0.3.0-alpha.6"
Both recv
statements are required. The .await
in either recv
is required. Doesn't error when using #[tokio::main]
instead from tokio master branch. Also errors when doing #[runtime::main(runtime_tokio::Tokio)]
.
Using rustc 1.38.0-nightly (95b1fe560 2019-07-20)
Running: rustup run nightly cargo run
Results in:
error[E0277]: `*const u8` cannot be sent between threads safely
--> src/main.rs:9:1
|
9 | #[runtime::main]
| ^^^^^^^^^^^^^^^^ `*const u8` cannot be sent between threads safely
|
= help: within `impl std::future::Future`, the trait `std::marker::Send` is not implemented for `*const u8`
= note: required because it appears within the type `crossbeam_channel::select::SelectedOperation<'_>`
= note: required because it appears within the type `for<'r, 's, 't0, 't1, 't2, 't3> {crossbeam_channel::channel::Receiver<std::time::Instant>, crossbeam_channel::select::Select<'r>, &'s crossbeam_channel::channel::Receiver<std::time::Instant>, &'t0 crossbeam_channel::channel::Receiver<std::time::Instant>, &'t1 crossbeam_channel::channel::Receiver<std::time::Instant>, &'t2 crossbeam_channel::channel::Receiver<std::time::Instant>, crossbeam_channel::select::SelectedOperation<'t3>, bool, std::result::Result<std::time::Instant, crossbeam_channel::err::RecvError>, impl std::future::Future, ()}`
= note: required because it appears within the type `[static generator@src/main.rs:9:1: 9:17 for<'r, 's, 't0, 't1, 't2, 't3> {crossbeam_channel::channel::Receiver<std::time::Instant>, crossbeam_channel::select::Select<'r>, &'s crossbeam_channel::channel::Receiver<std::time::Instant>, &'t0 crossbeam_channel::channel::Receiver<std::time::Instant>, &'t1 crossbeam_channel::channel::Receiver<std::time::Instant>, &'t2 crossbeam_channel::channel::Receiver<std::time::Instant>, crossbeam_channel::select::SelectedOperation<'t3>, bool, std::result::Result<std::time::Instant, crossbeam_channel::err::RecvError>, impl std::future::Future, ()}]`
= note: required because it appears within the type `std::future::GenFuture<[static generator@src/main.rs:9:1: 9:17 for<'r, 's, 't0, 't1, 't2, 't3> {crossbeam_channel::channel::Receiver<std::time::Instant>, crossbeam_channel::select::Select<'r>, &'s crossbeam_channel::channel::Receiver<std::time::Instant>, &'t0 crossbeam_channel::channel::Receiver<std::time::Instant>, &'t1 crossbeam_channel::channel::Receiver<std::time::Instant>, &'t2 crossbeam_channel::channel::Receiver<std::time::Instant>, crossbeam_channel::select::SelectedOperation<'t3>, bool, std::result::Result<std::time::Instant, crossbeam_channel::err::RecvError>, impl std::future::Future, ()}]>`
= note: required because it appears within the type `impl std::future::Future`
= note: required because it appears within the type `impl std::future::Future`
= note: required because it appears within the type `{impl std::future::Future, ()}`
= note: required because it appears within the type `[static generator@src/main.rs:9:1: 9:17 {impl std::future::Future, ()}]`
= note: required because it appears within the type `std::future::GenFuture<[static generator@src/main.rs:9:1: 9:17 {impl std::future::Future, ()}]>`
= note: required because it appears within the type `impl std::future::Future`
= note: required by `runtime_raw::enter`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
error: Could not compile `foo`.
To learn more, run the command again with --verbose.