Skip to content

Associated types and supertraits #19541

Closed
@nrc

Description

@nrc

These basically don't work well together. The following works:

pub trait Bar {
    type B;
}

pub trait Foo: Bar<A=int> {
    type A;
}

The following gives an error (the wrong error too), but should compile:

pub trait Bar {
    type B;
}

pub trait Foo: Bar {
    type A;
}

In this case, B should be treated like an associated type on Foo.

I am not sure if type B = int or even type B: Baz should be allowed in Foo, but I assume not (at least for now).

When the above works, we should require super trait associated types are given in type bindings, e.g., Foo<A=int, B=int>.

We should also allow Self::B in the body of Foo and if type T has bound Foo, then we should allow T::B.

Metadata

Metadata

Assignees

No one assigned

    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