Skip to content

Multiple different parameterisations of a trait in a bounds list conflict. #21669

@dylanede

Description

@dylanede

With this preamble:

struct A;
struct B;

trait F<T> {}

this code does not compile:

fn f<T: F<A> + F<B>>() {}

but this does:

fn f<T>() where T : F<A> + F<B> {}

As an example of a case where this can't be worked around, consider associated types. This example does not seem to have any possible workaround:

trait G {
    type X : F<A> + F<B>;
}

This attempt at a workaround causes an ICE:

trait G where Self::X : F<A> + F<B> {
    type X;
}

and this example apparently isn't valid syntax:

trait G {
    type X where X : F<A> + F<B>;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions