Skip to content

Send impl error message is too smart #21793

Closed
@Gankra

Description

@Gankra
use std::collections::BTreeMap;
use std::rc::Rc;
fn foo<T: Send>() {}
fn main() {
    foo::<BTreeMap<Rc<()>, Rc<()>>>();
}
<anon>:5:5: 5:36 error: the trait `core::marker::Send` is not implemented for the type `alloc::rc::Rc<()>` [E0277]
<anon>:5     foo::<BTreeMap<Rc<()>, Rc<()>>>();
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<anon>:5:5: 5:36 note: `alloc::rc::Rc<()>` cannot be sent between threads safely
<anon>:5     foo::<BTreeMap<Rc<()>, Rc<()>>>();
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error

The lack of an impl of Send for Rc is the problem, but the more pertinent problem is that BTreeMap itself is not Send. The Rc detail is a great piece of additional information, though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions