-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-coroutinesArea: CoroutinesArea: CoroutinesA-trait-systemArea: Trait systemArea: Trait systemAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Description
use std::collections::{BTreeMap, HashMap};
use std::sync::Arc;
fn needs_send<T: Send>(_val: T) {}
async fn async_fn_a(_num: u32) {}
async fn async_fn_b(map: Arc<BTreeMap<u32, &'static u32>>) {
for (_i, v) in &*map {
async_fn_a(**v).await;
}
}
async fn async_fn_c(map: Arc<HashMap<u32, &'static u32>>) {
for (_i, v) in &*map {
async_fn_a(**v).await;
}
}
fn main() {
// this works...
let map: Arc<HashMap<u32, &'static u32>> = Arc::new(HashMap::new());
needs_send(async_fn_c(map.clone()));
// but this doesn't
let map: Arc<BTreeMap<u32, &'static u32>> = Arc::new(BTreeMap::new());
needs_send(async_fn_b(map.clone()));
}
error: implementation of `std::marker::Send` is not general enough
--> src/main.rs:24:5
|
24 | needs_send(async_fn_b(map.clone()));
| ^^^^^^^^^^
|
= note: `std::marker::Send` would have to be implemented for the type `alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Immut<'0>, u32, &'1 u32, alloc::collections::btree::node::marker::Leaf>`, for any two lifetimes `'0` and `'1`
= note: but `std::marker::Send` is actually implemented for the type `alloc::collections::btree::node::NodeRef<alloc::collections::btree::node::marker::Immut<'2>, u32, &u32, alloc::collections::btree::node::marker::Leaf>`, for some specific lifetime `'2`
Adrodoc, LYF1999, Millione, hcsch, Thomasdezeeuw and 7 morejuancampa, HTGAzureX1212, yokomizor, lowlevl and willrnch
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-coroutinesArea: CoroutinesArea: CoroutinesA-trait-systemArea: Trait systemArea: Trait systemAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Type
Projects
Status
On deck