Skip to content

Can't express "T : Foo<X1> implies T : Foo<X2>" #11318

Closed
@vadimcn

Description

@vadimcn

[Previously reported on rust-dev]

I'm trying to say "Any type that implements Foo<X1> also implements Foo<X2>":

trait Foo<T> {}
struct X1;
struct X2;

impl<T: Foo<X1>> Foo<X2> for T {}

fn main() {}

but this does not compile:

test.rs:5:1: 5:34 error: expected Foo<X2>, but found Foo<X1> (expected struct X2 but found struct X1)
test.rs:5 impl<T: Foo<X1>> Foo<X2> for T {}

This is supposedly related to Rust not distinguishing between different instantiations of generic traits, though you'd never guess that from the error message...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions