Skip to content

Self is not recognised as implementing kinds in default method implementations #8171

Closed
@chris-morgan

Description

@chris-morgan

(This is related to #7661. It is in fact the second case there, but moved into a new issue as it languished there with the rest fixed.)

fn require_send<T: Send>(_: T){}

trait TragicallySelfIsNotSend: Send {
    fn x(self) {
        require_send(self);
    }
}

fn main(){}

This does not compile, though it should:

<anon>:5:8: 5:20 error: instantiating a type parameter with an incompatible type `Self`, which does not fulfill `Send`
<anon>:5         require_send(self);
                 ^~~~~~~~~~~~
error: aborting due to previous error

I need this to be able to refer to self inside a spawn closure, and that will only work if it's Send, and so there I sadly cannot provide a default method implementation of the trait at present.

(buzzwords for search: built-in trait inheritance.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions