Skip to content

btree_map::OccupiedEntry: Send regression #76686

@ghost

Description

The code below does not compile on new versions of rustc (bisect below)

use std::collections::{btree_map::Entry, BTreeMap}; use std::thread::spawn; fn main() { let map = BTreeMap::<i32, i32>::new(); let map = Box::leak(Box::new(map)); match map.entry(1) { Entry::Occupied(entry) => { spawn(move || { entry.get(); }); } _ => (), } }
error[E0277]: `NonNull<BTreeMap<i32, i32>>` cannot be sent between threads safely --> src/main.rs:10:13 | 10 | spawn(move || { | _____________^^^^^_- | | | | | `NonNull<BTreeMap<i32, i32>>` cannot be sent between threads safely 11 | | entry.get(); 12 | | }); | |_____________- within this `[closure@src/main.rs:10:19: 12:14 entry:std::collections::btree_map::OccupiedEntry<'_, i32, i32>]` | ::: /home/antek/.local/opt/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:596:8 | 596 | F: Send + 'static, | ---- required by this bound in `spawn` | = help: within `[closure@src/main.rs:10:19: 12:14 entry:std::collections::btree_map::OccupiedEntry<'_, i32, i32>]`, the trait `Send` is not implemented for `NonNull<BTreeMap<i32, i32>>` = note: required because it appears within the type `alloc::collections::btree::borrow::DormantMutRef<'_, BTreeMap<i32, i32>>` = note: required because it appears within the type `std::collections::btree_map::OccupiedEntry<'_, i32, i32>` = note: required because it appears within the type `[closure@src/main.rs:10:19: 12:14 entry:std::collections::btree_map::OccupiedEntry<'_, i32, i32>]` 

Bisect

searched nightlies: from nightly-2020-09-11 to nightly-2020-09-12
regressed nightly: nightly-2020-09-12
searched commits: from a1947b3 to 9911160
regressed commit: ee04f9a

bisected with cargo-bisect-rustc v0.5.2

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start 2020-09-11 

Metadata

Metadata

Labels

A-collectionsArea: `std::collections`C-bugCategory: This is a bug.P-criticalCritical priorityT-libsRelevant to the library team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions