Skip to content

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

Closed

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.)

Activity

  1. Aatch commented on Aug 3, 2013

    @Aatch
    Contributor

    Nominating for a milestone, probably well-defined. We need some way of bounding the Self type inside default methods.

  2. catamorphism commented on Sep 12, 2013

    @catamorphism
    Contributor

    We think this is fixed. Marked as needstest.

  3. added a commit that references this issue on Sep 16, 2013
    9c1cc73
  4. added a commit that references this issue on Sep 17, 2013
    4f92f45
  5. added a commit that references this issue on Sep 17, 2013
    07e821a
  6. added a commit that references this issue on Dec 30, 2021
    3354876
  7. added a commit that references this issue on Aug 21, 2026
    c8066eb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemE-needs-test

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions