Skip to content

Send/Sync transitive analysis lost in stored associated types #22828

Closed
@alexcrichton

Description

@alexcrichton

For example, this code does not compile:

trait Foo {
    type A;
    fn foo(&self) {}
}

impl Foo for usize {
    type A = usize;
}

struct Bar<T: Foo> { inner: T::A }

fn is_send<T: Send>() {}

fn main() {
    is_send::<Bar<usize>>();
}
foo.rs:15:5: 15:26 error: the trait `core::marker::Send` is not implemented for the type `<usize as Foo>::A` [E0277]
foo.rs:15     is_send::<Bar<usize>>();
              ^~~~~~~~~~~~~~~~~~~~~
foo.rs:15:5: 15:26 note: `<usize as Foo>::A` cannot be sent between threads safely
foo.rs:15     is_send::<Bar<usize>>();
              ^~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error

cc @nikomatsakis, @pnkfelix

Metadata

Metadata

Assignees

Labels

A-associated-itemsArea: Associated items (types, constants & functions)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions